From 6ab0d5bb1a1a295e60579b6bd16b0ffacb33ab72 Mon Sep 17 00:00:00 2001 From: Cambrian Lab Date: Tue, 12 May 2026 23:20:46 +0800 Subject: [PATCH] Improve homepage Lighthouse performance --- docusaurus.config.ts | 14 +- plugins/static-homepage-plugin.ts | 22 +++ src/components/shared/GlobalLayout.tsx | 20 ++ src/css/custom.css | 6 +- src/pages/index.tsx | 254 ++++++++++++++++++++++--- src/theme/Layout/index.tsx | 1 + 6 files changed, 277 insertions(+), 40 deletions(-) create mode 100644 plugins/static-homepage-plugin.ts diff --git a/docusaurus.config.ts b/docusaurus.config.ts index da14145d8..46b649db4 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -13,15 +13,6 @@ export default { trailingSlash: true, tagline: "GraphQL platform engineered for scale", headTags: [ - { - tagName: "script", - attributes: { - id: "chatbotscript", - "data-accountid": "CZPG9aVdtk59Tjz4SMTu8w==", - "data-websiteid": "75VGI0NlBqessD4BQn2pFg==", - src: "https://app.robofy.ai/bot/js/common.js?v=" + new Date().getTime(), - }, - }, { tagName: "script", attributes: { @@ -78,9 +69,7 @@ export default { editUrl: `https://github.com/${organization}/${project}/tree/develop`, }, blog: false, - theme: { - customCss: require.resolve("./src/css/custom.css"), - }, + theme: {}, sitemap: { changefreq: "weekly", priority: 0.5, @@ -152,6 +141,7 @@ export default { tableOfContents: {}, } satisfies Preset.ThemeConfig, plugins: [ + "./plugins/static-homepage-plugin.ts", [ "./plugins/custom-blog-plugin.ts", { diff --git a/plugins/static-homepage-plugin.ts b/plugins/static-homepage-plugin.ts new file mode 100644 index 000000000..20cb5bc09 --- /dev/null +++ b/plugins/static-homepage-plugin.ts @@ -0,0 +1,22 @@ +import fs from "fs/promises" +import path from "path" + +function staticHomepagePlugin() { + return { + name: "static-homepage-plugin", + async postBuild({outDir}: {outDir: string}) { + const indexPath = path.join(outDir, "index.html") + const html = await fs.readFile(indexPath, "utf8") + const staticHtml = html + .replace(/