From 9c3bcbe4fd415190709e00cc9463ac198455cc23 Mon Sep 17 00:00:00 2001 From: Charlie Egan Date: Thu, 17 Jul 2025 12:10:25 +0100 Subject: [PATCH] website: Render versions under /data/versions.json (#7783) This will facilitate other sites checking the current version of the OPA website. Signed-off-by: Charlie Egan --- docs/.gitignore | 3 +++ docs/docusaurus.config.js | 7 +++++++ netlify.toml | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/docs/.gitignore b/docs/.gitignore index 693fca82f3..e0e7820f25 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -2,3 +2,6 @@ build node_modules* package-lock.json + +# this is generated by the build process +static/data/versions.json diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index fd2f5660f8..ef31bdc34b 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -445,6 +445,13 @@ The Linux Foundation has registered trademarks and uses trademarks. For a list o const { versions } = content; await createData("versions.json", JSON.stringify(versions, null, 2)); + + const staticDir = path.join(context.siteDir, "static", "data"); + await fs.mkdir(staticDir, { recursive: true }); + await fs.writeFile( + path.join(staticDir, "versions.json"), + JSON.stringify(versions, null, 2), + ); }, }; }, diff --git a/netlify.toml b/netlify.toml index 689b5ffe06..a7aa631e83 100644 --- a/netlify.toml +++ b/netlify.toml @@ -20,3 +20,12 @@ function = "badge" [[edge_functions]] path = "/docs/*" function = "version-redirect" + +# /data/versions.json is used by versioned OPA deployments to determine +# if what the latest release is, how outdated they are. +[[headers]] +for = "/data/versions.json" +[headers.values] +Access-Control-Allow-Origin = "https://*.netlify.app" +Access-Control-Allow-Methods = "GET, OPTIONS" +Access-Control-Allow-Headers = "Content-Type"