Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor($theme-default): toc #1436

Merged
merged 8 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/@vuepress/core/lib/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import Content from './components/Content.js'
import ContentSlotsDistributor from './components/ContentSlotsDistributor'
import OutboundLink from './components/OutboundLink.vue'
import ClientOnly from './components/ClientOnly'
import TOC from './components/TOC.vue'

// suggest dev server restart on base change
if (module.hot) {
Expand Down Expand Up @@ -47,8 +46,6 @@ Vue.component('ClientOnly', ClientOnly)
// core components
Vue.component('Layout', getLayoutAsyncComponent('Layout'))
Vue.component('NotFound', getLayoutAsyncComponent('NotFound'))
// markdown components
Vue.component('TOC', TOC)

// global helper for adding base path to absolute urls
Vue.prototype.$withBase = function (path) {
Expand Down
6 changes: 0 additions & 6 deletions packages/@vuepress/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const componentPlugin = require('./lib/component')
const hoistScriptStylePlugin = require('./lib/hoist')
const convertRouterLinkPlugin = require('./lib/link')
const snippetPlugin = require('./lib/snippet')
const tocPlugin = require('./lib/tableOfContents')
const emojiPlugin = require('markdown-it-emoji')
const anchorPlugin = require('markdown-it-anchor')
const {
Expand All @@ -32,7 +31,6 @@ module.exports = (markdown = {}) => {
const {
externalLinks,
anchor,
toc,
plugins,
lineNumbers,
beforeInstantiate,
Expand Down Expand Up @@ -93,10 +91,6 @@ module.exports = (markdown = {}) => {
}, anchor)])
.end()

.plugin(PLUGINS.TOC)
.use(tocPlugin, [toc])
.end()

if (lineNumbers) {
config
.plugin(PLUGINS.LINE_NUMBERS)
Expand Down
3 changes: 3 additions & 0 deletions packages/@vuepress/plugin-toc/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__tests__
__mocks__
.temp
5 changes: 5 additions & 0 deletions packages/@vuepress/plugin-toc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @vuepress/plugin-toc

> table of contents plugin for vuepress

See [documentation](https://vuepress.vuejs.org/plugin/official/plugin-toc.html).
5 changes: 5 additions & 0 deletions packages/@vuepress/plugin-toc/enhanceApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import TOC from './components/TOC.vue'

export default ({ Vue }) => {
Vue.component('TOC', TOC)
}
10 changes: 10 additions & 0 deletions packages/@vuepress/plugin-toc/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const markdownTOC = require('./markdown')
const { path } = require('@vuepress/shared-utils')

module.exports = (options = {}, context) => ({
extendMarkdown (md) {
md.use(markdownTOC, options)
},

enhanceAppFiles: path.resolve(__dirname, 'enhanceApp.js')
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// reference: https://github.com/Oktavilla/markdown-it-table-of-contents

const defaults = {
includeLevel: [2, 3],
containerClass: 'table-of-contents',
Expand Down
26 changes: 26 additions & 0 deletions packages/@vuepress/plugin-toc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@vuepress/plugin-toc",
"version": "1.0.0-alpha.44",
"description": "table of contents plugin for vuepress",
"main": "index.js",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vuepress.git",
"directory": "packages/@vuepress/plugin-toc"
},
"keywords": [
"documentation",
"vue",
"vuepress",
"generator"
],
"author": "Shigma <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/vuejs/vuepress/issues"
},
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/plugin-toc#readme"
}
3 changes: 2 additions & 1 deletion packages/@vuepress/theme-default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ module.exports = (options, ctx) => ({

plugins: [
'@vuepress/active-header-links',
'@vuepress/nprogress',
'@vuepress/search',
'@vuepress/plugin-nprogress',
'@vuepress/toc',
['@vuepress/container', { type: 'tip' }],
['@vuepress/container', { type: 'warning' }],
['@vuepress/container', { type: 'danger' }]
Expand Down
1 change: 1 addition & 0 deletions packages/@vuepress/theme-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@vuepress/plugin-container": "^1.0.0-alpha.44",
"@vuepress/plugin-nprogress": "^1.0.0-alpha.44",
"@vuepress/plugin-search": "^1.0.0-alpha.44",
"@vuepress/plugin-toc": "^1.0.0-alpha.44",
"docsearch.js": "^2.5.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2"
Expand Down