config.js 2.5 KB
Newer Older
D
DCloud_LXH 已提交
1

M
mehaotian 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
const { slugify } = require("@vuepress/shared-utils");
const translatePlugin = require("./markdown/translate");
const headerPlugin = require("./markdown/header");
const createSidebar = require("./markdown/createSidebar");
const { simplifySlugText } = require("./utils");

const tabs = [
  "/uniCloud/",
  "/plugin/",
  "/worktile/",
  "/tutorial/",
  "/collocation/",
  "/component/",
  "/api/",
  "/",
];
D
DCloud_LXH 已提交
18 19
const config = {
  // TODO use theme
M
mehaotian 已提交
20
  title: "uni-app官网",
D
DCloud_LXH 已提交
21
  head: [
M
mehaotian 已提交
22 23 24 25 26 27 28 29
    [
      "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 已提交
30
  ],
D
DCloud_LXH 已提交
31
  locales: {
M
mehaotian 已提交
32 33 34
    "/": {
      lang: "zh-CN",
    },
D
DCloud_LXH 已提交
35
  },
D
DCloud_LXH 已提交
36
  themeConfig: {
M
mehaotian 已提交
37 38 39
    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",
D
DCloud_LXH 已提交
40 41 42 43 44 45
    // TODO use plugin/theme
    sidebar: createSidebar(tabs),
    // sidebarDepth: 2,
    nextLinks: false,
    prevLinks: false,
    // TODO use theme
M
mehaotian 已提交
46 47 48 49
    repo: "dcloudio/uni-app",
    docsRepo: "https://gitee.com/dcloud/unidocs-zh",
    docsBranch: "master",
    docsDir: "docs",
D
DCloud_LXH 已提交
50
    editLinks: true,
M
mehaotian 已提交
51 52
    editLinkText: "帮助我们改善此页面!",
    lastUpdated: "上次更新",
D
DCloud_LXH 已提交
53
    // smoothScroll: true,
54
    algolia: {
M
mehaotian 已提交
55 56 57 58 59
      apiKey: "2fdcc4e76c8e260671ad70065e60b2e7",
      indexName: "zh-uniapp",
      appId: "PQIR5NL8CZ",
      searchParameters: { hitsPerPage: 50 },
    },
D
DCloud_LXH 已提交
60 61 62
  },
  markdown: {
    slugify(str) {
M
mehaotian 已提交
63
      if (typeof str !== "string") return "";
D
DCloud_LXH 已提交
64

M
mehaotian 已提交
65 66 67 68
      let slug = str;
      if (slug.includes("@")) {
        let array = slug.split("@");
        slug = array.length > 1 ? array[array.length - 1] : str;
D
DCloud_LXH 已提交
69
      } else {
M
mehaotian 已提交
70
        slug = simplifySlugText(slug.toLowerCase()).trim();
D
DCloud_LXH 已提交
71
      }
M
mehaotian 已提交
72
      return slugify(slug);
D
DCloud_LXH 已提交
73
    },
M
mehaotian 已提交
74 75
    extractHeaders: ["h1", "h2", "h3", "h4"],
    async chainMarkdown(config) {
D
DCloud_LXH 已提交
76
      config
M
mehaotian 已提交
77
        .plugin("translate")
D
DCloud_LXH 已提交
78 79
        .use(translatePlugin)
        .end()
M
mehaotian 已提交
80
        .plugin("convert-header")
D
DCloud_LXH 已提交
81
        .use(headerPlugin)
D
DCloud_LXH 已提交
82
        .end()
M
mehaotian 已提交
83 84 85 86 87 88 89 90 91 92 93
        .plugin("normallize-link")
        .use(require("./markdown/normallizeLink"));
    },
  },
  plugins: [
    [require('./markdown/highlighter'),{
      theme: "material-palenight",
      // langs:[]
    }]
  ],
};
D
DCloud_LXH 已提交
94

M
mehaotian 已提交
95
module.exports = config;