mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
4.6 KiB
196 lines
4.6 KiB
2 years ago
|
# Home Page
|
||
3 years ago
|
|
||
2 years ago
|
VitePress default theme provides a homepage layout, which you can also see used on [the homepage of this site](../). You may use it on any of your pages by specifying `layout: home` in the [frontmatter](./frontmatter-config).
|
||
3 years ago
|
|
||
|
```yaml
|
||
|
---
|
||
|
layout: home
|
||
|
---
|
||
|
```
|
||
|
|
||
2 years ago
|
However, this option alone wouldn't do much. You can add several different pre templated "sections" to the homepage by setting additional other options such as `hero` and `features`.
|
||
3 years ago
|
|
||
|
## Hero Section
|
||
|
|
||
|
The Hero section comes at the top of the homepage. Here's how you can configure the Hero section.
|
||
|
|
||
|
```yaml
|
||
|
---
|
||
|
layout: home
|
||
|
|
||
|
hero:
|
||
2 years ago
|
name: VitePress
|
||
3 years ago
|
text: Vite & Vue powered static site generator.
|
||
|
tagline: Lorem ipsum...
|
||
2 years ago
|
image:
|
||
|
src: /logo.png
|
||
|
alt: VitePress
|
||
3 years ago
|
actions:
|
||
|
- theme: brand
|
||
|
text: Get Started
|
||
|
link: /guide/what-is-vitepress
|
||
|
- theme: alt
|
||
|
text: View on GitHub
|
||
|
link: https://github.com/vuejs/vitepress
|
||
|
---
|
||
|
```
|
||
|
|
||
|
```ts
|
||
|
interface Hero {
|
||
|
// The string shown top of `text`. Comes with brand color
|
||
|
// and expected to be short, such as product name.
|
||
|
name?: string
|
||
|
|
||
|
// The main text for the hero section. This will be defined
|
||
|
// as `h1` tag.
|
||
|
text: string
|
||
|
|
||
|
// Tagline displayed below `text`.
|
||
|
tagline?: string
|
||
|
|
||
2 years ago
|
// The image is displayed next to the text and tagline area.
|
||
|
image?: ThemeableImage
|
||
|
|
||
3 years ago
|
// Action buttons to display in home hero section.
|
||
|
actions?: HeroAction[]
|
||
|
}
|
||
|
|
||
2 years ago
|
type ThemeableImage =
|
||
|
| string
|
||
|
| { src: string; alt?: string }
|
||
|
| { light: string; dark: string; alt?: string }
|
||
|
|
||
3 years ago
|
interface HeroAction {
|
||
|
// Color theme of the button. Defaults to `brand`.
|
||
|
theme?: 'brand' | 'alt'
|
||
|
|
||
|
// Label of the button.
|
||
|
text: string
|
||
|
|
||
|
// Destination link of the button.
|
||
|
link: string
|
||
10 months ago
|
|
||
|
// Link target attribute.
|
||
|
target?: string
|
||
|
|
||
|
// Link rel attribute.
|
||
|
rel?: string
|
||
3 years ago
|
}
|
||
|
```
|
||
|
|
||
|
### Customizing the name color
|
||
|
|
||
1 year ago
|
VitePress uses the brand color (`--vp-c-brand-1`) for the `name`. However, you may customize this color by overriding `--vp-home-hero-name-color` variable.
|
||
3 years ago
|
|
||
|
```css
|
||
|
:root {
|
||
|
--vp-home-hero-name-color: blue;
|
||
|
}
|
||
|
```
|
||
|
|
||
|
Also you may customize it further by combining `--vp-home-hero-name-background` to give the `name` gradient color.
|
||
|
|
||
|
```css
|
||
|
:root {
|
||
|
--vp-home-hero-name-color: transparent;
|
||
|
--vp-home-hero-name-background: -webkit-linear-gradient(120deg, #bd34fe, #41d1ff);
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## Features Section
|
||
|
|
||
2 years ago
|
In Features section, you can list any number of features you would like to show right after the Hero section. To configure it, pass `features` option to the frontmatter.
|
||
3 years ago
|
|
||
2 years ago
|
You can provide an icon for each feature, which can be an emoji or any type of image. When the configured icon is an image (svg, png, jpeg...), you must provide the icon with the proper width and height; you can also provide the description, its intrinsic size as well as its variants for dark and light theme when required.
|
||
|
|
||
3 years ago
|
```yaml
|
||
|
---
|
||
|
layout: home
|
||
|
|
||
|
features:
|
||
|
- icon: 🛠️
|
||
|
title: Simple and minimal, always
|
||
|
details: Lorem ipsum...
|
||
2 years ago
|
- icon:
|
||
|
src: /cool-feature-icon.svg
|
||
|
title: Another cool feature
|
||
|
details: Lorem ipsum...
|
||
|
- icon:
|
||
|
dark: /dark-feature-icon.svg
|
||
|
light: /light-feature-icon.svg
|
||
|
title: Another cool feature
|
||
|
details: Lorem ipsum...
|
||
3 years ago
|
---
|
||
|
```
|
||
|
|
||
|
```ts
|
||
|
interface Feature {
|
||
2 years ago
|
// Show icon on each feature box.
|
||
|
icon?: FeatureIcon
|
||
3 years ago
|
|
||
|
// Title of the feature.
|
||
|
title: string
|
||
|
|
||
|
// Details of the feature.
|
||
|
details: string
|
||
2 years ago
|
|
||
|
// Link when clicked on feature component. The link can
|
||
|
// be both internal or external.
|
||
|
//
|
||
11 months ago
|
// e.g. `guide/reference/default-theme-home-page` or `https://example.com`
|
||
2 years ago
|
link?: string
|
||
|
|
||
|
// Link text to be shown inside feature component. Best
|
||
|
// used with `link` option.
|
||
|
//
|
||
|
// e.g. `Learn more`, `Visit page`, etc.
|
||
|
linkText?: string
|
||
1 year ago
|
|
||
|
// Link rel attribute for the `link` option.
|
||
|
//
|
||
|
// e.g. `external`
|
||
|
rel?: string
|
||
10 months ago
|
|
||
|
// Link target attribute for the `link` option.
|
||
|
target?: string
|
||
3 years ago
|
}
|
||
2 years ago
|
|
||
|
type FeatureIcon =
|
||
|
| string
|
||
|
| { src: string; alt?: string; width?: string; height: string }
|
||
|
| {
|
||
|
light: string
|
||
|
dark: string
|
||
|
alt?: string
|
||
|
width?: string
|
||
|
height: string
|
||
|
}
|
||
3 years ago
|
```
|
||
9 months ago
|
|
||
|
## Markdown Content
|
||
|
|
||
|
You can add additional content to your site's homepage just by adding Markdown below the `---` frontmatter divider.
|
||
|
|
||
|
````md
|
||
|
---
|
||
|
layout: home
|
||
|
|
||
|
hero:
|
||
|
name: VitePress
|
||
|
text: Vite & Vue powered static site generator.
|
||
|
---
|
||
|
|
||
|
## Getting Started
|
||
|
|
||
|
You can get started using VitePress right away using `npx`!
|
||
|
|
||
|
```sh
|
||
|
npm init
|
||
|
npx vitepress init
|
||
|
```
|
||
|
````
|
||
|
|
||
|
::: info
|
||
|
VitePress didn't always auto-style the extra content of the `layout: home` page. To revert to older behavior, you can add `markdownStyles: false` to the frontmatter.
|
||
|
:::
|