npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ppst-vitepress-theme

v0.0.3

Published

自定义vitepress主题

Downloads

2

Readme

vitepress 自定义主题

可以直接克隆,也可以使用下面方法一步步自定义实现

克隆地址

git clone http://git.ppst.top/pp/ppst-vitepress-theme-demo.git

安装 vitepress

pnpm install vitepress

安装主题

pnpm install ppst-vitepress-theme

安装读取文档插件

pnpm install  markdown-from-posts

目录结构

.vitepress
	theme
		index.ts
		override.css
	config.ts
pages
	default.md
posts
	文件夹/.md文件
	.md文件
public
	favicon.ico
index.md

.vitepress文件夹

config.ts - 配置自定义vitepress导航以及标题等

theme/override.css 重置样式

theme/index.ts

.vitepress/config.ts

const { getPosts } = require('markdown-from-posts')
async function config() {
  return {
    extends: {
      markdown: {
        headers: {
          level: [2, 3]
        }
      },
    },
    themeConfig: {
      posts: await getPosts(),
      title: 'BBBB',
      description: '自定义主题BBBB',
      docRoot: '',
      hasDarkSwitch: true,
      homeConfig: {
        headline: 'BBBB大标题',//大标题
        headlineHeight: 'BBBB高亮',//大标题高亮
        subheading: 'BBBB小标题',//小标题
        subheadingHeight: '小标题高亮',//小标题高亮
        description: '自定义主题,简短banner描述',//描述
      },

      nav: [
        { text: '首页', link: '/', icon: '' },
        { text: '归档', link: '/pages/archives', icon: '' },
        { text: '默认', link: '/pages/default', icon: '' },
        { text: '分类', link: '/pages/category', icon: '' },
        { text: '搜索', link: '/pages/search', icon: '' },
      ],
      footer: {
        copyright: '湘ICP备aaaaaaaa-1'
      }
    }
  }
}
module.exports = config()

.vitepress/theme/override.css 样式

:root {
  --c-main-color:#80adff;/* 主色调 */
}

.vitepress/theme/index.ts 【vitepress 引入主题】

import { CustomTheme } from 'ppst-vitepress-theme'

import './override.css'

export default {
  ...CustomTheme,
}

pages文件夹

配置二级目录页面(可自定义布局页面),

默认有

  • category.md【分类页面】
  • default.md 【默认页面】
  • default.md 【搜索页面】
  • archives.md 【归档页面】

如果需要自定义布局请定义组件并在.vitepress/theme/index.ts引用

在pages下页面中使用组件即可

posts 文件夹 【所有文档】

文档顶部:

---
title: default
date: 2018-09-14 13:57:02
category: default
tags:
  - default
---
  • title 为文档标题

  • date 创建时间

  • category 分类

  • tags 标签

public文件夹

  • favicon.ico 网站图标

  • img文件 公共图片文件夹

index.html文件

首页配置

---
page: true
date: 2021-06-30
title: 自定义标题
sidebar: false
---
<script setup>
</script>
<Home>

<template #banner>
<img src="/img/page.png" /> 
</template>

<template #description>
<!-- 一些其他描述 -->
</template>

  
</Home>

package.json

{
  "name": "demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "vitepress dev  --host 0.0.0.0",
    "build": "vitepress build "
  },
  "dependencies": {
    "@types/node": "^18.15.11",
    "markdown-from-posts": "^1.0.5",
    "vitepress": "1.0.0-alpha.64",
    "ppst-vitepress-theme": "^0.0.2"
  }
}