Browse Source

fix docs bug

main
谢亚昕 2 months ago
parent
commit
9a0a3aa769
  1. 74
      packages/.vitepress/getSideBar.ts
  2. 3
      packages/core/src/date/format/docs/index.md
  3. 3
      packages/core/src/date/friendly/docs/index.md
  4. 3
      packages/core/src/date/parse/docs/index.md
  5. 3
      packages/vue3/src/hook/echarts/docs/index.md

74
packages/.vitepress/getSideBar.ts

@ -86,7 +86,7 @@ function side(baseDir: string, options?: Options) {
const filePath = path.resolve(baseDir, item) const filePath = path.resolve(baseDir, item)
let p = filePath + ".md" let p = filePath + ".md"
const { const {
data: { title, first, name }, data: { title, first, name, category },
} = grayMatter(fs.readFileSync(p, "utf8")); } = grayMatter(fs.readFileSync(p, "utf8"));
const [pkg, _name, i] = item.split('/').slice(-3) const [pkg, _name, i] = item.split('/').slice(-3)
@ -97,6 +97,27 @@ function side(baseDir: string, options?: Options) {
if (sidebarItemIndex !== -1) { if (sidebarItemIndex !== -1) {
if (first!=undefined) { if (first!=undefined) {
if(category) {
// @ts-ignore
let ff = sidebars.find(v=>v._category === category)
if(!ff) {
ff = {
text: category,
// @ts-ignore
_sort: 0,
// @ts-ignore
_category: category,
items: []
}
// @ts-ignore
sidebars.push(ff)
}
// @ts-ignore
ff.items.push({
text: _title,
link: '/' + item.replace('index', ''),
});
} else {
sidebars[sidebarItemIndex].items.splice(first,0,{ sidebars[sidebarItemIndex].items.splice(first,0,{
text: _title, text: _title,
link: '/' + item.replace('index', ''), link: '/' + item.replace('index', ''),
@ -104,17 +125,61 @@ function side(baseDir: string, options?: Options) {
if (name) { if (name) {
sidebars[sidebarItemIndex].text = name sidebars[sidebarItemIndex].text = name
} }
}
}else{ }else{
if(category) {
// @ts-ignore
let ff = sidebars.find(v=>v._category === category)
if(!ff) {
ff = {
text: category,
// @ts-ignore
_sort: 0,
// @ts-ignore
_category: category,
items: []
}
// @ts-ignore
sidebars.push(ff)
}
// @ts-ignore
ff.items.push({
text: _title,
link: '/' + item.replace('index', ''),
});
} else {
sidebars[sidebarItemIndex].items.push({ sidebars[sidebarItemIndex].items.push({
text: _title, text: _title,
link: '/' + item.replace('index', ''), link: '/' + item.replace('index', ''),
}); });
} }
}
sidebars[sidebarItemIndex].items.sort((a,b)=>{ sidebars[sidebarItemIndex].items.sort((a,b)=>{
// @ts-ignore // @ts-ignore
return a._sort - b._sort return a._sort - b._sort
}) })
} else { } else {
if(category) {
// @ts-ignore
let ff = sidebars.find(v=>v._category === category)
if(!ff) {
ff = {
text: category,
// @ts-ignore
_sort: -999,
// @ts-ignore
_category: category,
items: []
}
// @ts-ignore
sidebars.push(ff)
}
// @ts-ignore
ff.items.push({
text: _title,
link: '/' + item.replace('index', ''),
});
} else {
sidebars.push({ sidebars.push({
text: name || curDir, text: name || curDir,
// @ts-ignore // @ts-ignore
@ -128,11 +193,16 @@ function side(baseDir: string, options?: Options) {
}); });
} }
} }
sidebars.sort((a,b)=>{
// @ts-ignore
return (a._sort || 0) - (b._sort || 0)
})
}
}) })
sidebars.sort((a,b)=>{ sidebars.sort((a,b)=>{
// @ts-ignore // @ts-ignore
return a._sort - b._sort return b._sort - a._sort
}) })
// const sidebars: Sidebar = []; // const sidebars: Sidebar = [];

3
packages/core/src/date/format/docs/index.md

@ -1,5 +1,6 @@
--- ---
title: 日期->格式化 title: 格式化
category: 日期
--- ---
## Demo ## Demo

3
packages/core/src/date/friendly/docs/index.md

@ -1,5 +1,6 @@
--- ---
title: 日期->美化 title: 美化
category: 日期
--- ---
## Demo ## Demo

3
packages/core/src/date/parse/docs/index.md

@ -1,5 +1,6 @@
--- ---
title: 日期->转化 title: 转化
category: 日期
--- ---
## Demo ## Demo

3
packages/vue3/src/hook/echarts/docs/index.md

@ -1,5 +1,6 @@
--- ---
title: hook->useEchart title: useEchart
category: echart
--- ---
<preview path="./demo.vue" title="@xyx-utils/vue3" description="useEchart"></preview> <preview path="./demo.vue" title="@xyx-utils/vue3" description="useEchart"></preview>

Loading…
Cancel
Save