Skip to content

Commit 9b3d842

Browse files
committed
update:update docs
1 parent 4a9a04d commit 9b3d842

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4214
-1464
lines changed

docs/.vitepress/config.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ function sidebarGuide() {
8181
{ text: 'data', link: '/guide/data' },
8282
{ text: 'maptalks', link: '/guide/maptalks' },
8383
{ text: 'mapbox-gl', link: '/guide/mapbox-gl' },
84+
{ text: 'maplibre-gl', link: '/guide/maplibre-gl' },
8485
{ text: 'leaflet', link: '/guide/leaflet' },
8586
{ text: 'ol', link: '/guide/ol' },
86-
{ text: 'ol5', link: '/guide/ol5' },
8787
{ text: 'ol3-4', link: '/guide/openlayers' },
8888
{ text: 'amap', link: '/guide/amap' },
8989
{ text: 'bmap', link: '/guide/bmap' },
@@ -102,7 +102,7 @@ const renderPermalink = (slug, opts, state, permalink) => {
102102
const tokens = state.tokens;
103103
const token = tokens[permalink];
104104
const title = tokens[permalink + 1].children
105-
.filter((token) => token.type === 'text' || token.type === 'code_inline')
105+
.filter((t: any) => t.type === 'text' || t.type === 'code_inline')
106106
.reduce((acc, t) => acc + t.content, '');
107107
const match = /^.+(\s*\{#([a-z0-9\-_]+?)\}\s*)$/.exec(title);
108108
slug = match ? match[2] : slug;
@@ -123,11 +123,13 @@ const renderPermalink = (slug, opts, state, permalink) => {
123123
new state.Token('link_close', 'a', -1),
124124
];
125125
if (opts.permalinkSpace) {
126-
// @ts-ignore
126+
// @ts-ignore ignore error
127127
linkTokens[position[!opts.permalinkBefore]](space());
128128
}
129129
state.tokens[permalink + 1].children[position[opts.permalinkBefore]](...linkTokens);
130-
} catch (e) {}
130+
} catch (e) {
131+
//
132+
}
131133
};
132134

133135
function getSidebarItems(dir: string[], currentRoot: string | undefined, root: string | undefined): any[] {
@@ -140,6 +142,7 @@ function getSidebarItems(dir: string[], currentRoot: string | undefined, root: s
140142
const fileName = e.split('/').pop() ?? '';
141143
return items.length
142144
? {
145+
// @ts-ignore ignore error
143146
text: (fileName.charAt(0).toUpperCase() + fileName.slice(1)).replaceAll('-', ' '),
144147
collapsible: true,
145148
collapsed: true,
@@ -149,6 +152,7 @@ function getSidebarItems(dir: string[], currentRoot: string | undefined, root: s
149152
}
150153
if (e.endsWith('.md') && e[0] !== '_') {
151154
return {
155+
// @ts-ignore ignore error
152156
text: (e.charAt(0).toUpperCase() + e.slice(1)).slice(0, -3).replaceAll('-', ' '),
153157
link: childDir.replace(root ?? '', ''),
154158
};
@@ -164,10 +168,11 @@ function autoSidebar(dirs: string[]): SidebarItem[] {
164168
return getSidebarItems(dirs, root, root);
165169
}
166170

167-
function sidebar(root = '', packagesPath: string) {
171+
function sidebar(root = '', packagesPath = '') {
168172
const index: { [key: string]: { text: string; link: string }[] } = {};
169173
const mds = readFileSync(`${__dirname}/../${packagesPath}/index.md`, 'utf-8').match(/.*.(\n|\r)/g) as string[];
170174
let lastTitle = '';
175+
// eslint-disable-next-line no-restricted-syntax
171176
for (const line of mds) {
172177
if (line.match(/# @/)) continue;
173178
else if (line.match(/##\s\w+/)) {
@@ -193,6 +198,7 @@ function sidebar(root = '', packagesPath: string) {
193198
},
194199
];
195200

201+
// eslint-disable-next-line no-restricted-syntax
196202
for (const i in index) {
197203
s.push({
198204
text: i,
@@ -286,7 +292,7 @@ export default defineConfig({
286292
provider: 'algolia',
287293
options: {
288294
appId: '7HSJME72X5',
289-
apiKey: 'b7a68c2706d9d2053ce96743b17c829b',
295+
apiKey: 'f907bba98e6918b124db4596143784dd',
290296
indexName: 'wind-layer',
291297
searchParameters: {
292298
facetFilters: ['tags:latest'],

docs/.vitepress/plugins/md.ts

+20-23
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const scriptLangTsRE = /<\s*script[^>]*\blang=['"]ts['"][^>]*/;
1010
const scriptSetupRE = /<\s*script[^>]*\bsetup\b[^>]*/;
1111
const scriptClientRE = /<\s*script[^>]*\bclient\b[^>]*/;
1212
let index = 1;
13-
function getDemoComponent(md: any, env, { title, desc, path, code, ...props }: any) {
13+
function getDemoComponent(md: any, env: any, { title, desc, path, code, enableIntersectionObserver, ...props }: any) {
1414
const componentName = `DemoComponent${index++}`;
1515
path = normalizePath(path);
1616
injectImportStatement(env, componentName, path);
@@ -30,6 +30,7 @@ function getDemoComponent(md: any, env, { title, desc, path, code, ...props }: a
3030
src="${path}"
3131
title="${title ?? ''}"
3232
desc="${desc ?? ''}"
33+
enableIntersectionObserver="${enableIntersectionObserver ?? 'true'}"
3334
importMap="${encodeURIComponent(importMap)}"
3435
>
3536
<${componentName}></${componentName}>
@@ -58,39 +59,34 @@ function genDemoByCode(md: any, env: any, path: string, code: string) {
5859
}
5960

6061
function injectImportStatement(env: any, componentName: string, path: string) {
61-
const componentRegistStatement =
62-
`import ${componentName} from '${path}'`.trim()
62+
const componentRegistStatement = `import ${componentName} from '${path}'`.trim();
6363

6464
if (!env?.sfcBlocks?.scripts) {
65-
env.sfcBlocks.scripts = []
65+
env.sfcBlocks.scripts = [];
6666
}
67-
const tags = env.sfcBlocks.scripts as { content: string }[]
67+
const tags = env.sfcBlocks.scripts as { content: string }[];
6868

69-
const isUsingTS = tags.findIndex(tag => scriptLangTsRE.test(tag.content)) > -1
70-
const existingSetupScriptIndex = tags?.findIndex(tag => {
71-
return (
72-
scriptRE.test(tag.content) &&
73-
scriptSetupRE.test(tag.content) &&
74-
!scriptClientRE.test(tag.content)
75-
)
76-
})
69+
const isUsingTS = tags.findIndex((tag) => scriptLangTsRE.test(tag.content)) > -1;
70+
const existingSetupScriptIndex = tags?.findIndex(
71+
(tag) => scriptRE.test(tag.content) && scriptSetupRE.test(tag.content) && !scriptClientRE.test(tag.content),
72+
);
7773

7874
if (existingSetupScriptIndex > -1) {
79-
const tagSrc = tags[existingSetupScriptIndex]
75+
const tagSrc = tags[existingSetupScriptIndex];
8076
tags[existingSetupScriptIndex].content = tagSrc.content.replace(
8177
scriptRE,
8278
`${componentRegistStatement}
8379
8480
</script>`,
85-
)
81+
);
8682
} else {
8783
tags.unshift({
8884
content: `
8985
<script ${isUsingTS ? 'lang="ts"' : ''} setup >
9086
${componentRegistStatement}
9187
</script>
9288
`.trim(),
93-
})
89+
});
9490
}
9591
}
9692

@@ -102,7 +98,7 @@ function demoBlockPlugin(md: any) {
10298
const addRenderRule = (type: string) => {
10399
const defaultRender = md.renderer.rules[type];
104100

105-
md.renderer.rules[type] = (tokens: any, idx: string, options, env, ...args: any[]) => {
101+
md.renderer.rules[type] = (tokens: any, idx: string, options: any, env: any, ...args: any[]) => {
106102
const token = tokens[idx];
107103
const content = token.content.trim();
108104
if (!content.startsWith(`<${DemoTag} `)) {
@@ -117,7 +113,7 @@ function demoBlockPlugin(md: any) {
117113
return defaultRender(tokens, idx, options, env, ...args);
118114
}
119115

120-
const frontmatter = env.frontmatter
116+
const frontmatter = env.frontmatter;
121117

122118
const mdDir = dirname(frontmatter.realPath ?? path);
123119
const srcPath = resolve(mdDir, props.src);
@@ -127,13 +123,14 @@ function demoBlockPlugin(md: any) {
127123
title: props.title,
128124
desc: props.desc,
129125
path: srcPath,
126+
enableIntersectionObserver: props.enableIntersectionObserver,
130127
code,
131128
});
132129
};
133-
}
130+
};
134131

135-
addRenderRule('html_block')
136-
addRenderRule('html_inline')
132+
addRenderRule('html_block');
133+
addRenderRule('html_inline');
137134
}
138135

139136
function getPropsMap(attrs: any) {
@@ -147,14 +144,14 @@ function getPropsMap(attrs: any) {
147144

148145
export function parseProps(content: string) {
149146
const ast = baseParse(content);
150-
const demoElement = ast.children[0];
147+
const demoElement = ast.children[0] as any;
151148

152149
return getPropsMap(demoElement.props as any[]);
153150
}
154151

155152
function fencePlugin(md: any) {
156153
const defaultRender = md.renderer.rules.fence;
157-
md.renderer.rules.fence = (tokens: any, idx: number, options, env, ...args: any[]) => {
154+
md.renderer.rules.fence = (tokens: any, idx: number, options: any, env: any, ...args: any[]) => {
158155
const token = tokens[idx];
159156
if (token.info.trim() !== FenceDemoTag) {
160157
return defaultRender(tokens, idx, options, env, ...args);

docs/.vitepress/theme/custom.less

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
:root {
22
--vp-layout-max-width: 1920px;
3+
--tp-base-background-color: hsla(0, 0%, 10%, 0.8);
34
scroll-behavior: smooth;
45
}
56

docs/.vitepress/theme/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-nocheck
21
// import { defineClientComponent } from 'vitepress';
32
import DefaultTheme from 'vitepress/theme';
43
import { SfcPlayground } from '@sakitam-gis/vitepress-playground';

docs/api/.nojekyll

-1
This file was deleted.

docs/components/leaflet.vue

-100
This file was deleted.

0 commit comments

Comments
 (0)