diff --git a/website/config/conf.d/default.conf b/website/config/conf.d/default.conf index 56eedfebabe..a35e5b6fb2b 100644 --- a/website/config/conf.d/default.conf +++ b/website/config/conf.d/default.conf @@ -4,7 +4,7 @@ server { error_page 404 /404.html; - set $latestStableVersion v14; + set $latestStableVersion v16; location / { # temporary redirects @@ -39,8 +39,9 @@ server { # marshmallowpie -> hotchocolate rewrite ^/docs/marshmallowpie.*$ $hc permanent; - # ensures version for hc & sbs is always set - rewrite ^/docs/(hotchocolate|strawberryshake)(?!/v\d+$|/v\d+/.*)(/.*)$ /docs/$1/$latestStableVersion$2 permanent; + # ensures version for hc, sbs, and fusion is always set + rewrite ^/docs/(hotchocolate|strawberryshake|fusion)/?$ /docs/$1/$latestStableVersion/ permanent; + rewrite ^/docs/(hotchocolate|strawberryshake|fusion)(?!/v\d+$|/v\d+/.*)(/.*)$ /docs/$1/$latestStableVersion$2 permanent; # ensures version for bcp is always set rewrite ^/docs/(bananacakepop)(?!/v\d+$|/v\d+\/.*)(/.*)$ /docs/$1/v2$2 permanent; diff --git a/website/package.json b/website/package.json index 4e1ef181911..61f0603dac7 100644 --- a/website/package.json +++ b/website/package.json @@ -13,8 +13,9 @@ "url": "https://github.com/ChilliCream/graphql-platform/issues" }, "scripts": { - "dev": "next dev --hostname 0.0.0.0 --port 3000", - "build": "next build && npx tsx scripts/generate-llms-txt.ts", + "dev": "yarn sync-doc-assets && next dev --hostname 0.0.0.0 --port 3000", + "build": "yarn sync-doc-assets && next build && npx tsx scripts/generate-llms-txt.ts", + "sync-doc-assets": "npx tsx scripts/sync-doc-assets.ts", "optimize-images": "npx tsx -e \"import { optimizeDirectory } from './lib/image-optimization'; (async () => { await optimizeDirectory(['./public/images', './public/docs']); })();\"", "start": "next start", "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"", diff --git a/website/scripts/sync-doc-assets.ts b/website/scripts/sync-doc-assets.ts new file mode 100644 index 00000000000..cc499f9ff93 --- /dev/null +++ b/website/scripts/sync-doc-assets.ts @@ -0,0 +1,48 @@ +import fs from "fs/promises"; +import path from "path"; + +const sourceRoot = path.join(process.cwd(), "src/docs"); +const targetRoot = path.join(process.cwd(), "public/docs"); +const markdownExtensions = new Set([".md", ".mdx"]); + +async function copyDocAssets(relativeDir = ""): Promise { + const sourceDir = path.join(sourceRoot, relativeDir); + const entries = await fs.readdir(sourceDir, { withFileTypes: true }); + let copied = 0; + + for (const entry of entries) { + const relativePath = path.join(relativeDir, entry.name); + const sourcePath = path.join(sourceRoot, relativePath); + const targetPath = path.join(targetRoot, relativePath); + + if (entry.isDirectory()) { + copied += await copyDocAssets(relativePath); + continue; + } + + if (!entry.isFile()) { + continue; + } + + const ext = path.extname(entry.name).toLowerCase(); + if (markdownExtensions.has(ext)) { + continue; + } + + await fs.mkdir(path.dirname(targetPath), { recursive: true }); + await fs.copyFile(sourcePath, targetPath); + copied++; + } + + return copied; +} + +async function main() { + const copied = await copyDocAssets(); + console.log(`synced ${copied} doc asset files`); +} + +main().catch((error) => { + console.error("failed to sync doc assets", error); + process.exitCode = 1; +}); diff --git a/website/src/docs/docs.json b/website/src/docs/docs.json index 73dba37008c..a8d6aa41e0c 100644 --- a/website/src/docs/docs.json +++ b/website/src/docs/docs.json @@ -166,7 +166,7 @@ "title": "Fusion", "description": "Federated GraphQL Gateway", "metaDescription": "Fusion is a powerful, open-source GraphQL gateway that helps developers to build a unified API for their services.", - "latestStableVersion": "v15", + "latestStableVersion": "v16", "versions": [ { "path": "v16", @@ -301,7 +301,7 @@ "title": "Hot Chocolate", "description": "GraphQL Server / Gateway", "metaDescription": "Hot Chocolate is the most efficient, feature-rich, open-source GraphQL server in the .NET ecosystem, that helps developers to build powerful APIs.", - "latestStableVersion": "v15", + "latestStableVersion": "v16", "versions": [ { "path": "v16", @@ -2462,7 +2462,7 @@ "title": "Strawberry Shake", "description": "GraphQL Client for .NET", "metaDescription": "Strawberry Shake is an incredible GraphQL client for the .NET ecosystem, that helps developers to build awesome UIs in Blazor, Maui, and more.", - "latestStableVersion": "v15", + "latestStableVersion": "v16", "versions": [ { "path": "v16",