fix(plugin-shikiji): in copy-code, unknown locales fallback not set (#348)

This commit is contained in:
pengzhanbo 2024-11-22 07:40:29 +08:00 committed by GitHub
parent 11b57c4f36
commit c09895ef1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -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)

View File

@ -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 `<button class="${className}" title="${title}" data-copied="${copied}"></button>`
}