diff --git a/docusaurus.config.ts b/docusaurus.config.ts index ef14d54c2..a46445f55 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -14,7 +14,7 @@ const i18n = require("./i18n/config"); const isDev = process.env.NODE_ENV !== "production"; -const proxy = process.env.PROXY || 'release'; +const proxy = process.env.PROXY || "release"; const ossEnv = isDev ? "/" : proxy; const targetPortalPath = proxy === "canary" ? "https://m.longbridge.xyz" : "https://m.lbkrs.com"; const localAPIProxyPath = "/dev-proxy"; @@ -29,7 +29,7 @@ const config: Config = { baseUrlIssueBanner: false, onBrokenLinks: "ignore", onBrokenMarkdownLinks: "ignore", - ssrTemplate:genSSRTemplate(ossEnv), + ssrTemplate: genSSRTemplate(ossEnv), trailingSlash: false, // https://docusaurus.io/docs/api/docusaurus-config#trailingSlash favicon: "https://pub.lbkrs.com/static/offline/202211/qohHsXzN9qtQ23ox/longport_favicon.png", customFields: { @@ -107,7 +107,20 @@ const config: Config = { }, theme: { customCss: "./src/css/custom.scss" + }, + sitemap: { + createSitemapItems: async (params) => { + const { defaultCreateSitemapItems, ...rest } = params; + const items = await defaultCreateSitemapItems(rest); + return await items.map((item) => { + return item.url = item.url + .replace("zh-CN/zh-CN", "zh-CN") + .replace("en/en", "en") + .replace("zh-HK/zh-HK", "zh-HK") + }); + } } + } satisfies Preset.Options ] ], diff --git a/package.json b/package.json index 43df2cda3..4c0fce674 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "start": "docusaurus start --port 4040", "dev": "yarn start", "build": "yarn clear && docusaurus build --out-dir ./dist", + "dev:build": "docusaurus build --out-dir ./dist", "postbuild": "sh ./setup-dist-dir.sh", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", diff --git a/setup-dist-dir.sh b/setup-dist-dir.sh index 5e8459a80..65cbfccb1 100755 --- a/setup-dist-dir.sh +++ b/setup-dist-dir.sh @@ -1,12 +1,9 @@ # step 1 create basic dirs -# mv all dist to temp dir for backup -mv ./dist/zh-CN /tmp/ && mv ./dist/zh-HK /tmp/ && mv ./dist/en /tmp/ +mv ./dist/learn.html ./dist/en/ +mv ./dist/sitemap.xml ./dist/en/ +mv ./dist/404.html ./dist/en/ +mv ./dist/.nojekyll ./dist/en/ -# cp all dist file to dist/en -mkdir -p ./dist/en -mv ./dist/* ./dist/en/ -mv /tmp/zh-CN ./dist/ && mv /tmp/zh-HK ./dist/ && mv /tmp/en/* ./dist/en/ - -# step 3 remove duplicated files +# step 2 remove duplicated files cp -rf ./dist/zh-CN/zh-CN/* ./dist/zh-CN/ && rm -rf ./dist/zh-CN/zh-CN cp -rf ./dist/zh-HK/zh-HK/* ./dist/zh-HK/ && rm -rf ./dist/zh-HK/zh-HK