From 69c44aa607470b8b55b8ef506bf2499f13a69b92 Mon Sep 17 00:00:00 2001 From: Kia King Ishii Date: Fri, 20 May 2022 03:17:57 +0900 Subject: [PATCH] feat: add layout option and home hero section --- docs/.vitepress/config.ts | 6 +- docs/config/frontmatter-configs.md | 89 +++++++++++++++ docs/config/introduction.md | 3 + docs/index.md | 9 +- .../theme-default/components/VPContent.vue | 17 ++- .../{VPContentDoc.vue => VPDoc.vue} | 26 ++--- ...VPContentDocFooter.vue => VPDocFooter.vue} | 5 +- ...ContentDocOutline.vue => VPDocOutline.vue} | 4 +- .../theme-default/components/VPHome.vue | 9 ++ .../theme-default/components/VPHomeHero.vue | 106 ++++++++++++++++++ .../components/VPNavBarTitle.vue | 39 ++++--- .../theme-default/components/VPPage.vue | 5 + src/client/theme-default/styles/base.css | 3 + src/client/theme-default/styles/vars.css | 19 ++++ src/client/theme-default/styles/vp-doc.css | 6 + 15 files changed, 310 insertions(+), 36 deletions(-) create mode 100644 docs/config/frontmatter-configs.md create mode 100644 docs/config/introduction.md rename src/client/theme-default/components/{VPContentDoc.vue => VPDoc.vue} (84%) rename src/client/theme-default/components/{VPContentDocFooter.vue => VPDocFooter.vue} (96%) rename src/client/theme-default/components/{VPContentDocOutline.vue => VPDocOutline.vue} (96%) create mode 100644 src/client/theme-default/components/VPHome.vue create mode 100644 src/client/theme-default/components/VPHomeHero.vue create mode 100644 src/client/theme-default/components/VPPage.vue diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 19c7e415..99175da7 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -18,7 +18,7 @@ export default defineConfig({ sidebar: { '/guide/': getGuideSidebar(), '/config/': getConfigSidebar(), - '/': getGuideSidebar() + // '/': getGuideSidebar() }, editLink: { @@ -54,8 +54,10 @@ function getConfigSidebar() { { text: 'Config', items: [ + { text: 'Introduction', link: '/config/introduction' }, { text: 'App Configs', link: '/config/app-configs' }, - { text: 'Theme Configs', link: '/config/theme-configs' } + { text: 'Theme Configs', link: '/config/theme-configs' }, + { text: 'Frontmatter Configs', link: '/config/frontmatter-configs' } ] } ] diff --git a/docs/config/frontmatter-configs.md b/docs/config/frontmatter-configs.md new file mode 100644 index 00000000..1419f9e0 --- /dev/null +++ b/docs/config/frontmatter-configs.md @@ -0,0 +1,89 @@ +# Frontmatter Configs + +Frontmatter enables page based configuration. On every markdown, you’re free to add Any settings to override any global app or theme configs. Also, there are configs which you can only define in Frontmatter. + +```yaml +--- +title: Docs with VitePress +editLink: true +--- +``` + +You may access frontmatter by `$frontmatter` helper inside any markdown file. + +```md +{{ $frontmatter.title }} +``` + +## title + +- Type: `string` + +Title for the page. It's same as [config.title](../config/app-configs#title), and it overrides the app config. + +```yaml +--- +title: VitePress +--- +``` + +## description + +- Type: `string` + +Title for the page. It's same as [config.description](../config/app-configs#description), and it overrides the app config. + +```yaml +--- +description: VitePress +--- +``` + +## layout + +- Type: `doc | home | page` +- Default: `doc` + +Determines the layout of the page. + +- `doc` - It applies default documentation styles to the markdown content. +- `home` - Special layout for "Home Page". You may add extra options such as `hero` and `features` to rappidly create beautiful landing page. +- `page` - Behave similar to `doc` but it aplies no styles to the content. Useful when you want to create a fully custom page. + +```yaml +--- +type: doc +--- +``` + +## hero + +- Type: `Hero` + +This option only take effect when `layout` is set to `home`. + +It defines contents of home hero section. + +```yaml +--- +layout: home + +hero: + name: VuePress + text: Vite & Vue powered static site generator. + tagline: Lorem ipsum... +--- +``` + +```ts +interface Hero { + // The string shown top of `text`. Best used for product name. + name: string + + // The main text for the hero section. This will be defined as `h1`. + text: string + + // Tagline displayed below `text`. + tagline: string +} +``` diff --git a/docs/config/introduction.md b/docs/config/introduction.md new file mode 100644 index 00000000..da6c6b02 --- /dev/null +++ b/docs/config/introduction.md @@ -0,0 +1,3 @@ +# Introduction + +Here we plan to describe all about configurations. What the difference between app config and theme config, how to access them within markdown or in Vue Component and such. diff --git a/docs/index.md b/docs/index.md index 5039610d..e8122241 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,8 @@ -# Home Page +--- +layout: home -Coming soon... +hero: + name: VuePress + text: Vite & Vue powered static site generator. + tagline: Simple, minimal, yet powerful as lightning. Meet the modern SSG framework you've always wanted. +--- diff --git a/src/client/theme-default/components/VPContent.vue b/src/client/theme-default/components/VPContent.vue index d18af788..388f0415 100644 --- a/src/client/theme-default/components/VPContent.vue +++ b/src/client/theme-default/components/VPContent.vue @@ -1,10 +1,13 @@ @@ -15,11 +18,18 @@ const { hasSidebar } = useSidebar() :class="{ 'has-sidebar': hasSidebar }" > + + diff --git a/src/client/theme-default/components/VPNavBarTitle.vue b/src/client/theme-default/components/VPNavBarTitle.vue index 1d4a8b6d..39941386 100644 --- a/src/client/theme-default/components/VPNavBarTitle.vue +++ b/src/client/theme-default/components/VPNavBarTitle.vue @@ -1,39 +1,52 @@