diff --git a/src/client/app/components/Content.ts b/src/client/app/components/Content.ts index 4752554e..9e8b0921 100644 --- a/src/client/app/components/Content.ts +++ b/src/client/app/components/Content.ts @@ -1,5 +1,5 @@ import { defineComponent, h } from 'vue' -import { useRoute } from '../router' +import { useData, useRoute } from 'vitepress' import { contentUpdatedCallbacks } from '../utils' const runCbs = () => contentUpdatedCallbacks.forEach((fn) => fn()) @@ -11,14 +11,19 @@ export const Content = defineComponent({ }, setup(props) { const route = useRoute() + const { site } = useData() return () => - h(props.as, { style: { position: 'relative' } }, [ - route.component - ? h(route.component, { - onVnodeMounted: runCbs, - onVnodeUpdated: runCbs - }) - : '404 Page Not Found' - ]) + h( + props.as, + site.value.contentProps ?? { style: { position: 'relative' } }, + [ + route.component + ? h(route.component, { + onVnodeMounted: runCbs, + onVnodeUpdated: runCbs + }) + : '404 Page Not Found' + ] + ) } }) diff --git a/src/node/config.ts b/src/node/config.ts index b39250cd..a6591adf 100644 --- a/src/node/config.ts +++ b/src/node/config.ts @@ -235,7 +235,8 @@ export async function resolveSiteData( themeConfig: userConfig.themeConfig || {}, locales: userConfig.locales || {}, scrollOffset: userConfig.scrollOffset ?? 90, - cleanUrls: !!userConfig.cleanUrls + cleanUrls: !!userConfig.cleanUrls, + contentProps: userConfig.contentProps } } diff --git a/src/node/siteConfig.ts b/src/node/siteConfig.ts index c2f58d76..ae6d976f 100644 --- a/src/node/siteConfig.ts +++ b/src/node/siteConfig.ts @@ -70,6 +70,7 @@ export interface UserConfig appearance?: boolean | 'dark' lastUpdated?: boolean + contentProps?: Record /** * MarkdownIt options diff --git a/types/shared.d.ts b/types/shared.d.ts index 6a3fb916..3cb48065 100644 --- a/types/shared.d.ts +++ b/types/shared.d.ts @@ -60,6 +60,7 @@ export interface SiteData { scrollOffset: number | string | string[] locales: LocaleConfig localeIndex?: string + contentProps?: Record } export type HeadConfig =