从零开始写一个vuepress插件

初始化插件项目

  1. 在任意目录新建一个插件目录,我这里在 /pkg/vuepress-plugin-simple-encrypt

    mkdir /pkg/vuepress-plugin-simple-encrypt
    
    image-20220424215029271
    image-20220424215029271
  2. 进入该目录,初始化项目

    yarn init
    

    输入插件名 vuepress-plugin-simple-encrypt ,入口文件名 index.js ,其他选项对应填写即可。

    image-20220424215319909
    image-20220424215319909

    初始化之后,package.json 的文件内容:

    {
      "name": "vuepress-plugin-simple-encrypt",
      "version": "1.0.0",
      "description": "a simple encrypt and decrypt for vuepress",
      "main": "index.js",
      "scripts": {
        "test": "yarn test"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/terwer/vuepress-plugin-simple-encrypt.git"
      },
      "keywords": [
        "encrypt",
        "decrypt",
        "vuepress"
      ],
      "author": "terwer",
      "license": "MIT",
      "bugs": {
        "url": "https://github.com/terwer/vuepress-plugin-simple-encrypt/issues"
      },
      "homepage": "https://github.com/terwer/vuepress-plugin-simple-encrypt#readme"
    }
    
  3. 编写入口文件 index.js

    module.exports = (options, ctx) => {
        return {
            name: 'vuepress-plugin-simple-encrypt',
            async ready() {
                console.log('Hello World!');
            }
        }
    }
    
  4. 注入插件到 vuepress。在 config.ts 文件的插件节点加上我们的插件,注意使用相对目录目录

    [
      require('../../pkg/vuepress-plugin-simple-encrypt'), // 主要用于文章部分加密
      {
      }
    ]
    
  5. 启动项目 yarn dev ,正常情况可以看到输出 Hello World


Terwer...大约 2 分钟前端开发插件目录初始化从零开始vuepressplugin
Struts2类型转换之全局类型转换

概述

全局类型转换。在 src​ 目录下新建 xwork-conversion.properties​ ,该文件的内容是 待转换的类=转换器名字 ,即:

space.terwer.bean.User=space.terwer.converter.UserConverter2

Terwer...小于 1 分钟后端开发Struts2目录新建文件概述全局类型转换converterglobal
Vuepress平台配置指南

特别提示

注意:这个是 Vuepress 源码目录结构,不是构建文件部署的。这个是 Vuepress 源码目录结构,不是构建文件部署的。这个是 Vuepress 源码目录结构,不是构建文件部署的。

Github pages 不能用这个配置,Github pages 请参考 Hugo、Hexo 或者 Jekyll(Github 内置默认支持)。

推荐 Vuepress 的 V1 版本,配合 vuepress-theme-vdoing 使用,后续 bug 也只会对 V1 和此主题进行更新


Terwer...大约 1 分钟平台配置sy-post-publisher作品展示源码目录结构这个不是