Vuepress Template screenshot

Vuepress Template

Author Avatar Theme by Drylint
Updated: 11 May 2021
13 Stars

基于 vuepress 创建的模板,用于快速创建自己的技术博客,学习笔记,或者自己写的某个库的文档。

Categories

Overview

The VuePress Template is a template created using VuePress, a minimalistic static site generator, which allows for quickly creating technology blogs, study notes, or documentation for libraries. This template automates the creation of navigation bars and sidebars based on the organization of files and directories. It also includes configurations for eslint, markdownlint, stylelint, and other code quality and style checking tools. By using this template, users can focus on writing content without having to manually update navigation and sidebar configurations every time a file or directory is added, modified, or deleted.

VuePress consists of two main parts: a Vue-powered theme system and plugin API, and a default theme optimized for writing technical documentation. It generates pre-rendered HTML for each page, resulting in excellent loading performance and search engine optimization (SEO). Once a page is loaded, Vue takes over and converts the static content into a complete single-page application (SPA), with other pages being loaded on demand as the user browses.

To start using the VuePress Template, users can delete all files and directories under the “docs” directory, except for the “.vuepress” directory. They can then create a new README.md file in the “docs” directory and write content in it, which will serve as the homepage. By running the command “npm run serve” in the terminal, users will be able to access the homepage through a provided URL (usually http://localhost:8080/).

To customize the website’s title, logo, and other information, users can modify the configuration file “docs/.vuepress/config.js” according to the instructions in the VuePress documentation.

The template follows the VuePress conventions and configurations. All documents should be placed in the “docs/” directory, and any README.md or index.md file in each subdirectory will be automatically compiled into index.html, with the corresponding link being treated as the root ("/"). It is recommended not to have both README.md and index.md files in the same directory. Files or directories that should not generate navigation or sidebar items should be named with either “_” or “.” as the prefix, but they can still be accessed through their corresponding URLs. Files or directories that should not be packaged as pages and are not accessible through URLs can be placed in the “temp” directory under the root, typically used for drafts or unfinished articles.

A utility file “docs/.vuepress/utils/NavAndSidebar.js” is included in the template that automatically generates a navigation bar and sidebar based on the file and directory structure under “docs”. Articles or pages that should not be included in the navigation bar or sidebar should be named with either “_” or “.” as the prefix. If a directory contains a README.md or index.md file, the directory name will be displayed as a link in the navigation bar. Clicking on this link will display the pages within this directory as the sidebar content. Otherwise, navigation bar configurations will be recursively generated. However, the nesting depth of the navigation bar should not exceed 3 levels to avoid errors.

The template also includes configurations for code quality and style checking tools such as eslint, markdownlint, and stylelint. To have real-time error prompts, it is recommended to install the corresponding VS Code extensions for eslint, markdownlint, and stylelint. These recommended extensions are included in the shared configuration file “.vscode/extensions.json” in the repository. When opening the project in VS Code, a pop-up should appear if the extensions are not installed, asking if the user wants to install them.

Features

  • Automatically generates navigation bar and sidebar based on file and directory structure
  • Configurations for eslint, markdownlint, and stylelint for code quality and style checking
  • Optimized for search engine optimization (SEO) and loading performance
  • Easy customization of website title, logo, and other information
  • Conforms to VuePress conventions and configurations
  • Allows for excluding files and directories from navigation and sidebar
  • Supports nesting of navigation bar up to 3 levels
  • Includes recommended VS Code extensions for eslint, markdownlint, and stylelint

Installation

To begin using the VuePress Template, follow these steps:

  1. Delete all files and directories under the “docs” directory, except for the “.vuepress” directory.
  2. Create a new README.md file in the “docs” directory.
  3. Customize the content of the README.md file as desired. This file will serve as the homepage.
  4. Open the terminal and run the command npm run serve.
  5. Wait for the terminal to display a URL, usually http://localhost:8080/.
  6. Open a web browser and click on the URL while holding the Ctrl key to access the homepage.
  7. Modify the website’s title, logo, and other information by editing the “docs/.vuepress/config.js” file.
  8. Install the recommended VS Code extensions for eslint, markdownlint, and stylelint to enable real-time error prompts during writing.

Summary

The VuePress Template is a useful tool for quickly creating technology blogs, study notes, or library documentation. It automates the generation of navigation bars and sidebars based on the file and directory structure, while also providing configurations for code quality and style checking tools. With pre-rendered HTML and performance optimization, it offers excellent loading performance and search engine optimization. The template follows VuePress conventions and allows for customization of the website’s appearance and structure. Overall, the VuePress Template simplifies the process of creating and maintaining a technical blog or documentation.