vitepress系列-02-设置自定义的首页

设置自定义的首页

初始首页效果:

image-20240402145301023

设置成自己的首页,更改config.mtsdocs/index.md文件:

image-20240402150335526

设置版权

export default defineConfig({
  lang: 'en-US',
  title: "东东爱编码的技术博客",
  description: "记录日常学习点点滴滴",
  themeConfig: {
    nav: navConfig,
    footer: {
      message: 'Released under the MIT License.',
      copyright: 'Copyright © 2021-present eastern'
    }
  }
})

改完效果:

image-20240402152516654

进阶版设置首页

设置:

官网的描述如下:参考地址

image-20240403082327370

步骤:

  • docs下新建theme/index.ts文件

    import DefaultTheme from "vitepress/theme";
    // @ts-ignore
    import Home from './Home.vue'
    
    export default {
        extends: DefaultTheme,
        enhanceApp({ app }) {
            app.component('customHome', Home)
        }
    }
    
  • docs下新建theme/Home.vue文件

    <template>
      <div class="home-container">
    
    
      </div>
    </template>
    
    <script>
    export default {
      name: "Home"
    }
    </script>
    
    <style scoped lang="less">
      .home-container {
        background: url("../../public/bg.png") no-repeat;
        background-size: 100% 100%;
        height: calc(100vh - 178px)
      }
    </style>
    

    注意:

    其中bg.png就是显示的背景图片

  • 将自定义的首页,设置到布局中,在根目录下docs/index.md中将layoyut: home改成layout: customeHome

    注意:

    其中customeHome就是上面app.component('customHome', Home)这边注册的名字

效果:

image-20240403081909570

之后,就可以自己想怎么设计首页就怎么设计吧!

不要妄图图改它的全局样式,会炸!!!

相关推荐

  1. 建博客之旅03之vuepress和Vitepress

    2024-04-08 19:56:03       42 阅读
  2. RestTemplate定义设置

    2024-04-08 19:56:03       51 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-08 19:56:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-08 19:56:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-08 19:56:03       82 阅读
  4. Python语言-面向对象

    2024-04-08 19:56:03       91 阅读

热门阅读

  1. jquery

    2024-04-08 19:56:03       34 阅读
  2. js中filter,map,forEach,indexOf的用法和区别详解

    2024-04-08 19:56:03       38 阅读
  3. 网络安全教程及案例分析

    2024-04-08 19:56:03       37 阅读
  4. 前端开发语言都有哪些?

    2024-04-08 19:56:03       38 阅读
  5. 防抖和节流

    2024-04-08 19:56:03       32 阅读
  6. LeetCode 494. 目标和

    2024-04-08 19:56:03       32 阅读
  7. 【LeetCode热题100】【技巧】颜色分类

    2024-04-08 19:56:03       35 阅读
  8. Shell学习 - 2.24 Shell let命令:对整数进行数学运算

    2024-04-08 19:56:03       34 阅读
  9. 【备忘录】Linux kill 多个进程命令备忘

    2024-04-08 19:56:03       32 阅读
  10. 实现窗口拖拽移动

    2024-04-08 19:56:03       32 阅读