【保姆级教程】vitepress内容详解(1)

config.mts内容详解

打开config.mts文件


文件内容详细解释:

import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
  title: "My Awesome Project",//目录名称 网址标题
  description: "A VitePress Site",//描述
  themeConfig: {//主题配置
    // https://vitepress.dev/reference/default-theme-config
    nav: [//导航栏
      { text: 'Home', link: '/' },
      { text: 'Examples', link: '/markdown-examples' }
    ],

    sidebar: [//侧边栏
      {
        text: 'Examples',
        items: [
          { text: 'Markdown Examples', link: '/markdown-examples' },
          { text: 'Runtime API Examples', link: '/api-examples' }
        ]
      }
    ],

    socialLinks: [//友联
      { icon: 'github', link: 'https://github.com/vuejs/vitepress' }
    ]
  }
})

布局

VitePress 的布局整体可以分为 4 种,分别为:doc page home 和 没有任何默认布局(空白页面)
VitePress 默认主题提供了一个首页布局,也可以在此站点首页看到。可以通过 frontmatter 指定 layout: home 在任何页面上使用它


需要注意的是,下面的语法一定要写在 md 文档的头部才会生效
---
layout: doc | page | home
---
home效果:

doc效果:

page效果:

Hero 部分详解


hero:
  // `text` 上方的字符,带有品牌颜色
  // 预计简短,例如产品名称
  name: "My Awesome Project"
   // hero 部分的主要文字,
  // 被定义为 `h1` 标签
  text: "A VitePress Site"
  // `text` 下方的标语
  tagline: My great project tagline
  // text 和 tagline 区域旁的图片
  image?: ThemeableImage
   // 主页 hero 部分的操作按钮
  actions:
    - theme: brand
      text: Markdown Examples
      link: /markdown-examples
    - theme: alt
      text: API Examples
      link: /api-examples
//功能区
features:
  - title: Feature A
    details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
  - title: Feature B
    details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
  - title: Feature C
    details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
ThemeableImage =
  | string
  | { src: string; alt?: string }
  | { light: string; dark: string; alt?: string }

HeroAction {
  // 按钮的颜色主题,默认为 `brand`
  theme: 'brand' | 'alt'
  // 按钮的标签
  text: string

  // 按钮的目标链接
  link: string
  // 链接的 target 属性
  target: string
  // 链接的 rel 属性
  rel: string
}

您好,我是肥晨。
欢迎关注我获取前端学习资源,日常分享技术变革,生存法则;行业内幕,洞察先机。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奶糖 肥晨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值