Skip to content

Commit

Permalink
feat: support lang attributes (#1948)
Browse files Browse the repository at this point in the history
Co-authored-by: _Kerman <kermanx@qq.com>
  • Loading branch information
ssssota and KermanX authored Nov 30, 2024
1 parent a47b8bc commit 207a000
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/client/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const FRONTMATTER_FIELDS = [
'transition',
'zoom',
'dragPos',
'lang',
]

export const HEADMATTER_FIELDS = [
Expand Down
1 change: 1 addition & 0 deletions packages/client/internals/SlideWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const style = computed<CSSProperties>(() => ({
:data-slidev-no="props.route.no"
:class="getSlideClass(route, ['slide', 'presenter'].includes(props.renderContext) ? '' : 'disable-view-transition')"
:style="style"
:lang="props.route.meta.slide.frontmatter.lang"
>
<SlideBottom />
<component :is="props.route.component" />
Expand Down
3 changes: 3 additions & 0 deletions packages/slidev/node/setups/indexHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export default function setupIndexHtml({ mode, entry, clientRoot, userRoot, root
if (data.config.fonts.webfonts.length && data.config.fonts.provider !== 'none')
head += `\n<link rel="stylesheet" href="${generateGoogleFontsUrl(data.config.fonts)}" type="text/css">`

if (data.headmatter.lang)
main = main.replace('<html lang="en">', `<html lang="${data.headmatter.lang}">`)

main = main
.replace('__ENTRY__', toAtFS(join(clientRoot, 'main.ts')))
.replace('<!-- head -->', head)
Expand Down

0 comments on commit 207a000

Please sign in to comment.