Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions website/config/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ server {

error_page 404 /404.html;

set $latestStableVersion v14;
set $latestStableVersion v16;

location / {
# temporary redirects
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}\"",
Expand Down
48 changes: 48 additions & 0 deletions website/scripts/sync-doc-assets.ts
Original file line number Diff line number Diff line change
@@ -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<number> {
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;
});
6 changes: 3 additions & 3 deletions website/src/docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down