├── example
├── .gitignore
├── md
│ ├── demos
│ │ └── test.jsx
│ └── test.md
├── src
│ ├── App.jsx
│ ├── main.jsx
│ └── favicon.svg
├── index.html
├── package.json
├── vite.config.js
└── yarn.lock
├── .gitignore
├── src
├── utils
│ ├── slash.js
│ └── parseHeader.js
├── markdown
│ ├── plugins
│ │ ├── hoist.js
│ │ ├── preWrapper.js
│ │ ├── header.js
│ │ ├── slugify.js
│ │ ├── lineNumbers.js
│ │ ├── containers.js
│ │ ├── highlight.js
│ │ ├── highlightLines.js
│ │ ├── link.js
│ │ ├── component.js
│ │ └── snippet.js
│ └── markdown.js
└── main.js
├── .travis.yml
├── docs
└── vite-plugin-tdoc.png
├── rollup.config.js
├── .github
└── workflows
│ └── tag-push.yml
├── LICENSE
├── README.md
└── package.json
/example/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .DS_Store
3 | dist
4 | dist-ssr
5 | *.local
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | dist
4 | package-lock.json
5 | yarn.lock
6 |
--------------------------------------------------------------------------------
/src/utils/slash.js:
--------------------------------------------------------------------------------
1 | export function slash(p) {
2 | return p.replace(/\\/g, '/')
3 | }
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '11'
4 | - '10'
5 | - '8'
6 | - '6'
7 |
--------------------------------------------------------------------------------
/docs/vite-plugin-tdoc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/honkinglin/vite-plugin-tdoc/HEAD/docs/vite-plugin-tdoc.png
--------------------------------------------------------------------------------
/example/md/demos/test.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 |
3 | function Test() {
4 |
5 | return (
6 |
hello world
7 | )
8 | }
9 |
10 | export default Test
11 |
--------------------------------------------------------------------------------
/example/src/App.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import Test from '../md/test.md'
3 |
4 | function App() {
5 | return (
6 |
7 |
8 |
9 | )
10 | }
11 |
12 | export default App
13 |
--------------------------------------------------------------------------------
/example/src/main.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom'
3 | import App from './App'
4 |
5 | ReactDOM.render(
6 |
7 |
8 | ,
9 | document.getElementById('root')
10 | )
11 |
--------------------------------------------------------------------------------
/example/md/test.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Blogging Like a Hacker
3 | lang: en-US
4 | editLink: true
5 | sidebar: auto
6 | navbar: true
7 | ---
8 |
9 | [[toc]]
10 |
11 | # Test
12 |
13 | ### a.info
14 |
15 | ### Render custom demos
16 |
17 | ::: demo demos/test
18 | :::
19 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite App
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "dev": "vite",
6 | "build": "vite build",
7 | "preview": "vite preview"
8 | },
9 | "dependencies": {
10 | "react": "^17.0.2",
11 | "react-dom": "^17.0.2"
12 | },
13 | "devDependencies": {
14 | "@babel/core": "^7.16.0",
15 | "@babel/preset-react": "^7.16.0",
16 | "@vitejs/plugin-react": "^1.1.1",
17 | "gray-matter": "^4.0.3",
18 | "vite": "^2.7.0"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import resolve from '@rollup/plugin-node-resolve';
2 | import commonjs from '@rollup/plugin-commonjs';
3 | import json from "@rollup/plugin-json";
4 | import pkg from './package.json';
5 |
6 | export default [
7 | {
8 | input: 'src/main.js',
9 | output: [
10 | { file: pkg.main, format: 'cjs', exports: "auto" },
11 | { file: pkg.module, format: 'es', exports: "auto" },
12 | ],
13 | plugins: [
14 | resolve({ preferBuiltins: true }),
15 | commonjs(),
16 | json(),
17 | ]
18 | }
19 | ];
20 |
--------------------------------------------------------------------------------
/src/markdown/plugins/hoist.js:
--------------------------------------------------------------------------------
1 | // hoist