Skip to content

Commit

Permalink
docs: support dir in meta for pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang committed Dec 17, 2023
1 parent 35a9c1b commit 17e8e7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions packages/docs/.vitepress/theme/components/Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script setup lang="ts">
import { watch } from 'vue'
import { useData } from 'vitepress'
import VPTheme from 'vitepress/theme'
const { frontmatter } = useData()
watch(() => frontmatter.value.dir, (dir = 'ltr') => {
if (typeof document === 'undefined') { return }
document.documentElement.dir = dir
document.body.dir = dir
document.body.style.direction = dir
}, { immediate: true })
</script>

<template>
<VPTheme.Layout />
</template>
3 changes: 2 additions & 1 deletion packages/docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import AsideSponsors from './components/AsideSponsors.vue'
import TranslationStatus from './components/TranslationStatus.vue'
import './styles/vars.css'
import './styles/sponsors.css'
import Layout from './components/Layout.vue'
import VueSchoolLink from './components/VueSchoolLink.vue'
import VueMasteryLogoLink from './components/VueMasteryLogoLink.vue'

const theme: Theme = {
...DefaultTheme,
Layout() {
return h(DefaultTheme.Layout, null, {
return h(Layout, null, {
// 'home-features-after': () => h(HomeSponsors),
'aside-ads-before': () => h(AsideSponsors),
'doc-before': () => h(TranslationStatus),
Expand Down

0 comments on commit 17e8e7f

Please sign in to comment.