const path = require('path'); const { slugify } = require('@vuepress/shared-utils') const translatePlugin = require('./markdown/translate') const headerPlugin = require('./markdown/header') const createSidebar = require('./markdown/createSidebar') const { simplifySlugText, tabs } = require('./utils') const copyOptions = require('./config/copy'); const config = { theme: 'vuepress-theme-uni-app-test', title: 'uni-app官网', head: [ ['link', { rel: 'shortcut icon', type: 'image/x-icon', href: 'https://web-assets.dcloud.net.cn/unidoc/zh/icon.png?v=1556263038788' }], ['script', { src: `/js/redirect.js?${Date.now()}&v=${Date.now()}&version=${Date.now()}` }], ['script', { src: 'https://hm.baidu.com/hm.js?fe3b7a223fc08c795f0f4b6350703e6f' }] ], locales: { '/': { lang: 'zh-CN', } }, themeConfig: { titleLogo: 'https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png', logo: 'https://web-assets.dcloud.net.cn/unidoc/zh/logo.png', // TODO use plugin/theme sidebar: createSidebar(tabs), sidebarDepth: 0, nextLinks: false, prevLinks: false, // TODO use theme repo: 'dcloudio/uni-app', docsRepo: 'https://gitcode.net/dcloud/unidocs-zh', docsBranch: 'master', docsDir: 'docs', editLinks: true, editLinkText: '帮助我们改善此页面!', lastUpdated: '上次更新', // smoothScroll: true, algolia: { apiKey: '2fdcc4e76c8e260671ad70065e60b2e7', indexName: 'zh-uniapp', appId: 'PQIR5NL8CZ', searchParameters: { hitsPerPage: 50 } }, isDevelopment: process.env.NODE_ENV === 'development' }, markdown: { // toc: { includeLevel: [1, 2, 3, 4] }, slugify(str) { if (typeof str !== 'string') return '' let slug = str if (slug.includes('@')) { let array = slug.split('@') slug = array.length > 1 ? array[array.length - 1] : str } else { slug = simplifySlugText(slug.toLowerCase()).trim() } return slugify(slug) }, extractHeaders: ['h1', 'h2', 'h3', 'h4'], chainMarkdown(config) { config .plugin('translate') .use(translatePlugin) .end() .plugin('convert-header') .use(headerPlugin) .end() .plugin('normallize-link') .use(require('./markdown/normallizeLink')) } }, chainWebpack(config, isServer) { config.resolve.alias.set( '@theme-config', path.resolve(process.cwd(), 'docs/.vuepress/config') ) }, plugins: [ ["vuepress-plugin-juejin-style-copy", copyOptions] ] } module.exports = config