vitepress 0.21.2 → 0.21.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/app/data.js +2 -1
- package/dist/client/app/router.js +11 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/shared.js +1 -0
- package/dist/node/cli.js +1 -1
- package/dist/node/index.d.ts +6 -0
- package/dist/node/index.js +1 -1
- package/dist/node/{serve-3fb9b386.js → serve-9874c5ac.js} +281 -114
- package/package.json +50 -42
- package/theme.d.ts +9 -0
- package/types/shared.d.ts +1 -0
- package/dist/vitepress.d.ts +0 -311
package/dist/client/app/data.js
CHANGED
|
@@ -5,7 +5,8 @@ import { withBase } from './utils';
|
|
|
5
5
|
export const dataSymbol = Symbol();
|
|
6
6
|
export const siteDataRef = shallowRef(parse(serializedSiteData));
|
|
7
7
|
function parse(data) {
|
|
8
|
-
|
|
8
|
+
const parsed = JSON.parse(data);
|
|
9
|
+
return (import.meta.env.DEV ? readonly(parsed) : parsed);
|
|
9
10
|
}
|
|
10
11
|
// hmr
|
|
11
12
|
if (import.meta.hot) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { reactive, inject, markRaw, nextTick, readonly } from 'vue';
|
|
2
2
|
import { inBrowser } from './utils';
|
|
3
|
+
import { siteDataRef } from './data';
|
|
3
4
|
export const RouterSymbol = Symbol();
|
|
4
5
|
// we are just using URL to parse the pathname and hash - the base doesn't
|
|
5
6
|
// matter and is only passed to support same-host hrefs.
|
|
@@ -148,7 +149,16 @@ function scrollTo(el, hash, smooth = false) {
|
|
|
148
149
|
console.warn(e);
|
|
149
150
|
}
|
|
150
151
|
if (target) {
|
|
151
|
-
|
|
152
|
+
let offset = siteDataRef.value.scrollOffset;
|
|
153
|
+
if (typeof offset === 'string') {
|
|
154
|
+
offset =
|
|
155
|
+
document.querySelector(offset).getBoundingClientRect().bottom + 24;
|
|
156
|
+
}
|
|
157
|
+
const targetPadding = parseInt(window.getComputedStyle(target).paddingTop, 10);
|
|
158
|
+
const targetTop = window.scrollY +
|
|
159
|
+
target.getBoundingClientRect().top -
|
|
160
|
+
offset +
|
|
161
|
+
targetPadding;
|
|
152
162
|
// only smooth scroll if distance is smaller than screen height.
|
|
153
163
|
if (!smooth || Math.abs(targetTop - window.scrollY) > window.innerHeight) {
|
|
154
164
|
window.scrollTo(0, targetTop);
|
package/dist/client/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ComponentOptions } from 'vue';
|
|
|
6
6
|
import { ComponentOptionsMixin } from 'vue';
|
|
7
7
|
import { DefineComponent } from 'vue';
|
|
8
8
|
import { EmitsOptions } from 'vue';
|
|
9
|
+
import { ExtractPropTypes } from 'vue';
|
|
9
10
|
import { Ref } from 'vue';
|
|
10
11
|
import { RendererElement } from 'vue';
|
|
11
12
|
import { RendererNode } from 'vue';
|
|
@@ -14,7 +15,7 @@ import { VNodeProps } from 'vue';
|
|
|
14
15
|
|
|
15
16
|
export declare const Content: DefineComponent< {}, () => VNode<RendererNode, RendererElement, {
|
|
16
17
|
[key: string]: any;
|
|
17
|
-
}>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<{}
|
|
18
|
+
}>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes< {}>>, {}>;
|
|
18
19
|
|
|
19
20
|
export declare const Debug: ComponentOptions<{}, any, any, any, any, any, any, any>;
|
|
20
21
|
|
|
@@ -76,6 +77,7 @@ export declare interface SiteData<ThemeConfig = any> {
|
|
|
76
77
|
description: string
|
|
77
78
|
head: HeadConfig[]
|
|
78
79
|
themeConfig: ThemeConfig
|
|
80
|
+
scrollOffset: number | string
|
|
79
81
|
locales: Record<string, LocaleConfig>
|
|
80
82
|
/**
|
|
81
83
|
* Available locales for the site when it has defined `locales` in its
|
package/dist/client/shared.js
CHANGED
package/dist/node/cli.js
CHANGED
package/dist/node/index.d.ts
CHANGED
|
@@ -256,6 +256,7 @@ export declare interface SiteData<ThemeConfig = any> {
|
|
|
256
256
|
description: string
|
|
257
257
|
head: HeadConfig[]
|
|
258
258
|
themeConfig: ThemeConfig
|
|
259
|
+
scrollOffset: number | string
|
|
259
260
|
locales: Record<string, LocaleConfig>
|
|
260
261
|
/**
|
|
261
262
|
* Available locales for the site when it has defined `locales` in its
|
|
@@ -301,6 +302,11 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
301
302
|
srcExclude?: string[];
|
|
302
303
|
outDir?: string;
|
|
303
304
|
shouldPreload?: (link: string, page: string) => boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Configure the scroll offset when the theme has a sticky header.
|
|
307
|
+
* Can be a number or a selector element to get the offset from.
|
|
308
|
+
*/
|
|
309
|
+
scrollOffset?: number | string;
|
|
304
310
|
/**
|
|
305
311
|
* Enable MPA / zero-JS mode
|
|
306
312
|
* @experimental
|
package/dist/node/index.js
CHANGED
|
@@ -12302,16 +12302,23 @@ function cleanRoute(siteData, route) {
|
|
|
12302
12302
|
const PKG_ROOT = path__default["default"].join(__dirname, "../../");
|
|
12303
12303
|
const DIST_CLIENT_PATH = path__default["default"].join(__dirname, "../client");
|
|
12304
12304
|
const APP_PATH = path__default["default"].join(DIST_CLIENT_PATH, "app");
|
|
12305
|
-
|
|
12305
|
+
path__default["default"].join(DIST_CLIENT_PATH, "shared");
|
|
12306
12306
|
const DEFAULT_THEME_PATH = path__default["default"].join(DIST_CLIENT_PATH, "theme-default");
|
|
12307
12307
|
const SITE_DATA_ID = "@siteData";
|
|
12308
12308
|
const SITE_DATA_REQUEST_PATH = "/" + SITE_DATA_ID;
|
|
12309
|
-
|
|
12309
|
+
const vueRuntimePath = "vue/dist/vue.runtime.esm-bundler.js";
|
|
12310
|
+
function resolveAliases(root, themeDir) {
|
|
12310
12311
|
const paths = {
|
|
12311
12312
|
"/@theme": themeDir,
|
|
12312
|
-
"
|
|
12313
|
+
"@theme": themeDir,
|
|
12313
12314
|
[SITE_DATA_ID]: SITE_DATA_REQUEST_PATH
|
|
12314
12315
|
};
|
|
12316
|
+
let vuePath;
|
|
12317
|
+
try {
|
|
12318
|
+
vuePath = require.resolve(vueRuntimePath, { paths: [root] });
|
|
12319
|
+
} catch (e) {
|
|
12320
|
+
vuePath = require.resolve(vueRuntimePath);
|
|
12321
|
+
}
|
|
12315
12322
|
const aliases = [
|
|
12316
12323
|
...Object.keys(paths).map((p) => ({
|
|
12317
12324
|
find: p,
|
|
@@ -12328,7 +12335,7 @@ function resolveAliases(themeDir) {
|
|
|
12328
12335
|
{ find: /^vitepress\//, replacement: PKG_ROOT + "/" },
|
|
12329
12336
|
{
|
|
12330
12337
|
find: /^vue$/,
|
|
12331
|
-
replacement:
|
|
12338
|
+
replacement: vuePath
|
|
12332
12339
|
}
|
|
12333
12340
|
];
|
|
12334
12341
|
return aliases;
|
|
@@ -13373,7 +13380,7 @@ async function resolveConfig(root = process.cwd(), command = "serve", mode = "de
|
|
|
13373
13380
|
outDir,
|
|
13374
13381
|
tempDir: resolve(root, ".temp"),
|
|
13375
13382
|
markdown: userConfig.markdown,
|
|
13376
|
-
alias: resolveAliases(themeDir),
|
|
13383
|
+
alias: resolveAliases(root, themeDir),
|
|
13377
13384
|
vue: userConfig.vue,
|
|
13378
13385
|
vite: userConfig.vite,
|
|
13379
13386
|
shouldPreload: userConfig.shouldPreload,
|
|
@@ -13448,7 +13455,8 @@ async function resolveSiteData(root, userConfig, command = "serve", mode = "deve
|
|
|
13448
13455
|
head: userConfig.head || [],
|
|
13449
13456
|
themeConfig: userConfig.themeConfig || {},
|
|
13450
13457
|
locales: userConfig.locales || {},
|
|
13451
|
-
langs: createLangDictionary(userConfig)
|
|
13458
|
+
langs: createLangDictionary(userConfig),
|
|
13459
|
+
scrollOffset: userConfig.scrollOffset || 90
|
|
13452
13460
|
};
|
|
13453
13461
|
}
|
|
13454
13462
|
|
|
@@ -24501,7 +24509,7 @@ Renderer$1.prototype.renderToken = function renderToken(tokens, idx, options) {
|
|
|
24501
24509
|
|
|
24502
24510
|
/**
|
|
24503
24511
|
* Renderer.renderInline(tokens, options, env) -> String
|
|
24504
|
-
* - tokens (Array): list on block tokens to
|
|
24512
|
+
* - tokens (Array): list on block tokens to render
|
|
24505
24513
|
* - options (Object): params of parser instance
|
|
24506
24514
|
* - env (Object): additional data from parsed input (references, for example)
|
|
24507
24515
|
*
|
|
@@ -24528,7 +24536,7 @@ Renderer$1.prototype.renderInline = function (tokens, options, env) {
|
|
|
24528
24536
|
|
|
24529
24537
|
/** internal
|
|
24530
24538
|
* Renderer.renderInlineAsText(tokens, options, env) -> String
|
|
24531
|
-
* - tokens (Array): list on block tokens to
|
|
24539
|
+
* - tokens (Array): list on block tokens to render
|
|
24532
24540
|
* - options (Object): params of parser instance
|
|
24533
24541
|
* - env (Object): additional data from parsed input (references, for example)
|
|
24534
24542
|
*
|
|
@@ -24555,7 +24563,7 @@ Renderer$1.prototype.renderInlineAsText = function (tokens, options, env) {
|
|
|
24555
24563
|
|
|
24556
24564
|
/**
|
|
24557
24565
|
* Renderer.render(tokens, options, env) -> String
|
|
24558
|
-
* - tokens (Array): list on block tokens to
|
|
24566
|
+
* - tokens (Array): list on block tokens to render
|
|
24559
24567
|
* - options (Object): params of parser instance
|
|
24560
24568
|
* - env (Object): additional data from parsed input (references, for example)
|
|
24561
24569
|
*
|
|
@@ -26485,7 +26493,7 @@ var list$1 = function list(state, startLine, endLine, silent) {
|
|
|
26485
26493
|
// This code can fail if plugins use blkIndent as well as lists,
|
|
26486
26494
|
// but I hope the spec gets fixed long before that happens.
|
|
26487
26495
|
//
|
|
26488
|
-
if (state.
|
|
26496
|
+
if (state.sCount[startLine] >= state.blkIndent) {
|
|
26489
26497
|
isTerminatingParagraph = true;
|
|
26490
26498
|
}
|
|
26491
26499
|
}
|
|
@@ -27637,7 +27645,7 @@ var isSpace$3 = utils$3.isSpace;
|
|
|
27637
27645
|
|
|
27638
27646
|
|
|
27639
27647
|
var newline = function newline(state, silent) {
|
|
27640
|
-
var pmax, max, pos = state.pos;
|
|
27648
|
+
var pmax, max, ws, pos = state.pos;
|
|
27641
27649
|
|
|
27642
27650
|
if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }
|
|
27643
27651
|
|
|
@@ -27651,7 +27659,11 @@ var newline = function newline(state, silent) {
|
|
|
27651
27659
|
if (!silent) {
|
|
27652
27660
|
if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {
|
|
27653
27661
|
if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {
|
|
27654
|
-
|
|
27662
|
+
// Find whitespaces tail of pending chars.
|
|
27663
|
+
ws = pmax - 1;
|
|
27664
|
+
while (ws >= 1 && state.pending.charCodeAt(ws - 1) === 0x20) ws--;
|
|
27665
|
+
|
|
27666
|
+
state.pending = state.pending.slice(0, ws);
|
|
27655
27667
|
state.push('hardbreak', 'br', 0);
|
|
27656
27668
|
} else {
|
|
27657
27669
|
state.pending = state.pending.slice(0, -1);
|
|
@@ -27812,7 +27824,6 @@ strikethrough.tokenize = function strikethrough(state, silent) {
|
|
|
27812
27824
|
state.delimiters.push({
|
|
27813
27825
|
marker: marker,
|
|
27814
27826
|
length: 0, // disable "rule of 3" length checks meant for emphasis
|
|
27815
|
-
jump: i / 2, // for `~~` 1 marker = 2 characters
|
|
27816
27827
|
token: state.tokens.length - 1,
|
|
27817
27828
|
end: -1,
|
|
27818
27829
|
open: scanned.can_open,
|
|
@@ -27937,15 +27948,6 @@ emphasis.tokenize = function emphasis(state, silent) {
|
|
|
27937
27948
|
//
|
|
27938
27949
|
length: scanned.length,
|
|
27939
27950
|
|
|
27940
|
-
// An amount of characters before this one that's equivalent to
|
|
27941
|
-
// current one. In plain English: if this delimiter does not open
|
|
27942
|
-
// an emphasis, neither do previous `jump` characters.
|
|
27943
|
-
//
|
|
27944
|
-
// Used to skip sequences like "*****" in one step, for 1st asterisk
|
|
27945
|
-
// value will be 0, for 2nd it's 1 and so on.
|
|
27946
|
-
//
|
|
27947
|
-
jump: i,
|
|
27948
|
-
|
|
27949
27951
|
// A position of the token this delimiter corresponds to.
|
|
27950
27952
|
//
|
|
27951
27953
|
token: state.tokens.length - 1,
|
|
@@ -27999,9 +28001,11 @@ function postProcess(state, delimiters) {
|
|
|
27999
28001
|
//
|
|
28000
28002
|
isStrong = i > 0 &&
|
|
28001
28003
|
delimiters[i - 1].end === startDelim.end + 1 &&
|
|
28004
|
+
// check that first two markers match and adjacent
|
|
28005
|
+
delimiters[i - 1].marker === startDelim.marker &&
|
|
28002
28006
|
delimiters[i - 1].token === startDelim.token - 1 &&
|
|
28003
|
-
|
|
28004
|
-
delimiters[
|
|
28007
|
+
// check that last two markers are adjacent (we can safely assume they match)
|
|
28008
|
+
delimiters[startDelim.end + 1].token === endDelim.token + 1;
|
|
28005
28009
|
|
|
28006
28010
|
ch = String.fromCharCode(startDelim.marker);
|
|
28007
28011
|
|
|
@@ -28504,9 +28508,28 @@ function processDelimiters(state, delimiters) {
|
|
|
28504
28508
|
openersBottom = {},
|
|
28505
28509
|
max = delimiters.length;
|
|
28506
28510
|
|
|
28511
|
+
if (!max) return;
|
|
28512
|
+
|
|
28513
|
+
// headerIdx is the first delimiter of the current (where closer is) delimiter run
|
|
28514
|
+
var headerIdx = 0;
|
|
28515
|
+
var lastTokenIdx = -2; // needs any value lower than -1
|
|
28516
|
+
var jumps = [];
|
|
28517
|
+
|
|
28507
28518
|
for (closerIdx = 0; closerIdx < max; closerIdx++) {
|
|
28508
28519
|
closer = delimiters[closerIdx];
|
|
28509
28520
|
|
|
28521
|
+
jumps.push(0);
|
|
28522
|
+
|
|
28523
|
+
// markers belong to same delimiter run if:
|
|
28524
|
+
// - they have adjacent tokens
|
|
28525
|
+
// - AND markers are the same
|
|
28526
|
+
//
|
|
28527
|
+
if (delimiters[headerIdx].marker !== closer.marker || lastTokenIdx !== closer.token - 1) {
|
|
28528
|
+
headerIdx = closerIdx;
|
|
28529
|
+
}
|
|
28530
|
+
|
|
28531
|
+
lastTokenIdx = closer.token;
|
|
28532
|
+
|
|
28510
28533
|
// Length is only used for emphasis-specific "rule of 3",
|
|
28511
28534
|
// if it's not defined (in strikethrough or 3rd party plugins),
|
|
28512
28535
|
// we can default it to 0 to disable those checks.
|
|
@@ -28525,14 +28548,11 @@ function processDelimiters(state, delimiters) {
|
|
|
28525
28548
|
|
|
28526
28549
|
minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)];
|
|
28527
28550
|
|
|
28528
|
-
openerIdx =
|
|
28529
|
-
|
|
28530
|
-
// avoid crash if `closer.jump` is pointing outside of the array, see #742
|
|
28531
|
-
if (openerIdx < -1) openerIdx = -1;
|
|
28551
|
+
openerIdx = headerIdx - jumps[headerIdx] - 1;
|
|
28532
28552
|
|
|
28533
28553
|
newMinOpenerIdx = openerIdx;
|
|
28534
28554
|
|
|
28535
|
-
for (; openerIdx > minOpenerIdx; openerIdx -=
|
|
28555
|
+
for (; openerIdx > minOpenerIdx; openerIdx -= jumps[openerIdx] + 1) {
|
|
28536
28556
|
opener = delimiters[openerIdx];
|
|
28537
28557
|
|
|
28538
28558
|
if (opener.marker !== closer.marker) continue;
|
|
@@ -28562,15 +28582,19 @@ function processDelimiters(state, delimiters) {
|
|
|
28562
28582
|
// sure algorithm has linear complexity (see *_*_*_*_*_... case).
|
|
28563
28583
|
//
|
|
28564
28584
|
lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ?
|
|
28565
|
-
|
|
28585
|
+
jumps[openerIdx - 1] + 1 :
|
|
28566
28586
|
0;
|
|
28567
28587
|
|
|
28568
|
-
|
|
28588
|
+
jumps[closerIdx] = closerIdx - openerIdx + lastJump;
|
|
28589
|
+
jumps[openerIdx] = lastJump;
|
|
28590
|
+
|
|
28569
28591
|
closer.open = false;
|
|
28570
28592
|
opener.end = closerIdx;
|
|
28571
|
-
opener.jump = lastJump;
|
|
28572
28593
|
opener.close = false;
|
|
28573
28594
|
newMinOpenerIdx = -1;
|
|
28595
|
+
// treat next token as start of run,
|
|
28596
|
+
// it optimizes skips in **<...>**a**<...>** pathological case
|
|
28597
|
+
lastTokenIdx = -2;
|
|
28574
28598
|
break;
|
|
28575
28599
|
}
|
|
28576
28600
|
}
|
|
@@ -35144,7 +35168,7 @@ const headingPlugin = (md, include = ["h2", "h3"]) => {
|
|
|
35144
35168
|
};
|
|
35145
35169
|
};
|
|
35146
35170
|
|
|
35147
|
-
var e=!1,n={false:"push",true:"unshift",after:"push",before:"unshift"},t={isPermalinkSymbol:!0};function r(r,a,i,l){var o;if(!e){var c="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";"object"==typeof process&&process&&process.emitWarning?process.emitWarning(c):console.warn(c),e=!0;}var s=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(a.permalinkClass?[["class",a.permalinkClass]]:[],[["href",a.permalinkHref(r,i)]],Object.entries(a.permalinkAttrs(r,i)))}),Object.assign(new i.Token("html_block","",0),{content:a.permalinkSymbol,meta:t}),new i.Token("link_close","a",-1)];a.permalinkSpace&&i.tokens[l+1].children[n[a.permalinkBefore]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[l+1].children)[n[a.permalinkBefore]].apply(o,s);}function a(e){return "#"+e}function i(e){return {}}var l={class:"header-anchor",symbol:"#",renderHref:a,renderAttrs:i};function o(e){function n(t){return t=Object.assign({},n.defaults,t),function(n,r,a,i){return e(n,t,r,a,i)}}return n.defaults=Object.assign({},l),n.renderPermalinkImpl=e,n}var c=o(function(e,r,a,i,l){var o,c=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(r.class?[["class",r.class]]:[],[["href",r.renderHref(e,i)]],r.ariaHidden?[["aria-hidden","true"]]:[],Object.entries(r.renderAttrs(e,i)))}),Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t}),new i.Token("link_close","a",-1)];r.space&&i.tokens[l+1].children[n[r.placement]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[l+1].children)[n[r.placement]].apply(o,c);});Object.assign(c.defaults,{space:!0,placement:"after",ariaHidden:!1});var s$1=o(c.renderPermalinkImpl);s$1.defaults=Object.assign({},c.defaults,{ariaHidden:!0});var d$1=o(function(e,n,t,r,a){var i=[Object.assign(new r.Token("link_open","a",1),{attrs:[].concat(n.class?[["class",n.class]]:[],[["href",n.renderHref(e,r)]],Object.entries(n.renderAttrs(e,r)))})].concat(r.tokens[a+1].children,[new r.Token("link_close","a",-1)]);r.tokens[a+1]=Object.assign(new r.Token("inline","",0),{children:i});}),u=o(function(e,r,a,i,l){var o;if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(r.style))throw new Error("`permalink.linkAfterHeader` called with unknown style option `"+r.style+"`");if(!["aria-describedby","aria-labelledby"].includes(r.style)&&!r.assistiveText)throw new Error("`permalink.linkAfterHeader` called without the `assistiveText` option in `"+r.style+"` style");if("visually-hidden"===r.style&&!r.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");var c=i.tokens[l+1].children.filter(function(e){return "text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),s=[],d=[];r.class&&d.push(["class",r.class]),d.push(["href",r.renderHref(e,i)]),d.push.apply(d,Object.entries(r.renderAttrs(e,i))),"visually-hidden"===r.style?(s.push(Object.assign(new i.Token("span_open","span",1),{attrs:[["class",r.visuallyHiddenClass]]}),Object.assign(new i.Token("text","",0),{content:r.assistiveText(c)}),new i.Token("span_close","span",-1)),r.space&&s[n[r.placement]](Object.assign(new i.Token("text","",0),{content:" "})),s[n[r.placement]](Object.assign(new i.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t}),new i.Token("span_close","span",-1))):s.push(Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t})),"aria-label"===r.style?d.push(["aria-label",r.assistiveText(c)]):["aria-describedby","aria-labelledby"].includes(r.style)&&d.push([r.style,e]);var u=[Object.assign(new i.Token("link_open","a",1),{attrs:d})].concat(s,[new i.Token("link_close","a",-1)]);(o=i.tokens).splice.apply(o,[l+3,0].concat(u));});function f(e,n,t,r){var a=e,i=r;if(t&&Object.prototype.hasOwnProperty.call(n,a))throw new Error("User defined `id` attribute `"+e+"` is not unique. Please fix it in your Markdown to continue.");for(;Object.prototype.hasOwnProperty.call(n,a);)a=e+"-"+i,i+=1;return n[a]=!0,a}function b(e,n){n=Object.assign({},b.defaults,n),e.core.ruler.push("anchor",function(e){for(var t,a={},i=e.tokens,l=Array.isArray(n.level)?(t=n.level,function(e){return t.includes(e)}):function(e){return function(n){return n>=e}}(n.level),o=0;o<i.length;o++){var c=i[o];if("heading_open"===c.type&&l(Number(c.tag.substr(1)))){var s=i[o+1].children.filter(function(e){return "text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),d=c.attrGet("id");d=null==d?f(n.slugify(s),a,!1,n.uniqueSlugStartIndex):f(d,a,!0,n.uniqueSlugStartIndex),c.attrSet("id",d),!1!==n.tabIndex&&c.attrSet("tabindex",""+n.tabIndex),"function"==typeof n.permalink?n.permalink(d,n,e,o):(n.permalink||n.renderPermalink&&n.renderPermalink!==r)&&n.renderPermalink(d,n,e,o),o=i.indexOf(c),n.callback&&n.callback(c,{slug:d,title:s});}}});}Object.assign(u.defaults,{style:"visually-hidden",space:!0,placement:"after"}),b.permalink={__proto__:null,legacy:r,renderHref:a,renderAttrs:i,makePermalink:o,linkInsideHeader:c,ariaHidden:s$1,headerLink:d$1,linkAfterHeader:u},b.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:r,permalinkClass:s$1.defaults.class,permalinkSpace:s$1.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===s$1.defaults.placement,permalinkHref:s$1.defaults.renderHref,permalinkAttrs:s$1.defaults.renderAttrs},b.default=b;
|
|
35171
|
+
var e=!1,n={false:"push",true:"unshift",after:"push",before:"unshift"},t={isPermalinkSymbol:!0};function r(r,a,i,l){var o;if(!e){var c="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";"object"==typeof process&&process&&process.emitWarning?process.emitWarning(c):console.warn(c),e=!0;}var s=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(a.permalinkClass?[["class",a.permalinkClass]]:[],[["href",a.permalinkHref(r,i)]],Object.entries(a.permalinkAttrs(r,i)))}),Object.assign(new i.Token("html_block","",0),{content:a.permalinkSymbol,meta:t}),new i.Token("link_close","a",-1)];a.permalinkSpace&&i.tokens[l+1].children[n[a.permalinkBefore]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[l+1].children)[n[a.permalinkBefore]].apply(o,s);}function a(e){return "#"+e}function i(e){return {}}var l={class:"header-anchor",symbol:"#",renderHref:a,renderAttrs:i};function o(e){function n(t){return t=Object.assign({},n.defaults,t),function(n,r,a,i){return e(n,t,r,a,i)}}return n.defaults=Object.assign({},l),n.renderPermalinkImpl=e,n}var c=o(function(e,r,a,i,l){var o,c=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(r.class?[["class",r.class]]:[],[["href",r.renderHref(e,i)]],r.ariaHidden?[["aria-hidden","true"]]:[],Object.entries(r.renderAttrs(e,i)))}),Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t}),new i.Token("link_close","a",-1)];r.space&&i.tokens[l+1].children[n[r.placement]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[l+1].children)[n[r.placement]].apply(o,c);});Object.assign(c.defaults,{space:!0,placement:"after",ariaHidden:!1});var s$1=o(c.renderPermalinkImpl);s$1.defaults=Object.assign({},c.defaults,{ariaHidden:!0});var d$1=o(function(e,n,t,r,a){var i=[Object.assign(new r.Token("link_open","a",1),{attrs:[].concat(n.class?[["class",n.class]]:[],[["href",n.renderHref(e,r)]],Object.entries(n.renderAttrs(e,r)))})].concat(n.safariReaderFix?[new r.Token("span_open","span",1)]:[],r.tokens[a+1].children,n.safariReaderFix?[new r.Token("span_close","span",-1)]:[],[new r.Token("link_close","a",-1)]);r.tokens[a+1]=Object.assign(new r.Token("inline","",0),{children:i});});Object.assign(d$1.defaults,{safariReaderFix:!1});var u=o(function(e,r,a,i,l){var o;if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(r.style))throw new Error("`permalink.linkAfterHeader` called with unknown style option `"+r.style+"`");if(!["aria-describedby","aria-labelledby"].includes(r.style)&&!r.assistiveText)throw new Error("`permalink.linkAfterHeader` called without the `assistiveText` option in `"+r.style+"` style");if("visually-hidden"===r.style&&!r.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");var c=i.tokens[l+1].children.filter(function(e){return "text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),s=[],d=[];r.class&&d.push(["class",r.class]),d.push(["href",r.renderHref(e,i)]),d.push.apply(d,Object.entries(r.renderAttrs(e,i))),"visually-hidden"===r.style?(s.push(Object.assign(new i.Token("span_open","span",1),{attrs:[["class",r.visuallyHiddenClass]]}),Object.assign(new i.Token("text","",0),{content:r.assistiveText(c)}),new i.Token("span_close","span",-1)),r.space&&s[n[r.placement]](Object.assign(new i.Token("text","",0),{content:" "})),s[n[r.placement]](Object.assign(new i.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t}),new i.Token("span_close","span",-1))):s.push(Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t})),"aria-label"===r.style?d.push(["aria-label",r.assistiveText(c)]):["aria-describedby","aria-labelledby"].includes(r.style)&&d.push([r.style,e]);var u=[Object.assign(new i.Token("link_open","a",1),{attrs:d})].concat(s,[new i.Token("link_close","a",-1)]);(o=i.tokens).splice.apply(o,[l+3,0].concat(u));});function f(e,n,t,r){var a=e,i=r;if(t&&Object.prototype.hasOwnProperty.call(n,a))throw new Error("User defined `id` attribute `"+e+"` is not unique. Please fix it in your Markdown to continue.");for(;Object.prototype.hasOwnProperty.call(n,a);)a=e+"-"+i,i+=1;return n[a]=!0,a}function b(e,n){n=Object.assign({},b.defaults,n),e.core.ruler.push("anchor",function(e){for(var t,a={},i=e.tokens,l=Array.isArray(n.level)?(t=n.level,function(e){return t.includes(e)}):function(e){return function(n){return n>=e}}(n.level),o=0;o<i.length;o++){var c=i[o];if("heading_open"===c.type&&l(Number(c.tag.substr(1)))){var s=i[o+1].children.filter(function(e){return "text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),d=c.attrGet("id");d=null==d?f(n.slugify(s),a,!1,n.uniqueSlugStartIndex):f(d,a,!0,n.uniqueSlugStartIndex),c.attrSet("id",d),!1!==n.tabIndex&&c.attrSet("tabindex",""+n.tabIndex),"function"==typeof n.permalink?n.permalink(d,n,e,o):(n.permalink||n.renderPermalink&&n.renderPermalink!==r)&&n.renderPermalink(d,n,e,o),o=i.indexOf(c),n.callback&&n.callback(c,{slug:d,title:s});}}});}Object.assign(u.defaults,{style:"visually-hidden",space:!0,placement:"after"}),b.permalink={__proto__:null,legacy:r,renderHref:a,renderAttrs:i,makePermalink:o,linkInsideHeader:c,ariaHidden:s$1,headerLink:d$1,linkAfterHeader:u},b.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:r,permalinkClass:s$1.defaults.class,permalinkSpace:s$1.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===s$1.defaults.placement,permalinkHref:s$1.defaults.renderHref,permalinkAttrs:s$1.defaults.renderAttrs},b.default=b;
|
|
35148
35172
|
|
|
35149
35173
|
var utils$1 = {};
|
|
35150
35174
|
|
|
@@ -35720,7 +35744,8 @@ var patterns = options => {
|
|
|
35720
35744
|
token.nesting = 0;
|
|
35721
35745
|
let content = tokens[i + 1].content;
|
|
35722
35746
|
let start = content.lastIndexOf(options.leftDelimiter);
|
|
35723
|
-
|
|
35747
|
+
let attrs = utils.getAttrs(content, start, options);
|
|
35748
|
+
utils.addAttrs(attrs, token);
|
|
35724
35749
|
token.markup = content;
|
|
35725
35750
|
tokens.splice(i + 1, 2);
|
|
35726
35751
|
}
|
|
@@ -35737,7 +35762,7 @@ var patterns = options => {
|
|
|
35737
35762
|
{
|
|
35738
35763
|
position: -1,
|
|
35739
35764
|
content: utils.hasDelimiters('end', options),
|
|
35740
|
-
type: (t) => t !== 'code_inline'
|
|
35765
|
+
type: (t) => t !== 'code_inline' && t !== 'math_inline'
|
|
35741
35766
|
}
|
|
35742
35767
|
]
|
|
35743
35768
|
}
|
|
@@ -35820,6 +35845,12 @@ function test(tokens, i, t) {
|
|
|
35820
35845
|
let ii = t.shift !== undefined
|
|
35821
35846
|
? i + t.shift
|
|
35822
35847
|
: t.position;
|
|
35848
|
+
|
|
35849
|
+
if (t.shift !== undefined && ii < 0) {
|
|
35850
|
+
// we should never shift to negative indexes (rolling around to back of array)
|
|
35851
|
+
return res;
|
|
35852
|
+
}
|
|
35853
|
+
|
|
35823
35854
|
let token = get(tokens, ii); // supports negative ii
|
|
35824
35855
|
|
|
35825
35856
|
|
|
@@ -36122,16 +36153,25 @@ var markdownItEmoji = function emoji_plugin(md, options) {
|
|
|
36122
36153
|
bare_emoji_plugin(md, opts);
|
|
36123
36154
|
};
|
|
36124
36155
|
|
|
36125
|
-
|
|
36126
|
-
|
|
36156
|
+
/*
|
|
36157
|
+
* markdown-it-table-of-contents
|
|
36158
|
+
*
|
|
36159
|
+
* The algorithm works as follows:
|
|
36160
|
+
* Step 1: Gather all headline tokens from a Markdown document and put them in an array.
|
|
36161
|
+
* Step 2: Turn the flat array into a nested tree, respecting the correct headline level.
|
|
36162
|
+
* Step 3: Turn the nested tree into HTML code.
|
|
36163
|
+
*/
|
|
36164
|
+
|
|
36165
|
+
const slugify = function (s) {
|
|
36166
|
+
return encodeURIComponent(String(s).trim().toLowerCase().replace(/\s+/g, '-'));
|
|
36127
36167
|
};
|
|
36128
|
-
|
|
36129
|
-
includeLevel: [
|
|
36168
|
+
const defaults$2 = {
|
|
36169
|
+
includeLevel: [1, 2],
|
|
36130
36170
|
containerClass: 'table-of-contents',
|
|
36131
36171
|
slugify: slugify,
|
|
36132
36172
|
markerPattern: /^\[\[toc\]\]/im,
|
|
36133
36173
|
listType: 'ul',
|
|
36134
|
-
format: function(content, md) {
|
|
36174
|
+
format: function (content, md) {
|
|
36135
36175
|
return md.renderInline(content);
|
|
36136
36176
|
},
|
|
36137
36177
|
forceFullToc: false,
|
|
@@ -36140,17 +36180,182 @@ var defaults$2 = {
|
|
|
36140
36180
|
transformLink: undefined,
|
|
36141
36181
|
};
|
|
36142
36182
|
|
|
36143
|
-
|
|
36144
|
-
|
|
36145
|
-
|
|
36146
|
-
|
|
36183
|
+
/**
|
|
36184
|
+
* @typedef {Object} HeadlineItem
|
|
36185
|
+
* @property {number} level Headline level
|
|
36186
|
+
* @property {string} anchor Anchor target
|
|
36187
|
+
* @property {string} text Text of headline
|
|
36188
|
+
*/
|
|
36189
|
+
|
|
36190
|
+
/**
|
|
36191
|
+
* @typedef {Object} TocItem
|
|
36192
|
+
* @property {number} level Item level
|
|
36193
|
+
* @property {string} text Text of link
|
|
36194
|
+
* @property {string} anchor Target of link
|
|
36195
|
+
* @property {Array<TocItem>} children Sub-items for this list item
|
|
36196
|
+
* @property {TocItem} parent Parent this item belongs to
|
|
36197
|
+
*/
|
|
36198
|
+
|
|
36199
|
+
/**
|
|
36200
|
+
* Finds all headline items for the defined levels in a Markdown document.
|
|
36201
|
+
* @param {Array<number>} levels includeLevels like `[1, 2, 3]`
|
|
36202
|
+
* @param {*} tokens Tokens gathered by the plugin
|
|
36203
|
+
* @param {*} options Plugin options
|
|
36204
|
+
* @returns {Array<HeadlineItem>}
|
|
36205
|
+
*/
|
|
36206
|
+
function findHeadlineElements(levels, tokens, options) {
|
|
36207
|
+
const headings = [];
|
|
36208
|
+
let currentHeading = null;
|
|
36209
|
+
|
|
36210
|
+
tokens.forEach(token => {
|
|
36211
|
+
if (token.type === 'heading_open') {
|
|
36212
|
+
const id = findExistingIdAttr(token);
|
|
36213
|
+
const level = parseInt(token.tag.toLowerCase().replace('h', ''), 10);
|
|
36214
|
+
if (levels.indexOf(level) >= 0) {
|
|
36215
|
+
currentHeading = {
|
|
36216
|
+
level: level,
|
|
36217
|
+
text: null,
|
|
36218
|
+
anchor: id || null
|
|
36219
|
+
};
|
|
36220
|
+
}
|
|
36221
|
+
}
|
|
36222
|
+
else if (currentHeading && token.type === 'inline') {
|
|
36223
|
+
const textContent = token.children
|
|
36224
|
+
.filter((childToken) => childToken.type === 'text' || childToken.type === 'code_inline')
|
|
36225
|
+
.reduce((acc, t) => acc + t.content, '');
|
|
36226
|
+
currentHeading.text = textContent;
|
|
36227
|
+
if (! currentHeading.anchor) {
|
|
36228
|
+
currentHeading.anchor = options.slugify(textContent, token.content);
|
|
36229
|
+
}
|
|
36230
|
+
}
|
|
36231
|
+
else if (token.type === 'heading_close') {
|
|
36232
|
+
if (currentHeading) {
|
|
36233
|
+
headings.push(currentHeading);
|
|
36234
|
+
}
|
|
36235
|
+
currentHeading = null;
|
|
36236
|
+
}
|
|
36237
|
+
});
|
|
36238
|
+
|
|
36239
|
+
return headings;
|
|
36240
|
+
}
|
|
36241
|
+
|
|
36242
|
+
/**
|
|
36243
|
+
* Helper to find an existing id attr on a token. Should be a heading_open token, but could be anything really
|
|
36244
|
+
* Provided by markdown-it-anchor or markdown-it-attrs
|
|
36245
|
+
* @param {any} token Token
|
|
36246
|
+
* @returns {string} Id attribute to use as anchor
|
|
36247
|
+
*/
|
|
36248
|
+
function findExistingIdAttr(token) {
|
|
36249
|
+
if (token && token.attrs && token.attrs.length > 0) {
|
|
36250
|
+
const idAttr = token.attrs.find( (attr) => {
|
|
36251
|
+
if (Array.isArray(attr) && attr.length >= 2) {
|
|
36252
|
+
return attr[0] === 'id';
|
|
36253
|
+
}
|
|
36254
|
+
return false;
|
|
36255
|
+
});
|
|
36256
|
+
if (idAttr && Array.isArray(idAttr) && idAttr.length >= 2) {
|
|
36257
|
+
const [key, val] = idAttr;
|
|
36258
|
+
return val;
|
|
36259
|
+
}
|
|
36260
|
+
}
|
|
36261
|
+
return null;
|
|
36262
|
+
}
|
|
36263
|
+
|
|
36264
|
+
/**
|
|
36265
|
+
* Helper to get minimum headline level so that the TOC is nested correctly
|
|
36266
|
+
* @param {Array<HeadlineItem>} headlineItems Search these
|
|
36267
|
+
* @returns {number} Minimum level
|
|
36268
|
+
*/
|
|
36269
|
+
function getMinLevel(headlineItems) {
|
|
36270
|
+
return Math.min(...headlineItems.map(item => item.level));
|
|
36271
|
+
}
|
|
36272
|
+
|
|
36273
|
+
/**
|
|
36274
|
+
* Helper that creates a TOCItem
|
|
36275
|
+
* @param {number} level
|
|
36276
|
+
* @param {string} text
|
|
36277
|
+
* @param {string} anchor
|
|
36278
|
+
* @param {TocItem} rootNode
|
|
36279
|
+
* @returns {TocItem}
|
|
36280
|
+
*/
|
|
36281
|
+
function addListItem(level, text, anchor, rootNode) {
|
|
36282
|
+
const listItem = { level, text, anchor, children: [], parent: rootNode };
|
|
36283
|
+
rootNode.children.push(listItem);
|
|
36284
|
+
return listItem;
|
|
36285
|
+
}
|
|
36286
|
+
|
|
36287
|
+
/**
|
|
36288
|
+
* Turns a list of flat headline items into a nested tree object representing the TOC
|
|
36289
|
+
* @param {Array<HeadlineItem>} headlineItems
|
|
36290
|
+
* @returns {TocItem} Tree of TOC items
|
|
36291
|
+
*/
|
|
36292
|
+
function flatHeadlineItemsToNestedTree(headlineItems) {
|
|
36293
|
+
// create a root node with no text that holds the entire TOC. this won't be rendered, but only its children
|
|
36294
|
+
const toc = { level: getMinLevel(headlineItems) - 1, anchor: null, text: null, children: [], parent: null };
|
|
36295
|
+
// pointer that tracks the last root item of the current list
|
|
36296
|
+
let currentRootNode = toc;
|
|
36297
|
+
// pointer that tracks the last item (to turn it into a new root node if necessary)
|
|
36298
|
+
let prevListItem = currentRootNode;
|
|
36299
|
+
|
|
36300
|
+
headlineItems.forEach(headlineItem => {
|
|
36301
|
+
// if level is bigger, take the previous node, add a child list, set current list to this new child list
|
|
36302
|
+
if (headlineItem.level > prevListItem.level) {
|
|
36303
|
+
// eslint-disable-next-line no-unused-vars
|
|
36304
|
+
Array.from({ length: headlineItem.level - prevListItem.level }).forEach(_ => {
|
|
36305
|
+
currentRootNode = prevListItem;
|
|
36306
|
+
prevListItem = addListItem(headlineItem.level, null, null, currentRootNode);
|
|
36307
|
+
});
|
|
36308
|
+
prevListItem.text = headlineItem.text;
|
|
36309
|
+
prevListItem.anchor = headlineItem.anchor;
|
|
36310
|
+
}
|
|
36311
|
+
// if level is same, add to the current list
|
|
36312
|
+
else if (headlineItem.level === prevListItem.level) {
|
|
36313
|
+
prevListItem = addListItem(headlineItem.level, headlineItem.text, headlineItem.anchor, currentRootNode);
|
|
36314
|
+
}
|
|
36315
|
+
// if level is smaller, set current list to currentlist.parent
|
|
36316
|
+
else if (headlineItem.level < prevListItem.level) {
|
|
36317
|
+
for (let i = 0; i < prevListItem.level - headlineItem.level; i++) {
|
|
36318
|
+
currentRootNode = currentRootNode.parent;
|
|
36319
|
+
}
|
|
36320
|
+
prevListItem = addListItem(headlineItem.level, headlineItem.text, headlineItem.anchor, currentRootNode);
|
|
36321
|
+
}
|
|
36322
|
+
});
|
|
36323
|
+
|
|
36324
|
+
return toc;
|
|
36325
|
+
}
|
|
36326
|
+
|
|
36327
|
+
/**
|
|
36328
|
+
* Recursively turns a nested tree of tocItems to HTML.
|
|
36329
|
+
* @param {TocItem} tocItem
|
|
36330
|
+
* @returns {string}
|
|
36331
|
+
*/
|
|
36332
|
+
function tocItemToHtml(tocItem, options, md) {
|
|
36333
|
+
return '<' + options.listType + '>' + tocItem.children.map(childItem => {
|
|
36334
|
+
let li = '<li>';
|
|
36335
|
+
let anchor = childItem.anchor;
|
|
36336
|
+
if (options && options.transformLink) {
|
|
36337
|
+
anchor = options.transformLink(anchor);
|
|
36338
|
+
}
|
|
36339
|
+
|
|
36340
|
+
let text = childItem.text ? options.format(childItem.text, md, anchor) : null;
|
|
36341
|
+
|
|
36342
|
+
li += anchor ? `<a href="#${anchor}">${text}</a>` : (text || '');
|
|
36343
|
+
|
|
36344
|
+
return li + (childItem.children.length > 0 ? tocItemToHtml(childItem, options, md) : '') + '</li>';
|
|
36345
|
+
}).join('') + '</' + options.listType + '>';
|
|
36346
|
+
}
|
|
36347
|
+
|
|
36348
|
+
var markdownItTableOfContents = function (md, o) {
|
|
36349
|
+
const options = Object.assign({}, defaults$2, o);
|
|
36350
|
+
const tocRegexp = options.markerPattern;
|
|
36351
|
+
let gstate;
|
|
36147
36352
|
|
|
36148
36353
|
function toc(state, silent) {
|
|
36149
|
-
|
|
36150
|
-
|
|
36354
|
+
let token;
|
|
36355
|
+
let match;
|
|
36151
36356
|
|
|
36152
36357
|
// Reject if the token does not start with [
|
|
36153
|
-
if (state.src.charCodeAt(state.pos) !== 0x5B /* [ */
|
|
36358
|
+
if (state.src.charCodeAt(state.pos) !== 0x5B /* [ */) {
|
|
36154
36359
|
return false;
|
|
36155
36360
|
}
|
|
36156
36361
|
// Don't run any pairs in validation mode
|
|
@@ -36160,7 +36365,7 @@ var markdownItTableOfContents = function(md, o) {
|
|
|
36160
36365
|
|
|
36161
36366
|
// Detect TOC markdown
|
|
36162
36367
|
match = tocRegexp.exec(state.src.substr(state.pos));
|
|
36163
|
-
match = !match ? [] : match.filter(function(m) { return m; });
|
|
36368
|
+
match = !match ? [] : match.filter(function (m) { return m; });
|
|
36164
36369
|
if (match.length < 1) {
|
|
36165
36370
|
return false;
|
|
36166
36371
|
}
|
|
@@ -36182,8 +36387,8 @@ var markdownItTableOfContents = function(md, o) {
|
|
|
36182
36387
|
return true;
|
|
36183
36388
|
}
|
|
36184
36389
|
|
|
36185
|
-
md.renderer.rules.toc_open = function(tokens, index) {
|
|
36186
|
-
var tocOpenHtml = '<div class="'+ options.containerClass +'">';
|
|
36390
|
+
md.renderer.rules.toc_open = function (tokens, index) {
|
|
36391
|
+
var tocOpenHtml = '<div class="' + options.containerClass + '">';
|
|
36187
36392
|
|
|
36188
36393
|
if (options.containerHeaderHtml) {
|
|
36189
36394
|
tocOpenHtml += options.containerHeaderHtml;
|
|
@@ -36192,7 +36397,7 @@ var markdownItTableOfContents = function(md, o) {
|
|
|
36192
36397
|
return tocOpenHtml;
|
|
36193
36398
|
};
|
|
36194
36399
|
|
|
36195
|
-
md.renderer.rules.toc_close = function(tokens, index) {
|
|
36400
|
+
md.renderer.rules.toc_close = function (tokens, index) {
|
|
36196
36401
|
var tocFooterHtml = '';
|
|
36197
36402
|
|
|
36198
36403
|
if (options.containerFooterHtml) {
|
|
@@ -36202,69 +36407,19 @@ var markdownItTableOfContents = function(md, o) {
|
|
|
36202
36407
|
return tocFooterHtml + '</div>';
|
|
36203
36408
|
};
|
|
36204
36409
|
|
|
36205
|
-
md.renderer.rules.toc_body = function(tokens, index) {
|
|
36410
|
+
md.renderer.rules.toc_body = function (tokens, index) {
|
|
36206
36411
|
if (options.forceFullToc) {
|
|
36207
|
-
throw("forceFullToc was removed in version 0.5.0. For more information, see https://github.com/Oktavilla/markdown-it-table-of-contents/pull/41")
|
|
36412
|
+
throw ("forceFullToc was removed in version 0.5.0. For more information, see https://github.com/Oktavilla/markdown-it-table-of-contents/pull/41");
|
|
36208
36413
|
} else {
|
|
36209
|
-
|
|
36414
|
+
const headlineItems = findHeadlineElements(options.includeLevel, gstate.tokens, options);
|
|
36415
|
+
const toc = flatHeadlineItemsToNestedTree(headlineItems);
|
|
36416
|
+
const html = tocItemToHtml(toc, options, md);
|
|
36417
|
+
return html;
|
|
36210
36418
|
}
|
|
36211
36419
|
};
|
|
36212
36420
|
|
|
36213
|
-
function renderChildsTokens(pos, tokens) {
|
|
36214
|
-
var headings = [],
|
|
36215
|
-
buffer = '',
|
|
36216
|
-
currentLevel,
|
|
36217
|
-
subHeadings,
|
|
36218
|
-
size = tokens.length,
|
|
36219
|
-
i = pos;
|
|
36220
|
-
while(i < size) {
|
|
36221
|
-
var token = tokens[i];
|
|
36222
|
-
var heading = tokens[i - 1];
|
|
36223
|
-
var level = token.tag && parseInt(token.tag.substr(1, 1));
|
|
36224
|
-
if (token.type !== 'heading_close' || options.includeLevel.indexOf(level) == -1 || heading.type !== 'inline') {
|
|
36225
|
-
i++; continue; // Skip if not matching criteria
|
|
36226
|
-
}
|
|
36227
|
-
if (!currentLevel) {
|
|
36228
|
-
currentLevel = level;// We init with the first found level
|
|
36229
|
-
} else {
|
|
36230
|
-
if (level > currentLevel) {
|
|
36231
|
-
subHeadings = renderChildsTokens(i, tokens);
|
|
36232
|
-
buffer += subHeadings[1];
|
|
36233
|
-
i = subHeadings[0];
|
|
36234
|
-
continue;
|
|
36235
|
-
}
|
|
36236
|
-
if (level < currentLevel) {
|
|
36237
|
-
// Finishing the sub headings
|
|
36238
|
-
buffer += "</li>";
|
|
36239
|
-
headings.push(buffer);
|
|
36240
|
-
return [i, "<"+ options.listType +">"+ headings.join('') +"</"+ options.listType +">"];
|
|
36241
|
-
}
|
|
36242
|
-
if (level == currentLevel) {
|
|
36243
|
-
// Finishing the sub headings
|
|
36244
|
-
buffer += "</li>";
|
|
36245
|
-
headings.push(buffer);
|
|
36246
|
-
}
|
|
36247
|
-
}
|
|
36248
|
-
var content = heading.children
|
|
36249
|
-
.filter((token) => token.type === 'text' || token.type === 'code_inline')
|
|
36250
|
-
.reduce((acc, t) => acc + t.content, '');
|
|
36251
|
-
var slugifiedContent = options.slugify(content);
|
|
36252
|
-
var link = "#"+slugifiedContent;
|
|
36253
|
-
if (options.transformLink) {
|
|
36254
|
-
link = options.transformLink(link);
|
|
36255
|
-
}
|
|
36256
|
-
buffer = `<li><a href="${link}">`;
|
|
36257
|
-
buffer += options.format(content, md, link);
|
|
36258
|
-
buffer += `</a>`;
|
|
36259
|
-
i++;
|
|
36260
|
-
}
|
|
36261
|
-
buffer += buffer === '' ? '' : '</li>';
|
|
36262
|
-
headings.push(buffer);
|
|
36263
|
-
return [i, "<"+ options.listType +">"+ headings.join('') +"</"+ options.listType +">"];
|
|
36264
|
-
}
|
|
36265
|
-
|
|
36266
36421
|
// Catch all the tokens for iteration later
|
|
36267
|
-
md.core.ruler.push('grab_state', function(state) {
|
|
36422
|
+
md.core.ruler.push('grab_state', function (state) {
|
|
36268
36423
|
gstate = state;
|
|
36269
36424
|
});
|
|
36270
36425
|
|
|
@@ -36311,6 +36466,11 @@ const createMarkdownRenderer = (srcDir, options = {}) => {
|
|
|
36311
36466
|
if (options.lineNumbers) {
|
|
36312
36467
|
md.use(lineNumberPlugin);
|
|
36313
36468
|
}
|
|
36469
|
+
const originalRender = md.render;
|
|
36470
|
+
md.render = (...args) => {
|
|
36471
|
+
md.__data = {};
|
|
36472
|
+
return originalRender.call(md, ...args);
|
|
36473
|
+
};
|
|
36314
36474
|
return md;
|
|
36315
36475
|
};
|
|
36316
36476
|
|
|
@@ -36344,7 +36504,6 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
36344
36504
|
const { content, data: frontmatter } = grayMatter(src);
|
|
36345
36505
|
md.__path = file;
|
|
36346
36506
|
md.__relativePath = relativePath;
|
|
36347
|
-
md.__data = {};
|
|
36348
36507
|
let html = md.render(content);
|
|
36349
36508
|
const data = md.__data;
|
|
36350
36509
|
if (isBuild) {
|
|
@@ -36420,12 +36579,12 @@ export default {}<\/script>`);
|
|
|
36420
36579
|
return tags;
|
|
36421
36580
|
}
|
|
36422
36581
|
const inferTitle = (frontmatter, content) => {
|
|
36423
|
-
if (frontmatter.home) {
|
|
36424
|
-
return "Home";
|
|
36425
|
-
}
|
|
36426
36582
|
if (frontmatter.title) {
|
|
36427
36583
|
return deeplyParseHeader(frontmatter.title);
|
|
36428
36584
|
}
|
|
36585
|
+
if (frontmatter.home) {
|
|
36586
|
+
return "Home";
|
|
36587
|
+
}
|
|
36429
36588
|
const match = content.match(/^\s*#+\s+(.*)/m);
|
|
36430
36589
|
if (match) {
|
|
36431
36590
|
return deeplyParseHeader(match[1].trim());
|
|
@@ -40056,7 +40215,15 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40056
40215
|
const routePath = `/${page.replace(/\.md$/, "")}`;
|
|
40057
40216
|
const siteData = resolveSiteDataByRoute(config.site, routePath);
|
|
40058
40217
|
router.go(routePath);
|
|
40059
|
-
|
|
40218
|
+
let rendererPath;
|
|
40219
|
+
try {
|
|
40220
|
+
rendererPath = require.resolve("vue/server-renderer", {
|
|
40221
|
+
paths: [config.root]
|
|
40222
|
+
});
|
|
40223
|
+
} catch (e) {
|
|
40224
|
+
rendererPath = require.resolve("vue/server-renderer");
|
|
40225
|
+
}
|
|
40226
|
+
const content = await require(rendererPath).renderToString(app);
|
|
40060
40227
|
const pageName = page.replace(/\//g, "_");
|
|
40061
40228
|
const pageServerJsFileName = pageName + ".js";
|
|
40062
40229
|
const pageHash = pageToHashMap[pageName.toLowerCase()];
|
|
@@ -40064,7 +40231,7 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40064
40231
|
const { __pageData } = require(path__default["default"].join(config.tempDir, pageServerJsFileName));
|
|
40065
40232
|
const pageData = JSON.parse(__pageData);
|
|
40066
40233
|
let preloadLinks = config.mpa ? appChunk ? [appChunk.fileName] : [] : result && appChunk ? [
|
|
40067
|
-
|
|
40234
|
+
.../* @__PURE__ */ new Set([
|
|
40068
40235
|
...resolvePageImports(config, page, result, appChunk),
|
|
40069
40236
|
pageClientJsFileName,
|
|
40070
40237
|
appChunk.fileName
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.6",
|
|
4
4
|
"description": "Vite & Vue powered static site generator",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
6
|
"typings": "types/index.d.ts",
|
|
@@ -11,8 +11,36 @@
|
|
|
11
11
|
"bin",
|
|
12
12
|
"dist",
|
|
13
13
|
"types",
|
|
14
|
-
"client.d.ts"
|
|
14
|
+
"client.d.ts",
|
|
15
|
+
"theme.d.ts"
|
|
15
16
|
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "run-s dev-shared dev-start",
|
|
19
|
+
"dev-start": "run-p dev-client dev-node dev-watch",
|
|
20
|
+
"dev-client": "tsc -w -p src/client",
|
|
21
|
+
"dev-node": "tsc -w -p src/node",
|
|
22
|
+
"dev-shared": "node scripts/copyShared",
|
|
23
|
+
"dev-watch": "node scripts/watchAndCopy",
|
|
24
|
+
"build": "run-s build-prepare build-client build-node build-types",
|
|
25
|
+
"build-prepare": "rimraf -rf dist && node scripts/copyShared",
|
|
26
|
+
"build-client": "tsc -p src/client && node scripts/copyClient",
|
|
27
|
+
"build-node": "rollup -c scripts/rollup.config.js",
|
|
28
|
+
"build-types": "run-s build-types-client build-types-node",
|
|
29
|
+
"build-types-client": "tsc -p src/client --declaration --emitDeclarationOnly --outDir dist/temp && api-extractor run -c api-extractor.client.json && rimraf dist/temp",
|
|
30
|
+
"build-types-node": "tsc -p src/node --declaration --emitDeclarationOnly --outDir dist/temp && api-extractor run -c api-extractor.node.json && rimraf dist/temp",
|
|
31
|
+
"lint": "run-s lint:js lint:ts",
|
|
32
|
+
"lint:js": "prettier --check --write \"{bin,docs,scripts,src}/**/*.js\"",
|
|
33
|
+
"lint:ts": "prettier --check --write --parser typescript \"{__tests__,src,docs,types}/**/*.ts\"",
|
|
34
|
+
"test": "vitest run __tests__ -c __tests__/vitest.config.js --global",
|
|
35
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
|
36
|
+
"release": "node scripts/release.js",
|
|
37
|
+
"docs": "run-p dev docs-dev",
|
|
38
|
+
"docs-dev": "node ./bin/vitepress dev docs",
|
|
39
|
+
"docs-debug": "node --inspect-brk ./bin/vitepress dev docs",
|
|
40
|
+
"docs-build": "npm run build && node ./bin/vitepress build docs",
|
|
41
|
+
"docs-serve": "node ./bin/vitepress serve docs",
|
|
42
|
+
"ci-docs": "run-s build docs-build"
|
|
43
|
+
},
|
|
16
44
|
"engines": {
|
|
17
45
|
"node": ">=12.0.0"
|
|
18
46
|
},
|
|
@@ -47,8 +75,8 @@
|
|
|
47
75
|
"@docsearch/js": "^3.0.0-alpha.41",
|
|
48
76
|
"@vitejs/plugin-vue": "^2.0.0",
|
|
49
77
|
"prismjs": "^1.25.0",
|
|
50
|
-
"vite": "^2.7.
|
|
51
|
-
"vue": "^3.2.
|
|
78
|
+
"vite": "^2.7.12",
|
|
79
|
+
"vue": "^3.2.27"
|
|
52
80
|
},
|
|
53
81
|
"devDependencies": {
|
|
54
82
|
"@microsoft/api-extractor": "^7.18.9",
|
|
@@ -59,7 +87,6 @@
|
|
|
59
87
|
"@types/compression": "^1.7.0",
|
|
60
88
|
"@types/debug": "^4.1.7",
|
|
61
89
|
"@types/fs-extra": "^9.0.11",
|
|
62
|
-
"@types/jest": "^26.0.23",
|
|
63
90
|
"@types/koa": "^2.13.1",
|
|
64
91
|
"@types/koa-static": "^4.0.1",
|
|
65
92
|
"@types/lru-cache": "^5.1.0",
|
|
@@ -74,22 +101,21 @@
|
|
|
74
101
|
"debug": "^4.3.2",
|
|
75
102
|
"diacritics": "^1.3.0",
|
|
76
103
|
"enquirer": "^2.3.6",
|
|
77
|
-
"esbuild": "^0.
|
|
104
|
+
"esbuild": "^0.14.0",
|
|
78
105
|
"escape-html": "^1.0.3",
|
|
79
106
|
"execa": "^5.0.0",
|
|
80
107
|
"fast-glob": "^3.2.7",
|
|
81
108
|
"fs-extra": "^10.0.0",
|
|
82
109
|
"globby": "^11.0.3",
|
|
83
110
|
"gray-matter": "^4.0.3",
|
|
84
|
-
"jest": "^27.0.1",
|
|
85
111
|
"lint-staged": "^11.0.0",
|
|
86
112
|
"lru-cache": "^6.0.0",
|
|
87
|
-
"markdown-it": "^12.
|
|
88
|
-
"markdown-it-anchor": "^8.1
|
|
89
|
-
"markdown-it-attrs": "^4.
|
|
113
|
+
"markdown-it": "^12.3.2",
|
|
114
|
+
"markdown-it-anchor": "^8.4.1",
|
|
115
|
+
"markdown-it-attrs": "^4.1.3",
|
|
90
116
|
"markdown-it-container": "^3.0.0",
|
|
91
117
|
"markdown-it-emoji": "^2.0.0",
|
|
92
|
-
"markdown-it-table-of-contents": "^0.
|
|
118
|
+
"markdown-it-table-of-contents": "^0.6.0",
|
|
93
119
|
"micromatch": "^4.0.4",
|
|
94
120
|
"minimist": "^1.2.5",
|
|
95
121
|
"npm-run-all": "^4.1.5",
|
|
@@ -98,39 +124,21 @@
|
|
|
98
124
|
"prettier": "^2.3.0",
|
|
99
125
|
"rimraf": "^3.0.2",
|
|
100
126
|
"rollup": "^2.56.3",
|
|
101
|
-
"rollup-plugin-esbuild": "^4.
|
|
127
|
+
"rollup-plugin-esbuild": "^4.8.2",
|
|
102
128
|
"semver": "^7.3.5",
|
|
103
129
|
"sirv": "^1.0.12",
|
|
104
|
-
"ts-jest": "^27.0.1",
|
|
105
130
|
"typescript": "^4.3.2",
|
|
131
|
+
"vitest": "^0.1.19",
|
|
106
132
|
"yorkie": "^2.0.0"
|
|
107
133
|
},
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"build-types": "run-s build-types-client build-types-node",
|
|
120
|
-
"build-types-client": "tsc -p src/client --declaration --emitDeclarationOnly --outDir dist/temp && api-extractor run -c api-extractor.client.json && rimraf dist/temp",
|
|
121
|
-
"build-types-node": "tsc -p src/node --declaration --emitDeclarationOnly --outDir dist/temp && api-extractor run -c api-extractor.node.json && rimraf dist/temp",
|
|
122
|
-
"lint": "run-s lint:js lint:ts",
|
|
123
|
-
"lint:js": "prettier --check --write \"{bin,docs,scripts,src}/**/*.js\"",
|
|
124
|
-
"lint:ts": "prettier --check --write --parser typescript \"{__tests__,src,docs,types}/**/*.ts\"",
|
|
125
|
-
"test": "jest",
|
|
126
|
-
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
|
127
|
-
"release": "node scripts/release.js",
|
|
128
|
-
"docs": "run-p dev docs-dev",
|
|
129
|
-
"docs-dev": "node ./bin/vitepress dev docs",
|
|
130
|
-
"docs-debug": "node --inspect-brk ./bin/vitepress dev docs",
|
|
131
|
-
"docs-build": "npm run build && node ./bin/vitepress build docs",
|
|
132
|
-
"docs-serve": "node ./bin/vitepress serve docs",
|
|
133
|
-
"ci-docs": "run-s build docs-build"
|
|
134
|
-
},
|
|
135
|
-
"readme": "# (WIP) VitePress 📝💨\n\n[](https://github.com/vuejs/vitepress/actions)\n[](https://www.npmjs.com/package/vitepress)\n\n---\n\nVitePress is [VuePress](http://vuepress.vuejs.org/)' spiritual successor, built on top of [vite](https://github.com/vuejs/vite).\n\n## Documentation\n\nTo check out docs, visit [vitepress.vuejs.org](https://vitepress.vuejs.org).\n\n## Changelog\n\nDetailed changes for each release are documented in the [CHANGELOG](https://github.com/vuejs/vitepress/blob/master/CHANGELOG.md).\n\n## Contribution\n\nPlease make sure to read the [Contributing Guide](./.github/contributing.md) before making a pull request.\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n\nCopyright (c) 2019-present, Yuxi (Evan) You\n"
|
|
136
|
-
}
|
|
134
|
+
"pnpm": {
|
|
135
|
+
"peerDependencyRules": {
|
|
136
|
+
"ignoreMissing": [
|
|
137
|
+
"@algolia/client-search",
|
|
138
|
+
"react",
|
|
139
|
+
"react-dom",
|
|
140
|
+
"@types/react"
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
package/theme.d.ts
ADDED
package/types/shared.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface SiteData<ThemeConfig = any> {
|
|
|
22
22
|
description: string
|
|
23
23
|
head: HeadConfig[]
|
|
24
24
|
themeConfig: ThemeConfig
|
|
25
|
+
scrollOffset: number | string
|
|
25
26
|
locales: Record<string, LocaleConfig>
|
|
26
27
|
/**
|
|
27
28
|
* Available locales for the site when it has defined `locales` in its
|
package/dist/vitepress.d.ts
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { AliasOptions } from 'vite';
|
|
2
|
-
import anchor from 'markdown-it-anchor';
|
|
3
|
-
import { BuildOptions } from 'vite';
|
|
4
|
-
import MarkdownIt from 'markdown-it';
|
|
5
|
-
import { Options } from '@vitejs/plugin-vue';
|
|
6
|
-
import { ServerOptions } from 'vite';
|
|
7
|
-
import { UserConfig as UserConfig_2 } from 'vite';
|
|
8
|
-
import { ViteDevServer } from 'vite';
|
|
9
|
-
|
|
10
|
-
export declare function build(root: string, buildOptions?: BuildOptions & {
|
|
11
|
-
mpa?: string;
|
|
12
|
-
}): Promise<void>;
|
|
13
|
-
|
|
14
|
-
export declare const createMarkdownRenderer: (srcDir: string, options?: MarkdownOptions) => MarkdownRenderer;
|
|
15
|
-
|
|
16
|
-
export declare function createServer(root?: string, serverOptions?: ServerOptions): Promise<ViteDevServer>;
|
|
17
|
-
|
|
18
|
-
export declare namespace DefaultTheme {
|
|
19
|
-
export interface Config {
|
|
20
|
-
logo?: string
|
|
21
|
-
nav?: NavItem[] | false
|
|
22
|
-
sidebar?: SideBarConfig | MultiSideBarConfig
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* GitHub repository following the format <user>/<project>.
|
|
26
|
-
*
|
|
27
|
-
* @example `"vuejs/vue-next"`
|
|
28
|
-
*/
|
|
29
|
-
repo?: string
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
|
|
33
|
-
* depending on the provided repo.
|
|
34
|
-
*
|
|
35
|
-
* @example `"Contribute!"`
|
|
36
|
-
*/
|
|
37
|
-
repoLabel?: string
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* If your docs are in a different repository from your main project.
|
|
41
|
-
*
|
|
42
|
-
* @example `"vuejs/docs-next"`
|
|
43
|
-
*/
|
|
44
|
-
docsRepo?: string
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* If your docs are not at the root of the repo.
|
|
48
|
-
*
|
|
49
|
-
* @example `"docs"`
|
|
50
|
-
*/
|
|
51
|
-
docsDir?: string
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* If your docs are in a different branch. Defaults to `master`.
|
|
55
|
-
*
|
|
56
|
-
* @example `"next"`
|
|
57
|
-
*/
|
|
58
|
-
docsBranch?: string
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Enable links to edit pages at the bottom of the page.
|
|
62
|
-
*/
|
|
63
|
-
editLinks?: boolean
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Custom text for edit link. Defaults to "Edit this page".
|
|
67
|
-
*/
|
|
68
|
-
editLinkText?: string
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Show last updated time at the bottom of the page. Defaults to `false`.
|
|
72
|
-
* If given a string, it will be displayed as a prefix (default value:
|
|
73
|
-
* "Last Updated").
|
|
74
|
-
*/
|
|
75
|
-
lastUpdated?: string | boolean
|
|
76
|
-
|
|
77
|
-
prevLinks?: boolean
|
|
78
|
-
nextLinks?: boolean
|
|
79
|
-
|
|
80
|
-
locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
|
|
81
|
-
|
|
82
|
-
algolia?: AlgoliaSearchOptions
|
|
83
|
-
|
|
84
|
-
carbonAds?: {
|
|
85
|
-
carbon: string
|
|
86
|
-
custom?: string
|
|
87
|
-
placement: string
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// navbar --------------------------------------------------------------------
|
|
92
|
-
|
|
93
|
-
export type NavItem = NavItemWithLink | NavItemWithChildren
|
|
94
|
-
|
|
95
|
-
export interface NavItemBase {
|
|
96
|
-
text: string
|
|
97
|
-
target?: string
|
|
98
|
-
rel?: string
|
|
99
|
-
ariaLabel?: string
|
|
100
|
-
activeMatch?: string
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface NavItemWithLink extends NavItemBase {
|
|
104
|
-
link: string
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface NavItemWithChildren extends NavItemBase {
|
|
108
|
-
items: NavItemWithLink[]
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// sidebar -------------------------------------------------------------------
|
|
112
|
-
|
|
113
|
-
export type SideBarConfig = SideBarItem[] | 'auto' | false
|
|
114
|
-
|
|
115
|
-
export interface MultiSideBarConfig {
|
|
116
|
-
[path: string]: SideBarConfig
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export type SideBarItem = SideBarLink | SideBarGroup
|
|
120
|
-
|
|
121
|
-
export interface SideBarLink {
|
|
122
|
-
text: string
|
|
123
|
-
link: string
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface SideBarGroup {
|
|
127
|
-
text: string
|
|
128
|
-
link?: string
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @default false
|
|
132
|
-
*/
|
|
133
|
-
collapsable?: boolean
|
|
134
|
-
|
|
135
|
-
children: SideBarItem[]
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// algolia ------------------------------------------------------------------
|
|
139
|
-
// partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
|
|
140
|
-
export interface AlgoliaSearchOptions {
|
|
141
|
-
appId?: string
|
|
142
|
-
apiKey: string
|
|
143
|
-
indexName: string
|
|
144
|
-
placeholder?: string
|
|
145
|
-
searchParameters?: any
|
|
146
|
-
disableUserPersonalization?: boolean
|
|
147
|
-
initialQuery?: string
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// locales -------------------------------------------------------------------
|
|
151
|
-
|
|
152
|
-
export interface LocaleConfig {
|
|
153
|
-
/**
|
|
154
|
-
* Text for the language dropdown.
|
|
155
|
-
*/
|
|
156
|
-
selectText?: string
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Label for this locale in the language dropdown.
|
|
160
|
-
*/
|
|
161
|
-
label?: string
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Type config helper
|
|
167
|
-
*/
|
|
168
|
-
export declare function defineConfig(config: UserConfig<DefaultTheme.Config>): UserConfig<DefaultTheme.Config>;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Type config helper for custom theme config
|
|
172
|
-
*/
|
|
173
|
-
export declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig<ThemeConfig>): UserConfig<ThemeConfig>;
|
|
174
|
-
|
|
175
|
-
export declare type HeadConfig =
|
|
176
|
-
| [string, Record<string, string>]
|
|
177
|
-
| [string, Record<string, string>, string]
|
|
178
|
-
|
|
179
|
-
export declare interface Header {
|
|
180
|
-
level: number
|
|
181
|
-
title: string
|
|
182
|
-
slug: string
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export declare interface LocaleConfig {
|
|
186
|
-
lang: string
|
|
187
|
-
title?: string
|
|
188
|
-
description?: string
|
|
189
|
-
head?: HeadConfig[]
|
|
190
|
-
label?: string
|
|
191
|
-
selectText?: string
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export declare interface MarkdownOptions extends MarkdownIt.Options {
|
|
195
|
-
lineNumbers?: boolean;
|
|
196
|
-
config?: (md: MarkdownIt) => void;
|
|
197
|
-
anchor?: {
|
|
198
|
-
permalink?: anchor.AnchorOptions['permalink'];
|
|
199
|
-
};
|
|
200
|
-
attrs?: {
|
|
201
|
-
leftDelimiter?: string;
|
|
202
|
-
rightDelimiter?: string;
|
|
203
|
-
allowedAttributes?: string[];
|
|
204
|
-
};
|
|
205
|
-
toc?: any;
|
|
206
|
-
externalLinks?: Record<string, string>;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export declare interface MarkdownParsedData {
|
|
210
|
-
hoistedTags?: string[];
|
|
211
|
-
links?: string[];
|
|
212
|
-
headers?: Header[];
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export declare interface MarkdownRenderer extends MarkdownIt {
|
|
216
|
-
__path: string;
|
|
217
|
-
__relativePath: string;
|
|
218
|
-
__data: MarkdownParsedData;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export declare type RawConfigExports<ThemeConfig = any> = UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>> | (() => UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>>);
|
|
222
|
-
|
|
223
|
-
export declare function resolveConfig(root?: string, command?: 'serve' | 'build', mode?: string): Promise<SiteConfig>;
|
|
224
|
-
|
|
225
|
-
export declare function resolveSiteData(root: string, userConfig?: UserConfig, command?: 'serve' | 'build', mode?: string): Promise<SiteData>;
|
|
226
|
-
|
|
227
|
-
export declare function resolveSiteDataByRoute(siteData: SiteData, route: string): SiteData;
|
|
228
|
-
|
|
229
|
-
export declare function serve(options?: ServeOptions): Promise<void>;
|
|
230
|
-
|
|
231
|
-
export declare interface ServeOptions {
|
|
232
|
-
root?: string;
|
|
233
|
-
port?: number;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export declare interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa'> {
|
|
237
|
-
root: string;
|
|
238
|
-
srcDir: string;
|
|
239
|
-
site: SiteData<ThemeConfig>;
|
|
240
|
-
configPath: string | undefined;
|
|
241
|
-
themeDir: string;
|
|
242
|
-
outDir: string;
|
|
243
|
-
tempDir: string;
|
|
244
|
-
alias: AliasOptions;
|
|
245
|
-
pages: string[];
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export declare interface SiteData<ThemeConfig = any> {
|
|
249
|
-
base: string
|
|
250
|
-
/**
|
|
251
|
-
* Language of the site as it should be set on the `html` element.
|
|
252
|
-
* @example `en-US`, `zh-CN`
|
|
253
|
-
*/
|
|
254
|
-
lang: string
|
|
255
|
-
title: string
|
|
256
|
-
description: string
|
|
257
|
-
head: HeadConfig[]
|
|
258
|
-
themeConfig: ThemeConfig
|
|
259
|
-
locales: Record<string, LocaleConfig>
|
|
260
|
-
/**
|
|
261
|
-
* Available locales for the site when it has defined `locales` in its
|
|
262
|
-
* `themeConfig`. This object is otherwise empty. Keys are paths like `/` or
|
|
263
|
-
* `/zh/`.
|
|
264
|
-
*/
|
|
265
|
-
langs: Record<
|
|
266
|
-
string,
|
|
267
|
-
{
|
|
268
|
-
/**
|
|
269
|
-
* Lang attribute as set on the `<html>` element.
|
|
270
|
-
* @example `en-US`, `zh-CN`
|
|
271
|
-
*/
|
|
272
|
-
lang: string
|
|
273
|
-
/**
|
|
274
|
-
* Label to display in the language menu.
|
|
275
|
-
* @example `English`, `简体中文`
|
|
276
|
-
*/
|
|
277
|
-
label: string
|
|
278
|
-
}
|
|
279
|
-
>
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export declare interface UserConfig<ThemeConfig = any> {
|
|
283
|
-
extends?: RawConfigExports<ThemeConfig>;
|
|
284
|
-
lang?: string;
|
|
285
|
-
base?: string;
|
|
286
|
-
title?: string;
|
|
287
|
-
description?: string;
|
|
288
|
-
head?: HeadConfig[];
|
|
289
|
-
themeConfig?: ThemeConfig;
|
|
290
|
-
locales?: Record<string, LocaleConfig>;
|
|
291
|
-
markdown?: MarkdownOptions;
|
|
292
|
-
/**
|
|
293
|
-
* Options to pass on to `@vitejs/plugin-vue`
|
|
294
|
-
*/
|
|
295
|
-
vue?: Options;
|
|
296
|
-
/**
|
|
297
|
-
* Vite config
|
|
298
|
-
*/
|
|
299
|
-
vite?: UserConfig_2;
|
|
300
|
-
srcDir?: string;
|
|
301
|
-
srcExclude?: string[];
|
|
302
|
-
outDir?: string;
|
|
303
|
-
shouldPreload?: (link: string, page: string) => boolean;
|
|
304
|
-
/**
|
|
305
|
-
* Enable MPA / zero-JS mode
|
|
306
|
-
* @experimental
|
|
307
|
-
*/
|
|
308
|
-
mpa?: boolean;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export { }
|