Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
计算机应用开发
前端
Vuepress
提交
3f65817c
V
Vuepress
项目概览
计算机应用开发
/
前端
/
Vuepress
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vuepress
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3f65817c
编写于
8月 10, 2018
作者:
U
ULIVZ
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: new theme api
上级
9693ae10
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
44 deletion
+50
-44
packages/@vuepress/core/lib/prepare/index.js
packages/@vuepress/core/lib/prepare/index.js
+1
-1
packages/@vuepress/core/lib/prepare/resolveOptions.js
packages/@vuepress/core/lib/prepare/resolveOptions.js
+44
-41
packages/@vuepress/core/lib/prepare/resolveSiteData.js
packages/@vuepress/core/lib/prepare/resolveSiteData.js
+3
-0
packages/@vuepress/plugin-test/index.js
packages/@vuepress/plugin-test/index.js
+1
-1
packages/@vuepress/theme-default/components/Badge.vue
packages/@vuepress/theme-default/components/Badge.vue
+1
-1
未找到文件。
packages/@vuepress/core/lib/prepare/index.js
浏览文件 @
3f65817c
...
...
@@ -26,7 +26,7 @@ module.exports = async function prepare (sourceDir, isProd) {
await
plugin
.
hooks
.
ready
.
run
()
// 4.
A
pply plugin options to extend markdown.
// 4.
a
pply plugin options to extend markdown.
plugin
.
options
.
extendMarkdown
.
run
(
markdown
)
plugin
.
options
.
clientDynamicModules
.
run
()
...
...
packages/@vuepress/core/lib/prepare/resolveOptions.js
浏览文件 @
3f65817c
...
...
@@ -6,6 +6,15 @@ const loadConfig = require('./loadConfig')
const
{
sort
}
=
require
(
'
./util
'
)
module
.
exports
=
async
function
resolveOptions
(
sourceDir
)
{
function
requireResolve
(
target
)
{
return
require
.
resolve
(
target
,
{
paths
:
[
path
.
resolve
(
__dirname
,
'
../../node_modules
'
),
path
.
resolve
(
sourceDir
)
]
})
}
const
vuepressDir
=
path
.
resolve
(
sourceDir
,
'
.vuepress
'
)
const
siteConfig
=
loadConfig
(
vuepressDir
)
...
...
@@ -33,54 +42,48 @@ module.exports = async function resolveOptions (sourceDir) {
:
path
.
resolve
(
sourceDir
,
'
.vuepress/dist
'
)
// resolve theme
const
useDefaultTheme
=
(
!
siteConfig
.
theme
&&
!
fs
.
existsSync
(
path
.
resolve
(
vuepressDir
,
'
theme
'
))
)
const
defaultThemePath
=
path
.
resolve
(
__dirname
,
'
../default-theme
'
)
const
localThemePath
=
path
.
resolve
(
vuepressDir
,
'
theme
'
)
const
useLocalTheme
=
fs
.
existsSync
(
localThemePath
)
let
themePath
=
null
let
themeLayoutPath
=
null
let
themeNotFoundPath
=
null
let
themeIndexFile
=
null
let
themePlugins
=
[]
console
.
log
(
useDefaultTheme
)
console
.
log
(
siteConfig
)
if
(
useDefaultTheme
)
{
// use default theme
themePath
=
defaultThemePath
themeLayoutPath
=
path
.
resolve
(
defaultThemePath
,
'
Layout.vue
'
)
themeNotFoundPath
=
path
.
resolve
(
defaultThemePath
,
'
NotFound.vue
'
)
}
else
{
// resolve theme Layout
if
(
siteConfig
.
theme
)
{
// use external theme
// backward-compatible
if
(
useLocalTheme
)
{
// use local custom theme
themePath
=
localThemePath
themeLayoutPath
=
path
.
resolve
(
localThemePath
,
'
Layout.vue
'
)
themeNotFoundPath
=
path
.
resolve
(
localThemePath
,
'
NotFound.vue
'
)
if
(
!
fs
.
existsSync
(
themeLayoutPath
))
{
throw
new
Error
(
`[vuepress] Cannot resolve Layout.vue file in .vuepress/theme.`
)
}
if
(
!
fs
.
existsSync
(
themeNotFoundPath
))
{
throw
new
Error
(
`[vuepress] Cannot resolve NotFound.vue file in .vuepress/theme.`
)
}
}
else
if
(
siteConfig
.
theme
)
{
// use external theme
try
{
// backward-compatible 0.x.x.
themeLayoutPath
=
requireResolve
(
`vuepress-theme-
${
siteConfig
.
theme
}
/Layout.vue`
)
themePath
=
path
.
dirname
(
themeLayoutPath
)
themeNotFoundPath
=
path
.
resolve
(
themeLayoutPath
,
'
NotFound.vue
'
)
}
catch
(
e
)
{
try
{
themeLayoutPath
=
require
.
resolve
(
`vuepress-theme-
${
siteConfig
.
theme
}
/Layout.vue`
,
{
paths
:
[
path
.
resolve
(
__dirname
,
'
../../node_modules
'
),
path
.
resolve
(
sourceDir
)
]
})
themePath
=
path
.
dirname
(
themeLayoutPath
)
themeIndexFile
=
requireResolve
(
`vuepress-theme-
${
siteConfig
.
theme
}
/index.js`
)
}
catch
(
e
)
{
t
hrow
new
Error
(
`[vuepress] Failed to load custom theme "
$
{
siteConfig
.
theme
}
". File vuepress-theme-
${
siteConfig
.
theme
}
/Layout.vue does not exist.`
)
}
}
else
{
// use custom theme
themePath
=
path
.
resolve
(
vuepressDir
,
'
theme
'
)
themeLayoutPath
=
path
.
resolve
(
themePath
,
'
Layout.vue
'
)
if
(
!
fs
.
existsSync
(
themeLayoutPath
))
{
throw
new
Error
(
`[vuepress] Cannot resolve Layout.vue file in .vuepress/theme.`
)
t
ry
{
themeIndexFile
=
requireResolve
(
`@vuepress/theme-
${
siteConfig
.
theme
}
`
)
themePath
=
path
.
dirname
(
themeIndexFile
)
themeIndexFile
=
require
(
themeIndexFile
)
themeLayoutPath
=
themeIndexFile
.
layout
themeNotFoundPath
=
themeIndexFile
.
notFound
themePlugins
=
themeIndexFile
.
plugins
}
catch
(
e
)
{
throw
new
Error
(
`[vuepress] Failed to load custom theme "
${
siteConfig
.
theme
}
". File vuepress-theme-
${
siteConfig
.
theme
}
/Layout.vue does not exist.`
)
}
}
}
// resolve theme NotFound
themeNotFoundPath
=
path
.
resolve
(
themePath
,
'
NotFound.vue
'
)
if
(
!
fs
.
existsSync
(
themeNotFoundPath
))
{
themeNotFoundPath
=
path
.
resolve
(
defaultThemePath
,
'
NotFound.vue
'
)
}
}
// resolve theme config
...
...
@@ -118,7 +121,7 @@ module.exports = async function resolveOptions (sourceDir) {
themePath
,
themeLayoutPath
,
themeNotFoundPath
,
useDefaultTheme
,
themePlugins
,
isAlgoliaSearch
,
markdown
}
...
...
packages/@vuepress/core/lib/prepare/resolveSiteData.js
浏览文件 @
3f65817c
...
...
@@ -58,6 +58,9 @@ module.exports = async function ({
// resolve additional pagesData
const
additionalPagesData
=
await
Promise
.
all
(
plugin
.
options
.
additionalPages
.
values
.
map
(
async
({
route
:
routePath
,
path
:
filepath
})
=>
{
if
(
!
fs
.
existsSync
(
filepath
))
{
throw
new
Error
(
`[vuepress] Cannot resolve additional page:
${
filepath
}
`
)
}
return
getPageData
({
filepath
,
routePath
})
})
)
...
...
packages/@vuepress/plugin-test/index.js
浏览文件 @
3f65817c
...
...
@@ -69,7 +69,7 @@ module.exports = (options, context) => ({
return
[
{
route
:
'
/readme/
'
,
path
:
path
.
resolve
(
__dirname
,
'
../../README.md
'
)
path
:
path
.
resolve
(
__dirname
,
'
../../
../
README.md
'
)
}
]
},
...
...
packages/@vuepress/theme-default/components/Badge.vue
浏览文件 @
3f65817c
...
...
@@ -21,7 +21,7 @@ export default {
</
script
>
<
style
lang=
"stylus"
scoped
>
@import '../
../default-theme
/styles/config.styl'
@import '../
src
/styles/config.styl'
.badge
display inline-block
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录