Update Site source
This commit is contained in:
1 parent
ff08916cf0
commit
3af7215854
1 file changed
+7
-1
+7
-1
@@ -9,7 +9,13 @@ await rm(dist, { recursive: true, force: true });
|
||||
await Promise.all([mkdir(server, { recursive: true }), mkdir(meta, { recursive: true })]);
|
||||
const [rawIndexHtml, addonsJs, i18nJs, i18nRenderersJs] = await Promise.all([text("index.html"), text("addons.js"), text("i18n.js"), text("i18n-renderers.js")]);
|
||||
const release = "1.1.0";
|
||||
const indexHtml = rawIndexHtml.replace('src="addons.js"', `src="addons.js?v=${release}"`);
|
||||
// The original single-file prototype carried an obsolete English-to-Chinese
|
||||
// DOM replacement block. Runtime localisation now lives in i18n.js and
|
||||
// i18n-renderers.js, so exclude that dead block from the deployed document.
|
||||
const withoutLegacyI18n = rawIndexHtml
|
||||
.replace(/const ZH=.*?function browserLanguage/s, 'function browserLanguage')
|
||||
.replace(/function localizeDynamicText.*?function i18n\(key,fallback=key\)\{return lang\(\)===\'zh\'\?\(ZH\[key\]\|\|key\):fallback\}/s, 'function i18n(key,fallback=key){return fallback}');
|
||||
const indexHtml = withoutLegacyI18n.replace('src="addons.js"', `src="addons.js?v=${release}"`);
|
||||
await writeFile(new URL("assets.js", server), `export const indexHtml=${JSON.stringify(indexHtml)};\nexport const addonsJs=${JSON.stringify(addonsJs)};\nexport const i18nJs=${JSON.stringify(i18nJs)};\nexport const i18nRenderersJs=${JSON.stringify(i18nRenderersJs)};\n`);
|
||||
await copyFile(new URL("../worker/index.js", import.meta.url), new URL("index.js", server));
|
||||
await copyFile(new URL("../.openai/hosting.json", import.meta.url), new URL("hosting.json", meta));
|
||||
|
||||
Reference in new issue
Block a user