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

const tabs = ['/uniCloud/', '/plugin/', '/worktile/', '/tutorial/', '/collocation/', '/component/', '/api/', '/']

const config = {
  // TODO use theme
D
DCloud_LXH 已提交
11 12 13 14 15 16 17 18
  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 已提交
19 20 21 22 23 24 25 26 27 28
  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),
    // sidebarDepth: 2,
    nextLinks: false,
    prevLinks: false,
    // TODO use theme
    repo: 'dcloudio/uni-app',
D
DCloud_LXH 已提交
29
    docsRepo: 'https://gitee.com/dcloud/unidocs-zh',
D
DCloud_LXH 已提交
30
    docsBranch: 'vuepress',
D
DCloud_LXH 已提交
31 32 33 34
    docsDir: 'docs',
    editLinks: true,
    editLinkText: '帮助我们改善此页面!',
    // smoothScroll: true,
35 36 37
    algolia: {
      apiKey: '2fdcc4e76c8e260671ad70065e60b2e7',
      indexName: 'zh-uniapp',
D
DCloud_LXH 已提交
38
      appId: 'PQIR5NL8CZ',
D
DCloud_LXH 已提交
39
      searchParameters: { hitsPerPage: 50 }
40
    }
D
DCloud_LXH 已提交
41 42 43
  },
  markdown: {
    slugify(str) {
D
DCloud_LXH 已提交
44
      if (typeof str !== 'string') return ''
D
DCloud_LXH 已提交
45

D
DCloud_LXH 已提交
46
      let slug = str
D
DCloud_LXH 已提交
47 48 49 50
      if (slug.includes('@')) {
        let array = slug.split('@')
        slug = array.length > 1 ? array[array.length - 1] : str
      } else {
D
DCloud_LXH 已提交
51
        slug = simplifySlugText(slug.toLowerCase()).trim()
D
DCloud_LXH 已提交
52 53 54 55 56 57 58 59 60 61 62
      }
      return slugify(slug)
    },
    extractHeaders: ['h1', 'h2', 'h3', 'h4'],
    chainMarkdown(config) {
      config
        .plugin('translate')
        .use(translatePlugin)
        .end()
        .plugin('convert-header')
        .use(headerPlugin)
D
DCloud_LXH 已提交
63 64 65
        .end()
        .plugin('normallize-link')
        .use(require('./markdown/normallizeLink'))
D
DCloud_LXH 已提交
66
    }
D
DCloud_LXH 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
  },
  chainWebpack: (config, isServer) => {
    console.log('config :>> ', config);
    config.devServer.proxy({
      '/ext': {
        target: 'http://localhost:3000',  // 后台api
        changeOrigin: true,  //是否跨域
        secure: false,
        // secure: true,
        pathRewrite: {
          '^/ext': ''   //需要rewrite的,
        }
      },
      '/ask': {
        target: 'https://ask.dcloud.net.cn',  // 后台api
        changeOrigin: true,  //是否跨域
        secure: false,
        // secure: true,
        pathRewrite: {
          '^/ask': ''   //需要rewrite的,
        }
      }
    })
D
DCloud_LXH 已提交
90 91 92
  }
}

D
DCloud_LXH 已提交
93
module.exports = config