config.js 3.0 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
  title: 'uni-app官网',
D
DCloud_LXH 已提交
12
  description: 'uni-app,uniCloud,serverless',
D
DCloud_LXH 已提交
13 14 15 16
  head: [
    ['link', {
      rel: 'shortcut icon',
      type: 'image/x-icon',
D
DCloud_LXH 已提交
17
      href: 'https://web-assets.dcloud.net.cn/unidoc/zh/icon.png?v=1556263038788'
D
DCloud_LXH 已提交
18
    }],
D
DCloud_LXH 已提交
19 20 21
    ['meta', {
      name: 'keywords', content: 'serverless,云开发,数字天堂,前端开发,web开发,小程序开发,跨平台,跨平台开发,跨端开发,混合开发,app开发,多端开发,开发工具,HTML5,vue,react,native,rn,flutter,weex,cordova,微信小程序,阿里小程序,支付宝小程序,百度小程序,头条小程序,抖音小程序,QQ小程序,快应用,流应用,云函数'
    }],
D
DCloud_LXH 已提交
22
    ['script', { src: `/js/redirect.js?${Date.now()}&v=${Date.now()}&version=${Date.now()}` }],
D
DCloud_LXH 已提交
23
    ['script', { src: 'https://hm.baidu.com/hm.js?fe3b7a223fc08c795f0f4b6350703e6f' }]
D
DCloud_LXH 已提交
24
  ],
D
DCloud_LXH 已提交
25 26 27 28 29
  locales: {
    '/': {
      lang: 'zh-CN',
    }
  },
D
DCloud_LXH 已提交
30
  themeConfig: {
D
DCloud_LXH 已提交
31 32
    titleLogo: 'https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png',
    logo: 'https://web-assets.dcloud.net.cn/unidoc/zh/logo.png',
D
DCloud_LXH 已提交
33
    sidebar: createSidebar(tabs),
D
DCloud_LXH 已提交
34
    sidebarDepth: 0,
D
DCloud_LXH 已提交
35 36 37
    nextLinks: false,
    prevLinks: false,
    repo: 'dcloudio/uni-app',
D
DCloud_LXH 已提交
38
    docsRepo: 'https://gitcode.net/dcloud/unidocs-zh',
D
DCloud_LXH 已提交
39
    docsBranch: 'master',
D
DCloud_LXH 已提交
40 41 42
    docsDir: 'docs',
    editLinks: true,
    editLinkText: '帮助我们改善此页面!',
D
DCloud_LXH 已提交
43
    lastUpdated: '上次更新',
D
DCloud_LXH 已提交
44
    // smoothScroll: true,
45 46 47
    algolia: {
      apiKey: '2fdcc4e76c8e260671ad70065e60b2e7',
      indexName: 'zh-uniapp',
D
DCloud_LXH 已提交
48
      appId: 'PQIR5NL8CZ',
D
DCloud_LXH 已提交
49
      searchParameters: { hitsPerPage: 50 }
D
DCloud_LXH 已提交
50 51
    },
    isDevelopment: process.env.NODE_ENV === 'development'
D
DCloud_LXH 已提交
52 53
  },
  markdown: {
D
DCloud_LXH 已提交
54
    // toc: { includeLevel: [1, 2, 3, 4] },
D
DCloud_LXH 已提交
55
    slugify (str) {
D
DCloud_LXH 已提交
56
      if (typeof str !== 'string') return ''
D
DCloud_LXH 已提交
57

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

D
DCloud_LXH 已提交
91
module.exports = config