diff --git a/demo/yun/pages/posts/i18n.md b/demo/yun/pages/posts/i18n.md index 4800b4af..2a3021e8 100644 --- a/demo/yun/pages/posts/i18n.md +++ b/demo/yun/pages/posts/i18n.md @@ -70,7 +70,6 @@ The large text sections of the article content section use a different CSS i18n 配置 Vite Vue-i18n 插件 [@intlify/vite-plugin-vue-i18n](https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n): ::: - ::: en Config Vite Vue-i18n plugin [@intlify/vite-plugin-vue-i18n](https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n): ::: diff --git a/demo/yun/valaxy.config.ts b/demo/yun/valaxy.config.ts index 5ba306b9..533ce3cc 100644 --- a/demo/yun/valaxy.config.ts +++ b/demo/yun/valaxy.config.ts @@ -180,13 +180,5 @@ export default defineConfig({ icp: '苏ICP备17038157号', }, }, - - menu: { - custom: { - title: 'docs.view_docs', - icon: 'i-ri-file-list-2-line', - url: '/docs', - }, - }, }, }) diff --git a/demo/yun/vite.config.ts b/demo/yun/vite.config.ts index 17f79631..90e313c7 100644 --- a/demo/yun/vite.config.ts +++ b/demo/yun/vite.config.ts @@ -51,6 +51,9 @@ export default defineConfig({ tip: { icon: 'i-carbon-thumbs-up', text: 'ヒント', + langs: { + 'zh-CN': '提示', + }, }, warning: { icon: 'i-carbon-warning-alt', diff --git a/docs/pages/guide/container.md b/docs/pages/guide/container.md index fe29b29a..f09bcab7 100644 --- a/docs/pages/guide/container.md +++ b/docs/pages/guide/container.md @@ -19,8 +19,6 @@ custom block. ::: - - ::: tip tip diff --git a/docs/pages/guide/i18n.md b/docs/pages/guide/i18n.md index d2e4765b..323df34f 100644 --- a/docs/pages/guide/i18n.md +++ b/docs/pages/guide/i18n.md @@ -23,7 +23,7 @@ Valaxy **提出**了一种基于 CSS 面向博客的 i18n 解决方案。 **The effect is as follows** (click the button to switch). ::: - + ::: zh-CN 另一种 i18n 方案。 diff --git a/docs/vite.config.ts b/docs/vite.config.ts index 19de2ecd..2463cd8f 100644 --- a/docs/vite.config.ts +++ b/docs/vite.config.ts @@ -16,18 +16,15 @@ export default defineConfig({ blocks: { tip: { icon: 'i-carbon-thumbs-up', - text: 'ヒント', }, warning: { icon: 'i-carbon-warning-alt', - text: '注意', }, danger: { icon: 'i-carbon-warning', - text: '警告', }, info: { - text: 'información', + text: 'i-carbon-information', }, }, }, diff --git a/packages/valaxy/client/styles/global/i18n.scss b/packages/valaxy/client/styles/global/i18n.scss index e94c1edb..525af98f 100644 --- a/packages/valaxy/client/styles/global/i18n.scss +++ b/packages/valaxy/client/styles/global/i18n.scss @@ -8,7 +8,8 @@ html[lang] { h4[lang], h5[lang], h6[lang], - div[lang] { + div[lang], + span[lang] { display: none; } } @@ -32,7 +33,8 @@ html[lang] { h4[lang="#{$lang}"], h5[lang="#{$lang}"], h6[lang="#{$lang}"], - div[lang="#{$lang}"] { + div[lang="#{$lang}"], + span[lang="#{$lang}"] { display: block; } } diff --git a/packages/valaxy/node/markdown/markdown-it/container.ts b/packages/valaxy/node/markdown/markdown-it/container.ts index 34163827..09fcebf1 100644 --- a/packages/valaxy/node/markdown/markdown-it/container.ts +++ b/packages/valaxy/node/markdown/markdown-it/container.ts @@ -13,7 +13,7 @@ type ContainerArgs = [ }, ] -function createContainer(classes: string, defaultTitle: string, { icon, color }: Omit = {}): ContainerArgs { +function createContainer(classes: string, { icon, color, text: defaultTitle, langs }: BlockItem = {}): ContainerArgs { return [ container, classes, @@ -32,9 +32,14 @@ function createContainer(classes: string, defaultTitle: string, { icon, color }: if (icon) iconTag = `` - return `

${iconTag}${ - info || defaultTitle - }

\n` + let title = `${info || defaultTitle}` + if (langs) { + Object.keys(langs).forEach((lang) => { + title += `${langs[lang]}` + }) + } + + return `

${iconTag}${title}

\n` } else { return classes === 'details' ? '\n' : '
\n' @@ -48,6 +53,10 @@ export interface BlockItem { text?: string icon?: string color?: string + /** + * for i18n + */ + langs?: { [key: string]: string } } export interface Blocks { @@ -61,18 +70,33 @@ export interface Blocks { const defaultBlocksOptions: Blocks = { tip: { text: 'TIP', + langs: { + 'zh-CN': '提示', + }, }, warning: { text: 'WARNING', + langs: { + 'zh-CN': '注意', + }, }, danger: { - text: 'WARNING', + text: 'DANGER', + langs: { + 'zh-CN': '警告', + }, }, info: { text: 'INFO', + langs: { + 'zh-CN': '信息', + }, }, details: { text: 'Details', + langs: { + 'zh-CN': '详情', + }, }, } @@ -83,7 +107,7 @@ export const containerPlugin = (md: MarkdownIt, options: Blocks = {}) => { ...(options[optionKey as keyof Blocks] || {}), } - md.use(...createContainer(optionKey, option.text!, option)) + md.use(...createContainer(optionKey, option)) }) // explicitly escape Vue syntax