Vuepress 快速搭建博客--一款你值得擁有的博客主題

速覽

  • 這是一款 Vuepress 主題,集成了博客所需的分類、TAG墻、分頁、評論等功能。
  • 主題追求極簡,配置上手簡單,適配移動端。
  • 預(yù)覽地址
  • GitHub地址
  • 博客效果展示:
image

主題使用

安裝主題

創(chuàng)建一個新的項目 my-blog:

mkdir my-blog
cd my-blog

初始化 yarn 或 npm :

yarn init  或 npm init -y

安裝 vuepress 和 vuepress-theme-melodydl:

yarn add vuepress vuepress-theme-melodydl
或
npm install vuepress vuepress-theme-melodydl

創(chuàng)建 src/_posts 文件夾和 Vuepress 配置文件,項目結(jié)構(gòu)大致為:

my-blog
├── src # Blog 源文件目錄
│   ├── .vuepress # Vuepress 目錄
│   │   └── public # Vuepress 靜態(tài)資源文件
│   │   └── config.js # Vuepress 配置文件
│   └── about # About 頁面 文件夾
│   │   ├── index.md  # about 頁面內(nèi)容文件
│   └── _posts # 博客文件夾
│       ├── xxx.md
│       ...
└── package.json

在 package.json 加入 script 字段:

{
  "scripts": {
    "dev": "vuepress dev src",
    "build": "vuepress build src"
  }
}

配置主題

在 src/.vuepress/config.js 中配置 Vuepress 和主題:


    module.exports = {
        // 網(wǎng)站 Title
          title: 'Top 的博客 | Top Blog',
          
          // 網(wǎng)站描述
          description: '個人博客',
          
          // 網(wǎng)站 favicon 圖標(biāo)設(shè)置等
          head: [
            ['link', { rel: 'icon', href: '/favicon.ico' }],
            ['meta', { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no' }]
          ],
          
          // 使用的主題
          theme: 'melodydl',
          
          // 主題配置
          themeConfig: {
            title: 'Top Blog',

        // 個人信息(沒有或不想設(shè)置的,刪掉對應(yīng)字段即可)
        personalInfo: {
        
        // 名稱
          name: 'melodydl',
          
          // 頭像 public文件夾下
          avatar: '/avatar-top.jpeg',
          
          // 頭部背景圖
          headerBackgroundImg: '/avatar-bg.jpeg',
          
          // 個人簡介 (支持 HTML)
          description: 'In me the tiger sniffs the rose<br/>心有猛虎,細(xì)嗅薔薇',
          
           // 電子郵箱
          email: 'facecode@foxmail.com',
          
          // 所在地
          location: 'Shanghai, China'
        },
        // 頂部導(dǎo)航欄內(nèi)容
        nav: [ 
          {text: 'HOME', link: '/' },
          {text: 'ABOUT', link: '/about/'},
          {text: 'TAGS', link: '/tags/'}      
        ],
        
        // 首頁頭部標(biāo)題背景圖設(shè)置,圖片直接放在 public 文件夾下
        header: {
          home: {
            title: 'Top Blog', 
            subtitle: '好好生活,慢慢相遇', 
            headerImage: '/home-bg.jpeg'
          },
          
          // tag頁面頭部標(biāo)題背景圖設(shè)置,圖片直接放在 public 文件夾下
          tags: {
            title: 'Tags', 
            subtitle: '遇見你花光了我所有的運(yùn)氣', 
            headerImage: '/tags-bg.jpg'
          },
          
          // 文章詳情頭部背景圖
          postHeaderImg: '/post-bg.jpeg',
        },
        
        // 社交平臺帳號信息 
        sns: {
          csdn: { 
            account: 'csdn', 
            link: 'https://blog.csdn.net/weixin_44002432', 
          },
          weibo: { 
            account: 'weibo', 
            link: 'https://weibo.com/u/5656925978', 
          },
          juejin: { 
            account: 'juejin',
            link: 'https://juejin.im/user/5ce784a0f265da1b8333673c'
          },
          zhihu: { 
            account: 'zhihu',
            link: 'https://www.zhihu.com/people/sheng-tang-de-xing-kong'
          },
          github: { 
            account: 'github',
            link: 'https://github.com/youdeliang'
          }
        },
        // 底部 footer 的相關(guān)設(shè)置 
        footer: {
          // gitbutton  配置
          gitbtn: {
            // 倉庫地址
            repository: "https://ghbtns.com/github-btn.html?user=youdeliang&repo=vuepress-theme-top&type=star&count=true",
            frameborder: 0,
            scrolling: 0,
            width: "80px",
            height: "20px"
          },
          
          // 添加自定義 footer
          custom: `Copyright &copy; Top Blog 2020 <br /> 
            Theme By <a  target="_blank">VuePress</a>
            | <a  target="_blank">youdeliang</a>`
        },
        
        // 分頁配置
        pagination: {
          // 每頁文章數(shù)量
          perPage: 5,
        },
        
        // vssue 評論配置, 如果不需要,可以設(shè)置 comments: false
        comments: {    
          owner: 'youdeliang',
          repo: 'vuepress-theme-melodydl',
          clientId: 'dfba8ecad544784fec1f',
          clientSecret: '1358ac11bc8face24f598601991083e27372988d',
          autoCreateIssue: false,
        },
      }
    }

Vssue 評論插件

如果你知道 Gitment 和 Gitalk,那么 Vssue 其實和它們實現(xiàn)的功能沒什么區(qū)別 —— 在 Github 的 Issue 系統(tǒng)中存儲評論,在你的頁面上發(fā)表和展示評論,還可以編輯和刪除評論,提供了 Vuepress 的插件(最初的動力就是給自己的 Vuepress 博客開啟評論)。

Vssue 評論插件使用可以查看文檔手冊。傳送門

about頁面配置

---
layout: about 
title: About
subtitle: 你可以很好,但你無需完美
headerImage: /about-bg.jpg # public 文件夾下的圖片
---

下面為個人信息等內(nèi)容...

創(chuàng)建博文

在 src/_posts 下創(chuàng)建 md 文件

<!-- _posts/2019-04-01-JS異步編程方案總結(jié).md -->
---
title: "JS異步編程方案總結(jié)"
date: 2019-04-01
tags:
  - Promise
  - JavaScript
---

本篇博客主要是對 Javcscript 異步編程方案總結(jié)

more 上面的內(nèi)容是摘要,將顯示在目錄中。

<!-- more -->

more 下面的內(nèi)容只有瀏覽這篇文章時才會完全展示,不會顯示在目錄中。

運(yùn)行相應(yīng) script 生成你的博客網(wǎng)站

# 開發(fā)
npm run dev
# 構(gòu)建
npm run build

使用 GitHub pages 部署

部署具體步驟可以參考 Vuepress 官方文檔。 傳送門

最后

如果覺得主題好用的話,歡迎點贊和 Star,你的鼓勵是對我莫大的支持,謝謝??。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容