Skip to content

Commit 39e853f

Browse files
committed
wip: vitepress doc
1 parent 4bcf31f commit 39e853f

37 files changed

+2744
-3131
lines changed

.eslintrc.cjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'@aurorafe/eslint-config-ts',
5+
],
6+
};

.eslintrc.js

-150
This file was deleted.

.prettierrc.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1+
const { prettierRules } = require('@aurorafe/eslint-config-base/rules')
2+
13
module.exports = {
2-
printWidth: 100, // 单行长度
3-
tabWidth: 2, // 缩进长度
4-
useTabs: false, // 使用空格代替tab缩进
5-
semi: true, // 句末使用分号
6-
singleQuote: true, // 单引号
7-
quoteProps: 'as-needed', // 仅在必需时为对象的key添加引号
8-
trailingComma: 'all', // 多行时尽可能打印尾随逗号
9-
arrowParens: 'always', // 单参数箭头函数参数周围使用圆括号-eg: (x) => x
10-
endOfLine: 'lf', // 结束行形式
11-
bracketSpacing: true, // 在对象前后添加空格: { foo: bar }
12-
jsxSingleQuote: false, // jsx中使用单引号
13-
bracketSameLine: false, // 多属性html标签的‘>’折行放置
14-
proseWrap: 'never',
4+
...prettierRules,
155
};

docs/.eslintrc.cjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'@aurorafe/eslint-config-vue',
5+
],
6+
};

docs/.vitepress/config.ts

+43-36
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,23 @@ function nav() {
5454
items: [
5555
{
5656
text: 'Changelog',
57-
link: 'https://github.com/sakitam-fdd/wind-layer/releases'
57+
link: 'https://github.com/sakitam-fdd/wind-layer/releases',
5858
},
5959
{
6060
text: 'Contributing',
61-
link: 'https://github.com/sakitam-fdd/wind-layer/blob/master/.github/contributing.md'
62-
}
63-
]
64-
}
65-
]
61+
link: 'https://github.com/sakitam-fdd/wind-layer/blob/master/.github/contributing.md',
62+
},
63+
],
64+
},
65+
];
6666
}
6767

6868
function sidebarGuide() {
6969
return [
7070
{
7171
text: 'Introduction',
7272
collapsible: true,
73-
items: [
74-
{ text: 'Getting Started', link: '/guide/getting-started' },
75-
]
73+
items: [{ text: 'Getting Started', link: '/guide/getting-started' }],
7674
},
7775
{
7876
text: 'Cookbook',
@@ -88,29 +86,28 @@ function sidebarGuide() {
8886
{ text: 'ol5', link: '/guide/ol5' },
8987
{ text: 'ol3-4', link: '/guide/openlayers' },
9088
{ text: 'amap', link: '/guide/amap' },
91-
{ text: 'bmap', link: '/guide/bmap' }
92-
]
89+
{ text: 'bmap', link: '/guide/bmap' },
90+
],
9391
},
94-
]
92+
];
9593
}
9694

9795
const position = {
9896
false: 'push',
9997
true: 'unshift',
100-
}
98+
};
10199

102100
const renderPermalink = (slug, opts, state, permalink) => {
103101
try {
104-
const tokens = state.tokens
105-
const token = tokens[permalink]
102+
const tokens = state.tokens;
103+
const token = tokens[permalink];
106104
const title = tokens[permalink + 1].children
107105
.filter((token) => token.type === 'text' || token.type === 'code_inline')
108-
.reduce((acc, t) => acc + t.content, '')
109-
const match = /^.+(\s*\{#([a-z0-9\-_]+?)\}\s*)$/.exec(title)
110-
slug = match ? match[2] : slug
111-
token.attrSet('id', slug)
112-
const space = () =>
113-
Object.assign(new state.Token('text', '', 0), { content: ' ' })
106+
.reduce((acc, t) => acc + t.content, '');
107+
const match = /^.+(\s*\{#([a-z0-9\-_]+?)\}\s*)$/.exec(title);
108+
slug = match ? match[2] : slug;
109+
token.attrSet('id', slug);
110+
const space = () => Object.assign(new state.Token('text', '', 0), { content: ' ' });
114111

115112
const linkTokens = [
116113
Object.assign(new state.Token('link_open', 'a', 1), {
@@ -124,16 +121,14 @@ const renderPermalink = (slug, opts, state, permalink) => {
124121
content: opts.permalinkSymbol,
125122
}),
126123
new state.Token('link_close', 'a', -1),
127-
]
124+
];
128125
if (opts.permalinkSpace) {
129126
// @ts-ignore
130-
linkTokens[position[!opts.permalinkBefore]](space())
127+
linkTokens[position[!opts.permalinkBefore]](space());
131128
}
132-
state.tokens[permalink + 1].children[position[opts.permalinkBefore]](
133-
...linkTokens
134-
)
129+
state.tokens[permalink + 1].children[position[opts.permalinkBefore]](...linkTokens);
135130
} catch (e) {}
136-
}
131+
};
137132

138133
function getSidebarItems(dir: string[], currentRoot: string | undefined, root: string | undefined): any[] {
139134
return dir
@@ -145,11 +140,11 @@ function getSidebarItems(dir: string[], currentRoot: string | undefined, root: s
145140
const fileName = e.split('/').pop() ?? '';
146141
return items.length
147142
? {
148-
text: (fileName.charAt(0).toUpperCase() + fileName.slice(1)).replaceAll('-', ' '),
149-
collapsible: true,
150-
collapsed: true,
151-
items,
152-
}
143+
text: (fileName.charAt(0).toUpperCase() + fileName.slice(1)).replaceAll('-', ' '),
144+
collapsible: true,
145+
collapsed: true,
146+
items,
147+
}
153148
: null!;
154149
}
155150
if (e.endsWith('.md') && e[0] !== '_') {
@@ -252,7 +247,7 @@ export default defineConfig({
252247
themeConfig: {
253248
editLink: {
254249
pattern: 'https://github.com/sakitam-fdd/wind-layer/edit/master/docs/:path',
255-
text: '在 Github 编辑此页'
250+
text: '在 Github 编辑此页',
256251
},
257252
nav: nav(),
258253
sidebar: {
@@ -275,7 +270,7 @@ export default defineConfig({
275270
},
276271
footer: {
277272
message: 'Released under the MIT License.',
278-
copyright: 'Copyright © 2022-Present <a href="mailto:[email protected]">sakitam-fdd</a>'
273+
copyright: 'Copyright © 2022-Present <a href="mailto:[email protected]">sakitam-fdd</a>',
279274
},
280275

281276
socialLinks: [
@@ -345,5 +340,17 @@ export default defineConfig({
345340
prev: '上一篇',
346341
next: '下一篇',
347342
},
348-
}
349-
})
343+
},
344+
// async transformHead(context) {
345+
// // ...
346+
//
347+
// console.log(context)
348+
// },
349+
// transformPageData(pageData) {
350+
// pageData.frontmatter.head ??= []
351+
// pageData.frontmatter.head.push([
352+
// 'script',
353+
// { src: '//cdn.jsdelivr.net/npm/maptalks/dist/maptalks.min.js' }
354+
// ])
355+
// },
356+
});

docs/.vitepress/plugins/md.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function getDemoComponent(md: any, env, { title, desc, path, code, ...props }: a
3232
desc="${desc ?? ''}"
3333
importMap="${encodeURIComponent(importMap)}"
3434
>
35-
<${componentName}></${componentName}>
35+
<${componentName}></${componentName}>
3636
</${DemoTag}>
3737
`.trim();
3838
}

docs/.vitepress/theme/index.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
// @ts-nocheck
2+
// import { defineClientComponent } from 'vitepress';
23
import DefaultTheme from 'vitepress/theme';
34
import { SfcPlayground } from '@sakitam-gis/vitepress-playground';
45
import '@sakitam-gis/vitepress-playground/dist/style.css';
56
import './custom.less';
67

7-
// 示例组件
8-
const playgroundModules: Record<string, { default: string }> = import.meta.glob('../../playgrounds/**/*.vue', {
9-
eager: true,
10-
});
11-
128
export default {
139
...DefaultTheme,
1410
enhanceApp({ app, router, siteData }) {
1511
app.component('SfcPlayground', SfcPlayground);
16-
17-
Object.values(playgroundModules).forEach((module) => {
18-
const component = module.default;
19-
app.component(component.name, component);
20-
});
21-
}
22-
};
12+
},
13+
} as any;

docs/package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"type": "module",
55
"scripts": {
66
"dev": "vitepress dev --base /",
7-
"build": "vitepress build --base /wind-layer/",
8-
"serve": "vitepress serve docs"
7+
"build": "vitepress build --base /",
8+
"serve": "vitepress preview"
99
},
1010
"dependencies": {
1111
"@sakitam-gis/vitepress-playground": "^1.1.3",
@@ -33,7 +33,9 @@
3333
"fs-extra": "^11.2.0",
3434
"markdown-it": "^14.0.0",
3535
"markdown-it-container": "^4.0.0",
36-
"vitepress": "^1.0.0-rc.45",
37-
"vue": "^3.3.7"
36+
"vitepress": "^1.0.2",
37+
"vite": "^5.1.3",
38+
"vue": "^3.3.7",
39+
"vite-plugin-external": "^4.3.0"
3840
}
3941
}

0 commit comments

Comments
 (0)