diff --git a/plugins/plugin-shikiji/__test__/copyCodeButton.spec.ts b/plugins/plugin-shikiji/__test__/copyCodeButton.spec.ts index e3afd563..88003d3b 100644 --- a/plugins/plugin-shikiji/__test__/copyCodeButton.spec.ts +++ b/plugins/plugin-shikiji/__test__/copyCodeButton.spec.ts @@ -13,7 +13,7 @@ function createMarkdown(options: boolean | CopyCodeOptions = {}, lang = 'en-US') env: { isDebug: false }, siteData: { lang, - locales: { '/': { lang }, '/zh/': { lang: 'zh-CN' }, '/en/': { lang: 'en-US' } }, + locales: { '/': { lang }, '/zh/': { lang: 'zh-CN' }, '/en/': { lang: 'en-US' }, '/xxx/': { lang: 'unknown' } }, }, } as unknown as App copyCodeButtonPlugin(md, app, options) diff --git a/plugins/plugin-shikiji/src/node/copy-code-button/createCopyCodeButtonRender.ts b/plugins/plugin-shikiji/src/node/copy-code-button/createCopyCodeButtonRender.ts index a3925c67..f965ce15 100644 --- a/plugins/plugin-shikiji/src/node/copy-code-button/createCopyCodeButtonRender.ts +++ b/plugins/plugin-shikiji/src/node/copy-code-button/createCopyCodeButtonRender.ts @@ -32,7 +32,7 @@ export function createCopyCodeButtonRender(app: App, options?: boolean | CopyCod return (filePathRelative: string) => { const relativePath = ensureLeadingSlash(filePathRelative) const localePath = resolveLocalePath(locales, relativePath) - const { title, copied } = locales[localePath] + const { title, copied } = locales[localePath] || locales['/'] return `` }