config.js 2.8 KB
Newer Older
D
DCloud_LXH 已提交
1
const path = require('path');
D
DCloud_LXH 已提交
2 3 4 5
const { slugify } = require('@vuepress/shared-utils')
const translatePlugin = require('./markdown/translate')
const headerPlugin = require('./markdown/header')
const createSidebar = require('./markdown/createSidebar')
D
DCloud_LXH 已提交
6
const { simplifySlugText, tabs } = require('./utils')
D
DCloud_LXH 已提交
7
const copyOptions = require('./config/copy');
D
DCloud_LXH 已提交
8 9

const config = {
D
DCloud_LXH 已提交
10
  theme: 'vuepress-theme-uni-app-test',
D
DCloud_LXH 已提交
11 12 13 14 15 16
  title: 'uni-app官网',
  head: [
    ['link', {
      rel: 'shortcut icon',
      type: 'image/x-icon',
      href: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-a90b5f95-90ba-4d30-a6a7-cd4d057327db/d23e842c-58fc-4574-998d-17fdc7811cc3.png?v=1556263038788'
D
DCloud_LXH 已提交
17
    }],
D
DCloud_LXH 已提交
18
    ['script', { src: `/js/redirect.js?${Date.now()}&v=${Date.now()}&version=${Date.now()}` }],
D
DCloud_LXH 已提交
19
    ['script', { src: 'https://hm.baidu.com/hm.js?fe3b7a223fc08c795f0f4b6350703e6f' }]
D
DCloud_LXH 已提交
20
  ],
D
DCloud_LXH 已提交
21 22 23 24 25
  locales: {
    '/': {
      lang: 'zh-CN',
    }
  },
D
DCloud_LXH 已提交
26 27 28 29 30
  themeConfig: {
    titleLogo: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-f184e7c3-1912-41b2-b81f-435d1b37c7b4/1ae87107-2943-4ba6-be2b-390ca27c6260.png',
    logo: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-f184e7c3-1912-41b2-b81f-435d1b37c7b4/5a7f902b-21a7-4822-884f-925219eacc4b.png',
    // TODO use plugin/theme
    sidebar: createSidebar(tabs),
D
DCloud_LXH 已提交
31
    sidebarDepth: 0,
D
DCloud_LXH 已提交
32 33 34 35
    nextLinks: false,
    prevLinks: false,
    // TODO use theme
    repo: 'dcloudio/uni-app',
D
DCloud_LXH 已提交
36
    docsRepo: 'https://gitee.com/dcloud/unidocs-zh',
D
DCloud_LXH 已提交
37
    docsBranch: 'master',
D
DCloud_LXH 已提交
38 39 40
    docsDir: 'docs',
    editLinks: true,
    editLinkText: '帮助我们改善此页面!',
D
DCloud_LXH 已提交
41
    lastUpdated: '上次更新',
D
DCloud_LXH 已提交
42
    // smoothScroll: true,
43 44 45
    algolia: {
      apiKey: '2fdcc4e76c8e260671ad70065e60b2e7',
      indexName: 'zh-uniapp',
D
DCloud_LXH 已提交
46
      appId: 'PQIR5NL8CZ',
D
DCloud_LXH 已提交
47
      searchParameters: { hitsPerPage: 50 }
D
DCloud_LXH 已提交
48 49
    },
    isDevelopment: process.env.NODE_ENV === 'development'
D
DCloud_LXH 已提交
50 51
  },
  markdown: {
D
DCloud_LXH 已提交
52
    // toc: { includeLevel: [1, 2, 3, 4] },
D
DCloud_LXH 已提交
53
    slugify(str) {
D
DCloud_LXH 已提交
54
      if (typeof str !== 'string') return ''
D
DCloud_LXH 已提交
55

D
DCloud_LXH 已提交
56
      let slug = str
D
DCloud_LXH 已提交
57 58 59 60
      if (slug.includes('@')) {
        let array = slug.split('@')
        slug = array.length > 1 ? array[array.length - 1] : str
      } else {
D
DCloud_LXH 已提交
61
        slug = simplifySlugText(slug.toLowerCase()).trim()
D
DCloud_LXH 已提交
62 63 64 65 66 67 68 69 70 71 72
      }
      return slugify(slug)
    },
    extractHeaders: ['h1', 'h2', 'h3', 'h4'],
    chainMarkdown(config) {
      config
        .plugin('translate')
        .use(translatePlugin)
        .end()
        .plugin('convert-header')
        .use(headerPlugin)
D
DCloud_LXH 已提交
73 74 75
        .end()
        .plugin('normallize-link')
        .use(require('./markdown/normallizeLink'))
D
DCloud_LXH 已提交
76
    }
D
DCloud_LXH 已提交
77
  },
D
DCloud_LXH 已提交
78 79 80 81 82 83
  chainWebpack(config, isServer) {
    config.resolve.alias.set(
      '@theme-config',
      path.resolve(process.cwd(), 'docs/.vuepress/config')
    )
  },
D
DCloud_LXH 已提交
84 85 86
  plugins: [
    ["vuepress-plugin-juejin-style-copy", copyOptions]
  ]
D
DCloud_LXH 已提交
87 88
}

D
DCloud_LXH 已提交
89
module.exports = config