Skip to content

Commit

Permalink
feat(default-theme): support customLayout: true in frontmatter
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
yyx990803 committed Dec 5, 2020
1 parent 8dea518 commit f32771f
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 383 deletions.
1 change: 0 additions & 1 deletion docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function getConfigSidebar() {
{
text: 'Theme Config',
children: [
{ text: 'Homepage', link: '/config/homepage' },
{ text: 'Algolia Search', link: '/config/algolia-search' },
{ text: 'Carbon Ads', link: '/config/carbon-ads' }
]
Expand Down
23 changes: 0 additions & 23 deletions docs/config/homepage.md

This file was deleted.

20 changes: 4 additions & 16 deletions src/client/theme-default/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,7 @@
<!-- TODO: make this button accessible -->
<div class="sidebar-mask" @click="toggleSidebar(false)" />

<Home v-if="enableHome">
<template #hero>
<slot name="home-hero" />
</template>
<template #features>
<slot name="home-features" />
</template>
<template #footer>
<slot name="home-footer" />
</template>
</Home>

<Content v-if="isCustomLayout"/>
<Page v-else>
<template #top>
<slot name="page-top-ads">
Expand Down Expand Up @@ -72,7 +61,6 @@ import type { DefaultTheme } from './config'
// components
import NavBar from './components/NavBar.vue'
import Home from './components/Home.vue'
import SideBar from './components/SideBar.vue'
import Page from './components/Page.vue'
const CarbonAds = defineAsyncComponent(
Expand All @@ -92,8 +80,8 @@ const siteRouteData = useSiteDataByRoute()
const theme = computed(() => siteData.value.themeConfig)
const page = usePageData()
// home
const enableHome = computed(() => !!route.data.frontmatter.home)
// custom layout
const isCustomLayout = computed(() => !!route.data.frontmatter.customLayout)
// navbar
const showNavbar = computed(() => {
Expand All @@ -117,7 +105,7 @@ const showSidebar = computed(() => {
const { frontmatter } = route.data
const { themeConfig } = siteRouteData.value
return (
!frontmatter.home &&
!frontmatter.customLayout &&
frontmatter.sidebar !== false &&
((typeof themeConfig.sidebar === 'object' &&
Object.keys(themeConfig.sidebar).length != 0) ||
Expand Down
22 changes: 0 additions & 22 deletions src/client/theme-default/components/Home.vue

This file was deleted.

134 changes: 0 additions & 134 deletions src/client/theme-default/components/HomeFeatures.vue

This file was deleted.

44 changes: 0 additions & 44 deletions src/client/theme-default/components/HomeFooter.vue

This file was deleted.

Loading

1 comment on commit f32771f

@vercel
Copy link

@vercel vercel bot commented on f32771f Dec 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.