Skip to content

Commit f32771f

Browse files
committed
feat(default-theme): support customLayout: true in frontmatter
BREAKING CHANGE: the `home` frontmatter option has been removed. Instead, use `customLayout: true` and custom HTML + `<style>` in the markdown file to customize the home page (or any other page).
1 parent 8dea518 commit f32771f

File tree

7 files changed

+4
-383
lines changed

7 files changed

+4
-383
lines changed

docs/.vitepress/config.js

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ function getConfigSidebar() {
7272
{
7373
text: 'Theme Config',
7474
children: [
75-
{ text: 'Homepage', link: '/config/homepage' },
7675
{ text: 'Algolia Search', link: '/config/algolia-search' },
7776
{ text: 'Carbon Ads', link: '/config/carbon-ads' }
7877
]

docs/config/homepage.md

-23
This file was deleted.

src/client/theme-default/Layout.vue

+4-16
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,7 @@
1919
<!-- TODO: make this button accessible -->
2020
<div class="sidebar-mask" @click="toggleSidebar(false)" />
2121

22-
<Home v-if="enableHome">
23-
<template #hero>
24-
<slot name="home-hero" />
25-
</template>
26-
<template #features>
27-
<slot name="home-features" />
28-
</template>
29-
<template #footer>
30-
<slot name="home-footer" />
31-
</template>
32-
</Home>
33-
22+
<Content v-if="isCustomLayout"/>
3423
<Page v-else>
3524
<template #top>
3625
<slot name="page-top-ads">
@@ -72,7 +61,6 @@ import type { DefaultTheme } from './config'
7261
7362
// components
7463
import NavBar from './components/NavBar.vue'
75-
import Home from './components/Home.vue'
7664
import SideBar from './components/SideBar.vue'
7765
import Page from './components/Page.vue'
7866
const CarbonAds = defineAsyncComponent(
@@ -92,8 +80,8 @@ const siteRouteData = useSiteDataByRoute()
9280
const theme = computed(() => siteData.value.themeConfig)
9381
const page = usePageData()
9482
95-
// home
96-
const enableHome = computed(() => !!route.data.frontmatter.home)
83+
// custom layout
84+
const isCustomLayout = computed(() => !!route.data.frontmatter.customLayout)
9785
9886
// navbar
9987
const showNavbar = computed(() => {
@@ -117,7 +105,7 @@ const showSidebar = computed(() => {
117105
const { frontmatter } = route.data
118106
const { themeConfig } = siteRouteData.value
119107
return (
120-
!frontmatter.home &&
108+
!frontmatter.customLayout &&
121109
frontmatter.sidebar !== false &&
122110
((typeof themeConfig.sidebar === 'object' &&
123111
Object.keys(themeConfig.sidebar).length != 0) ||

src/client/theme-default/components/Home.vue

-22
This file was deleted.

src/client/theme-default/components/HomeFeatures.vue

-134
This file was deleted.

src/client/theme-default/components/HomeFooter.vue

-44
This file was deleted.

0 commit comments

Comments
 (0)