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

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

D
DCloud_LXH 已提交
94
module.exports = config