UNPKG

1.54 kBJavaScriptView Raw
1const path = require('path')
2
3/**
4 * @type {import('@vuepress/types').Theme<import('@vuepress/types').DefaultThemeConfig>}
5 */
6module.exports = (options, ctx) => {
7 const { themeConfig, siteConfig } = ctx
8
9 // resolve algolia
10 const isAlgoliaSearch = (
11 themeConfig.algolia
12 || Object
13 .keys(siteConfig.locales && themeConfig.locales || {})
14 .some(base => themeConfig.locales[base].algolia)
15 )
16
17 const enableSmoothScroll = themeConfig.smoothScroll === true
18
19 return {
20 alias () {
21 return {
22 '@AlgoliaSearchBox': isAlgoliaSearch
23 ? path.resolve(__dirname, 'components/AlgoliaSearchBox.vue')
24 : path.resolve(__dirname, 'noopModule.js')
25 }
26 },
27
28 plugins: [
29 ['@vuepress/active-header-links', options.activeHeaderLinks],
30 '@vuepress/search',
31 '@vuepress/plugin-nprogress',
32 ['container', {
33 type: 'tip',
34 defaultTitle: {
35 '/': 'TIP',
36 '/zh/': '提示'
37 }
38 }],
39 ['container', {
40 type: 'warning',
41 defaultTitle: {
42 '/': 'WARNING',
43 '/zh/': '注意'
44 }
45 }],
46 ['container', {
47 type: 'danger',
48 defaultTitle: {
49 '/': 'DANGER',
50 '/zh/': '警告'
51 }
52 }],
53 ['container', {
54 type: 'details',
55 before: info => `<details class="custom-block details">${info ? `<summary>${info}</summary>` : ''}\n`,
56 after: () => '</details>\n'
57 }],
58 ['smooth-scroll', enableSmoothScroll]
59 ]
60 }
61}