提交 d8d5f25a 编写于 作者: D DCloud_LXH

feat: 修改 html prefetch 脚本逻辑

上级 ac4d714b
...@@ -48,6 +48,7 @@ const config = { ...@@ -48,6 +48,7 @@ const config = {
editLinkText: '帮助我们改善此页面!', editLinkText: '帮助我们改善此页面!',
lastUpdated: '上次更新', lastUpdated: '上次更新',
// smoothScroll: true, // smoothScroll: true,
search: false,
algolia: { algolia: {
apiKey: '2fdcc4e76c8e260671ad70065e60b2e7', apiKey: '2fdcc4e76c8e260671ad70065e60b2e7',
indexName: 'zh-uniapp', indexName: 'zh-uniapp',
...@@ -107,18 +108,39 @@ const config = { ...@@ -107,18 +108,39 @@ const config = {
path.resolve(process.cwd(), 'docs/.vuepress/config') path.resolve(process.cwd(), 'docs/.vuepress/config')
) )
}, },
patterns: ['**/!(_sidebar).md', '**/*.vue'],
plugins: [ plugins: [
["vuepress-plugin-juejin-style-copy", copyOptions] ["vuepress-plugin-juejin-style-copy", copyOptions],
[
'named-chunks',
{
layoutChunkName: (layout) => 'layout-' + layout.componentName,
pageChunkName: page => {
const _context = page._context
const pageHeaders = (page.headers || []).map(item => item.title).join(',')
if (pageHeaders) {
const originDescription = page.frontmatter.description || ''
page.frontmatter = {
...page.frontmatter,
description: `${_context.siteConfig.description ? `${_context.siteConfig.description},` : ''}${pageHeaders}${originDescription ? `,${originDescription}` : ''}`.slice(0, 150),
}
}
const pagePath = page.path.indexOf('.html') === -1 ? page.path + 'index' : page.path
const curPath = 'docs/' + pagePath.replace('docs/', '').substring(1).replace(/\.html/g, "")
return curPath
}
}
]
], ],
/** /**
* *
* @param {string} path path: js 资源文件路径 * @param {string} path path: js 资源文件路径
* @param {string} type type: 资源文件类型,取值有 script 等 * @param {string} type type: 资源文件类型,取值有 script 等
* @returns * @returns
*/ */
shouldPrefetch: (path, type) => { shouldPrefetch: (path, type) => {
if (type === 'script' && path.indexOf('/docs/') > -1) return false if (type === 'script') return path.includes('vendors~') || path.includes('layout-') || path.includes('index.')
return true return false
} }
} }
......
...@@ -9388,6 +9388,11 @@ vuepress-plugin-mermaidjs@1.9.1: ...@@ -9388,6 +9388,11 @@ vuepress-plugin-mermaidjs@1.9.1:
dependencies: dependencies:
mermaid "^8.14.0" mermaid "^8.14.0"
vuepress-plugin-named-chunks@^1.1.4:
version "1.1.4"
resolved "https://registry.npmmirror.com/vuepress-plugin-named-chunks/-/vuepress-plugin-named-chunks-1.1.4.tgz#c65e121a8d0bbb4201766ec06816a2aa67dae3b7"
integrity sha512-zCRVmbf10VAf8NcrVLlm1b6eGU3vkc/iLVNvpIL3sBvtCCVaZheT2OlaV0CMPE6OjjTYbMrYXjugu4vcpiXrNQ==
vuepress-plugin-smooth-scroll@^0.0.3: vuepress-plugin-smooth-scroll@^0.0.3:
version "0.0.3" version "0.0.3"
resolved "https://registry.yarnpkg.com/vuepress-plugin-smooth-scroll/-/vuepress-plugin-smooth-scroll-0.0.3.tgz#6eff2d4c186cca917cc9f7df2b0af7de7c8c6438" resolved "https://registry.yarnpkg.com/vuepress-plugin-smooth-scroll/-/vuepress-plugin-smooth-scroll-0.0.3.tgz#6eff2d4c186cca917cc9f7df2b0af7de7c8c6438"
...@@ -9402,10 +9407,10 @@ vuepress-plugin-zooming@^1.1.8: ...@@ -9402,10 +9407,10 @@ vuepress-plugin-zooming@^1.1.8:
dependencies: dependencies:
zooming "^2.1.1" zooming "^2.1.1"
vuepress-theme-uni-app-test@^1.3.19: vuepress-theme-uni-app-test@^1.3.20:
version "1.3.19" version "1.3.20"
resolved "https://registry.npmmirror.com/vuepress-theme-uni-app-test/-/vuepress-theme-uni-app-test-1.3.19.tgz#fda7eff5dcf4938fc754a9a4bcb150800c97b872" resolved "https://registry.npmmirror.com/vuepress-theme-uni-app-test/-/vuepress-theme-uni-app-test-1.3.20.tgz#e76df157750e0940fce51e41cb4aadfd072fe8c7"
integrity sha512-QeuzPwwvQMg6mtA/ywA+FwdZUVj/RaLd607HauQiJzEGHxOIsEfTINEx1hzrdT+ILwprZ3w3oaB9T8ofnrX92g== integrity sha512-FFEm7H9hWGfpidRSbXbh+T1gAZ1SM7EhE+rw2WuqEHIS/gef7hAfWWCnW+iWEEj6Sh1mM/HuIbgoq8I3je/4PA==
dependencies: dependencies:
"@vuepress/plugin-back-to-top" "^1.9.5" "@vuepress/plugin-back-to-top" "^1.9.5"
"@vuepress/theme-default" "^1.8.2" "@vuepress/theme-default" "^1.8.2"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册