diff --git a/docusaurus.config.ts b/docusaurus.config.ts index da14145d8..b0c660805 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -14,14 +14,35 @@ export default { tagline: "GraphQL platform engineered for scale", headTags: [ { - tagName: "script", + tagName: "link", + attributes: { + rel: "preconnect", + href: "https://fonts.googleapis.com", + }, + }, + { + tagName: "link", attributes: { - id: "chatbotscript", - "data-accountid": "CZPG9aVdtk59Tjz4SMTu8w==", - "data-websiteid": "75VGI0NlBqessD4BQn2pFg==", - src: "https://app.robofy.ai/bot/js/common.js?v=" + new Date().getTime(), + rel: "preconnect", + href: "https://fonts.gstatic.com", + crossorigin: "anonymous", }, }, + { + tagName: "link", + attributes: { + rel: "preload", + as: "style", + href: "https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Space+Mono&display=swap", + onload: "this.onload=null;this.rel='stylesheet'", + }, + }, + { + tagName: "noscript", + attributes: {}, + innerHTML: + '', + }, { tagName: "script", attributes: { @@ -61,7 +82,7 @@ export default { }, }, future: { - experimental_faster: false, // Required for faster production builds. For reference: https://docusaurus.io/blog/releases/3.6#adoption-strategy + experimental_faster: true, // Required for faster production builds. For reference: https://docusaurus.io/blog/releases/3.6#adoption-strategy }, presets: [ [ @@ -215,6 +236,7 @@ export default { }, }, ], + "./plugins/no-hydrate-home-plugin.ts", async function tailwindPlugin() { return { name: "docusaurus-tailwindcss", diff --git a/package-lock.json b/package-lock.json index b08348526..581ef4f75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2514,9 +2514,9 @@ } }, "node_modules/@csstools/color-helpers": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.0.1.tgz", - "integrity": "sha512-MKtmkA0BX87PKaO1NFRTFH+UnkgnmySQOvNxJubsadusqPEC2aJ9MOQiMceZJJ6oitUl/i0L6u0M1IrmAOmgBA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.1.0.tgz", + "integrity": "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA==", "funding": [ { "type": "github", @@ -2533,9 +2533,9 @@ } }, "node_modules/@csstools/css-calc": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.0.tgz", - "integrity": "sha512-X69PmFOrjTZfN5ijxtI8hZ9kRADFSLrmmQ6hgDJ272Il049WGKpDY64KhrFm/7rbWve0z81QepawzjkKlqkNGw==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.4.tgz", + "integrity": "sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==", "funding": [ { "type": "github", @@ -2551,14 +2551,14 @@ "node": ">=18" }, "peerDependencies": { - "@csstools/css-parser-algorithms": "^3.0.4", - "@csstools/css-tokenizer": "^3.0.3" + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" } }, "node_modules/@csstools/css-color-parser": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.0.6.tgz", - "integrity": "sha512-S/IjXqTHdpI4EtzGoNCHfqraXF37x12ZZHA1Lk7zoT5pm2lMjFuqhX/89L7dqX4CcMacKK+6ZCs5TmEGb/+wKw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.1.0.tgz", + "integrity": "sha512-nbtKwh3a6xNVIp/VRuXV64yTKnb1IjTAEEh3irzS+HkKjAOYLTGNb9pmVNntZ8iVBHcWDA2Dof0QtPgFI1BaTA==", "funding": [ { "type": "github", @@ -2571,21 +2571,21 @@ ], "license": "MIT", "dependencies": { - "@csstools/color-helpers": "^5.0.1", - "@csstools/css-calc": "^2.1.0" + "@csstools/color-helpers": "^5.1.0", + "@csstools/css-calc": "^2.1.4" }, "engines": { "node": ">=18" }, "peerDependencies": { - "@csstools/css-parser-algorithms": "^3.0.4", - "@csstools/css-tokenizer": "^3.0.3" + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" } }, "node_modules/@csstools/css-parser-algorithms": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.4.tgz", - "integrity": "sha512-Up7rBoV77rv29d3uKHUIVubz1BTcgyUK72IvCQAbfbMv584xHcGKCKbWh7i8hPrRJ7qU4Y8IO3IY9m+iTB7P3A==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz", + "integrity": "sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==", "funding": [ { "type": "github", @@ -2601,13 +2601,13 @@ "node": ">=18" }, "peerDependencies": { - "@csstools/css-tokenizer": "^3.0.3" + "@csstools/css-tokenizer": "^3.0.4" } }, "node_modules/@csstools/css-tokenizer": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.3.tgz", - "integrity": "sha512-UJnjoFsmxfKUdNYdWgOB0mWUypuLvAfQPH1+pyvRJs6euowbFkFC6P13w1l8mJyi3vxYMxc9kld5jZEGRQs6bw==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz", + "integrity": "sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==", "funding": [ { "type": "github", @@ -12621,14 +12621,16 @@ "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.3.2", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", - "micromatch": "^4.0.4" + "micromatch": "^4.0.8" }, "engines": { "node": ">=8.6.0" @@ -17950,7 +17952,9 @@ "license": "MIT" }, "node_modules/micromatch": { - "version": "4.0.7", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "license": "MIT", "dependencies": { "braces": "^3.0.3", @@ -18104,7 +18108,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.7", + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", "funding": [ { "type": "github", @@ -19047,7 +19053,9 @@ } }, "node_modules/postcss": { - "version": "8.4.38", + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.12.tgz", + "integrity": "sha512-W62t/Se6rA0Az3DfCL0AqJwXuKwBeYg6nOaIgzP+xZ7N5BFCI7DYi1qs6ygUYT6rvfi6t9k65UMLJC+PHZpDAA==", "funding": [ { "type": "opencollective", @@ -19064,9 +19072,9 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.7", - "picocolors": "^1.0.0", - "source-map-js": "^1.2.0" + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" }, "engines": { "node": "^10 || ^12 || >=14" @@ -22661,7 +22669,9 @@ } }, "node_modules/source-map-js": { - "version": "1.2.0", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" diff --git a/package.json b/package.json index 59dbedce6..2ee57fcd7 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "@docusaurus/plugin-ideal-image": "3.6.3", "@docusaurus/preset-classic": "3.6.3", "@docusaurus/theme-search-algolia": "3.6.3", + "@graphiql/create-fetcher": "^0.1.0", "@mdx-js/react": "^3.0.1", "autoprefixer": "^10.4.19", "clsx": "^2.1.1", @@ -49,8 +50,7 @@ "react-hot-toast": "^2.4.1", "react-on-screen": "^2.1.1", "react-platform-js": "^0.0.1", - "tailwindcss": "^3.4.4", - "@graphiql/create-fetcher": "^0.1.0" + "tailwindcss": "^3.4.4" }, "devDependencies": { "@babel/core": "^7.24.7", diff --git a/plugins/no-hydrate-home-plugin.ts b/plugins/no-hydrate-home-plugin.ts new file mode 100644 index 000000000..6e0022802 --- /dev/null +++ b/plugins/no-hydrate-home-plugin.ts @@ -0,0 +1,93 @@ +import path from 'node:path' +import fs from 'node:fs/promises' +import crypto from 'node:crypto' +import type {Plugin} from '@docusaurus/types' + +const VIMEO_VIDEO_ID = '1011521201' + +export default function lazyHydrateHomePlugin(): Plugin { + return { + name: 'lazy-hydrate-home-plugin', + async postBuild({outDir}) { + const indexPath = path.join(outDir, 'index.html') + let html: string + try { + html = await fs.readFile(indexPath, 'utf8') + } catch { + return + } + const before = html.length + + const runtimeMatch = html.match(/\s]*?)\s+defer>/) + const mainMatch = html.match(/\s]*?)\s+defer>/) + const runtimeUrl = runtimeMatch ? runtimeMatch[1] : '' + const mainUrl = mainMatch ? mainMatch[1] : '' + const preloadMatches = html.match(/]*as=script[^>]*>/g) || [] + const modulePreloadMatches = html.match(/]*>/g) || [] + + let stripped = false + if (runtimeMatch && mainMatch) { + for (const p of preloadMatches) html = html.replace(p, '') + for (const p of modulePreloadMatches) html = html.replace(p, '') + html = html.replace(runtimeMatch[0], '') + html = html.replace(mainMatch[0], '') + stripped = true + } + + // Swap full styles.xxx.css with pre-baked home-min.css + let cssSwapped = false + const homeMinPath = path.join(outDir, 'assets', 'css', 'home-min.css') + try { + await fs.access(homeMinPath) + const stylesLinkRe = // + const stylesPreloadRe = /]*as=style[^>]*>/g + const sm = html.match(stylesLinkRe) + if (sm) { + html = html.replace(sm[0], '') + cssSwapped = true + } + html = html.replace(stylesPreloadRe, '') + } catch {} + + // Self-host Google Fonts + html = html.replace(/]*>/g, '') + html = html.replace(/]*>/g, '') + html = html.replace(/]*googleapis[^>]*>/g, '') + html = html.replace(/]*>/g, '') + html = html.replace(/