diff --git a/docs/.vuepress/config.yml b/docs/.vuepress/config.yml new file mode 100644 index 0000000000..7ef36b5e15 --- /dev/null +++ b/docs/.vuepress/config.yml @@ -0,0 +1,34 @@ +--- +title: VuePress +description: Vue-powered Static Site Generator +dest: vuepress +base: "/" +head: +- - link + - rel: icon + href: "/logo.png" +serviceWorker: true +themeConfig: + repo: vuejs/vuepress + editLinks: true + docsDir: docs + nav: + - text: Guide + link: "/guide/" + - text: Config Reference + link: "/config/" + - text: Default Theme Config + link: "/default-theme-config/" + sidebar: + "/guide/": + - title: Guide + collapsable: false + children: + - '' + - getting-started + - basic-config + - assets + - markdown + - using-vue + - custom-themes + - deploy \ No newline at end of file diff --git a/lib/prepare.js b/lib/prepare.js index f3439cb2e3..2c29b73761 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -2,6 +2,7 @@ const fs = require('fs-extra') const path = require('path') const globby = require('globby') const yaml = require('yaml-front-matter') +const yamlParser = require('js-yaml') const tempPath = path.resolve(__dirname, 'app/.temp') const { inferTitle, extractHeaders } = require('./util') @@ -66,9 +67,16 @@ if (!Object.assign) Object.assign = require('object-assign')` async function resolveOptions (sourceDir) { const vuepressDir = path.resolve(sourceDir, '.vuepress') const configPath = path.resolve(vuepressDir, 'config.js') + const configYmlPath = path.resolve(vuepressDir, 'config.yml') delete require.cache[configPath] - const siteConfig = fs.existsSync(configPath) ? require(configPath) : {} + let siteConfig = {} + if (fs.existsSync(configYmlPath)) { + const content = await fs.readFile(configYmlPath, 'utf-8') + siteConfig = yamlParser.safeLoad(content) + } else if (fs.existsSync(configPath)) { + siteConfig = require(configPath) + } // normalize description if (siteConfig.description) { diff --git a/package.json b/package.json index 423a709df0..c8f5c0411d 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "file-loader": "^1.1.11", "fs-extra": "^5.0.0", "globby": "^8.0.1", + "js-yaml": "^3.11.0", "koa-connect": "^2.0.1", "koa-mount": "^3.0.0", "koa-static": "^4.0.2", diff --git a/yarn.lock b/yarn.lock index 4d6decb97c..a30b0c56a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3274,7 +3274,7 @@ js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" -js-yaml@^3.10.0, js-yaml@^3.4.3, js-yaml@^3.9.0, js-yaml@^3.9.1: +js-yaml@^3.10.0, js-yaml@^3.11.0, js-yaml@^3.4.3, js-yaml@^3.9.0, js-yaml@^3.9.1: version "3.11.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef" dependencies: