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

md-tools-cli

v1.0.4

Published

Transform Markdown into a SPA website using React or Vue.

Downloads

37

Readme

md-tools

md-tools用于解析Markdown文件,并生成React(vue)静态站点。

功能

md-tools重度参考Bi Sheng,并在此基础剥离React依赖。

  • 引擎体系:提供React渲染引擎
  • 插件体系:antd类文档网站插件,组件类文档网站插件,描述信息插件,目录插件,图片预览插件,React解析插件,代码高清插件
  • 主题体系

如何使用

安装依赖:

npm install -D md-tools

npm scripts中增加start:

{
  "scripts": {
    "start": "md-tools start"
  }
}

增加配置文件 md-tools.config.js, 默认配置:

module.exports = {
  source: './posts',
  output: './_site',
  theme: './_theme',
  port: 8000,
};

文档

命令

$ npm install -g md-tools
$ md-tools -h
  用法: md-tools [command] [options]

  Commands:

    start [options]     开发模式:启动服务
    build [options]     生产模式:生产模式:构建输出静态文件
    help [cmd]          显示帮助信息

  Options:

    -h, --help     显示帮助信息
    -V, --version  显示版本号
    -c,--config    start,build命令设置配置文件路径,默认: md-tools-theme-component-react/md-tool.config.js

配置文件

md-tools 默认使用md-tools.config.js作为配置,可以通过 --config修改配置文件路径,如: md-tools --config another.config.js

md-tools.config.js的配置例子:

module.exports = {
  port: 8000,
  source: './posts',
  output: './site',
  engine: 'md-tools-engine-react',
  theme: './theme',
  htmlTemplate: path.join(__dirname, '../template.html'),
  devServerConfig: {},
  webpackConfig(config) {
    return config;
  },

  entryName: 'index',
  root: '/',
};

port: Number

default: 8000

开发模式下启动的服务端口号,如果端口被占用,会自动寻找未使用的端口

source: String | Array[String] | Object{ [category]: String | Array[String]}

default: './posts'

需要转换的Markdown文件所在路径.

Markdown文件内容会转换为插件体系预处理用到的Markdown数据,数据结构见 mark-twain

exclude: RegExp

default: null

需要例外的Markdown文件

output: String

default: './site'

md-tools构建输出的路径.

engine: String

default: 'md-tools-engine-react'

文档系统源码路径(引擎体系),可以是npm依赖包名称

theme: String

default: './theme'

文档系统源码路径(主题体系),可以是npm依赖包名称

themeConfig: any

undefined

主题个性配置, 主题源文件可以从props.themeConfig读取改配置。

备注: themeConfig传递过程使用了 JSON.stringify,所以无法在这里配置function/RegExp.

htmlTemplate: String

default: md-tools/lib/template.html

文档系统入口html文件模板,如果配置的引擎带有htmlTemplate,则默认值为引擎中的模板.

Note: 模板引擎 nunjucks, 模板中的参数:

iframeTemplate: String

default: md-tools-plugin-antd/lib/template.html

文档系统入口html文件模板(Markdown文档中配置iframe=[number]时)。

htmlTemplateExtraData: Object

default: {}

htmlTemplate自定义参数.

devServerConfig: Object

default: {}

参见 webpack-dev-server's documentation.

postcssConfig: Object

default: {
    plugins: [
      rucksack(),
      autoprefixer({
        browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 9', 'iOS >= 8', 'Android >= 4'],
      }),
    ],
  }

参见 wenpack postcss-loader's documentation.

webpackConfig: (config) => config

default: (config) => config

自定义webpack配置,参见 this.

transformers: Object[]

[{ test: /.md$/, use: MarkdownTransformer}]

Markdown转换引擎.

entryName: String

default: 'index'

webpack构建入口文件名, 如 [entryName].js & [entryName].css

root: String

default: '/'

发布目录。默认根目录,如果需要发布到二级目录,配置相应目录即可。

鸣谢

License

MIT