themekit-js 1.1.0
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/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/themekit.js +2 -0
- package/client.d.ts +5 -0
- package/dist/client/app/components/ClientOnly.js +10 -0
- package/dist/client/app/components/Content.js +23 -0
- package/dist/client/app/composables/codeGroups.js +40 -0
- package/dist/client/app/composables/copyCode.js +73 -0
- package/dist/client/app/composables/head.js +81 -0
- package/dist/client/app/composables/preFetch.js +99 -0
- package/dist/client/app/data.js +59 -0
- package/dist/client/app/devtools.js +29 -0
- package/dist/client/app/index.js +140 -0
- package/dist/client/app/router.js +233 -0
- package/dist/client/app/ssr.js +10 -0
- package/dist/client/app/theme.js +1 -0
- package/dist/client/app/utils.js +119 -0
- package/dist/client/index.d.ts +1446 -0
- package/dist/client/index.js +9 -0
- package/dist/client/shared.js +139 -0
- package/dist/client/theme-default/Layout.vue +94 -0
- package/dist/client/theme-default/NotFound.vue +109 -0
- package/dist/client/theme-default/components/VPAlgoliaSearchBox.vue +99 -0
- package/dist/client/theme-default/components/VPBackdrop.vue +41 -0
- package/dist/client/theme-default/components/VPBadge.vue +86 -0
- package/dist/client/theme-default/components/VPButton.vue +123 -0
- package/dist/client/theme-default/components/VPCarbonAds.vue +109 -0
- package/dist/client/theme-default/components/VPContent.vue +98 -0
- package/dist/client/theme-default/components/VPDoc.vue +193 -0
- package/dist/client/theme-default/components/VPDocAside.vue +46 -0
- package/dist/client/theme-default/components/VPDocAsideCarbonAds.vue +18 -0
- package/dist/client/theme-default/components/VPDocAsideOutline.vue +87 -0
- package/dist/client/theme-default/components/VPDocAsideSponsors.vue +17 -0
- package/dist/client/theme-default/components/VPDocFooter.vue +145 -0
- package/dist/client/theme-default/components/VPDocFooterLastUpdated.vue +50 -0
- package/dist/client/theme-default/components/VPDocOutlineItem.vue +59 -0
- package/dist/client/theme-default/components/VPFeature.vue +123 -0
- package/dist/client/theme-default/components/VPFeatures.vue +121 -0
- package/dist/client/theme-default/components/VPFlyout.vue +136 -0
- package/dist/client/theme-default/components/VPFooter.vue +60 -0
- package/dist/client/theme-default/components/VPHero.vue +336 -0
- package/dist/client/theme-default/components/VPHome.vue +43 -0
- package/dist/client/theme-default/components/VPHomeContent.vue +52 -0
- package/dist/client/theme-default/components/VPHomeFeatures.vue +14 -0
- package/dist/client/theme-default/components/VPHomeHero.vue +24 -0
- package/dist/client/theme-default/components/VPHomeSponsors.vue +116 -0
- package/dist/client/theme-default/components/VPImage.vue +46 -0
- package/dist/client/theme-default/components/VPLink.vue +33 -0
- package/dist/client/theme-default/components/VPLocalNav.vue +171 -0
- package/dist/client/theme-default/components/VPLocalNavOutlineDropdown.vue +190 -0
- package/dist/client/theme-default/components/VPLocalSearchBox.vue +856 -0
- package/dist/client/theme-default/components/VPMenu.vue +72 -0
- package/dist/client/theme-default/components/VPMenuGroup.vue +47 -0
- package/dist/client/theme-default/components/VPMenuLink.vue +54 -0
- package/dist/client/theme-default/components/VPNav.vue +57 -0
- package/dist/client/theme-default/components/VPNavBar.vue +267 -0
- package/dist/client/theme-default/components/VPNavBarAppearance.vue +25 -0
- package/dist/client/theme-default/components/VPNavBarExtra.vue +94 -0
- package/dist/client/theme-default/components/VPNavBarHamburger.vue +79 -0
- package/dist/client/theme-default/components/VPNavBarMenu.vue +29 -0
- package/dist/client/theme-default/components/VPNavBarMenuGroup.vue +42 -0
- package/dist/client/theme-default/components/VPNavBarMenuLink.vue +53 -0
- package/dist/client/theme-default/components/VPNavBarSearch.vue +194 -0
- package/dist/client/theme-default/components/VPNavBarSearchButton.vue +208 -0
- package/dist/client/theme-default/components/VPNavBarSocialLinks.vue +27 -0
- package/dist/client/theme-default/components/VPNavBarTitle.vue +76 -0
- package/dist/client/theme-default/components/VPNavBarTranslations.vue +47 -0
- package/dist/client/theme-default/components/VPNavScreen.vue +99 -0
- package/dist/client/theme-default/components/VPNavScreenAppearance.vue +33 -0
- package/dist/client/theme-default/components/VPNavScreenMenu.vue +23 -0
- package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +111 -0
- package/dist/client/theme-default/components/VPNavScreenMenuGroupLink.vue +39 -0
- package/dist/client/theme-default/components/VPNavScreenMenuGroupSection.vue +34 -0
- package/dist/client/theme-default/components/VPNavScreenMenuLink.vue +39 -0
- package/dist/client/theme-default/components/VPNavScreenSocialLinks.vue +14 -0
- package/dist/client/theme-default/components/VPNavScreenTranslations.vue +73 -0
- package/dist/client/theme-default/components/VPPage.vue +7 -0
- package/dist/client/theme-default/components/VPSidebar.vue +137 -0
- package/dist/client/theme-default/components/VPSidebarItem.vue +250 -0
- package/dist/client/theme-default/components/VPSkipLink.vue +68 -0
- package/dist/client/theme-default/components/VPSocialLink.vue +50 -0
- package/dist/client/theme-default/components/VPSocialLinks.vue +27 -0
- package/dist/client/theme-default/components/VPSponsors.vue +48 -0
- package/dist/client/theme-default/components/VPSponsorsGrid.vue +48 -0
- package/dist/client/theme-default/components/VPSwitch.vue +63 -0
- package/dist/client/theme-default/components/VPSwitchAppearance.vue +52 -0
- package/dist/client/theme-default/components/VPTeamMembers.vue +66 -0
- package/dist/client/theme-default/components/VPTeamMembersItem.vue +225 -0
- package/dist/client/theme-default/components/VPTeamPage.vue +58 -0
- package/dist/client/theme-default/components/VPTeamPageSection.vue +77 -0
- package/dist/client/theme-default/components/VPTeamPageTitle.vue +63 -0
- package/dist/client/theme-default/components/icons/VPIconAlignJustify.vue +8 -0
- package/dist/client/theme-default/components/icons/VPIconAlignLeft.vue +8 -0
- package/dist/client/theme-default/components/icons/VPIconAlignRight.vue +8 -0
- package/dist/client/theme-default/components/icons/VPIconArrowLeft.vue +7 -0
- package/dist/client/theme-default/components/icons/VPIconArrowRight.vue +7 -0
- package/dist/client/theme-default/components/icons/VPIconChevronDown.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconChevronLeft.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconChevronRight.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconChevronUp.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconEdit.vue +6 -0
- package/dist/client/theme-default/components/icons/VPIconHeart.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconLanguages.vue +9 -0
- package/dist/client/theme-default/components/icons/VPIconMinus.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconMinusSquare.vue +6 -0
- package/dist/client/theme-default/components/icons/VPIconMoon.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconMoreHorizontal.vue +7 -0
- package/dist/client/theme-default/components/icons/VPIconPlus.vue +5 -0
- package/dist/client/theme-default/components/icons/VPIconPlusSquare.vue +6 -0
- package/dist/client/theme-default/components/icons/VPIconSun.vue +13 -0
- package/dist/client/theme-default/composables/aside.js +17 -0
- package/dist/client/theme-default/composables/data.js +2 -0
- package/dist/client/theme-default/composables/edit-link.js +16 -0
- package/dist/client/theme-default/composables/flyout.js +41 -0
- package/dist/client/theme-default/composables/langs.js +26 -0
- package/dist/client/theme-default/composables/local-nav.js +18 -0
- package/dist/client/theme-default/composables/nav.js +30 -0
- package/dist/client/theme-default/composables/outline.js +178 -0
- package/dist/client/theme-default/composables/prev-next.js +57 -0
- package/dist/client/theme-default/composables/sidebar.js +136 -0
- package/dist/client/theme-default/composables/sponsor-grid.js +94 -0
- package/dist/client/theme-default/fonts/inter-italic-cyrillic-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-cyrillic.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-greek-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-greek.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-latin-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-latin.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-italic-vietnamese.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-cyrillic-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-cyrillic.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-greek-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-greek.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-latin-ext.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-latin.woff2 +0 -0
- package/dist/client/theme-default/fonts/inter-roman-vietnamese.woff2 +0 -0
- package/dist/client/theme-default/index.js +3 -0
- package/dist/client/theme-default/styles/base.css +252 -0
- package/dist/client/theme-default/styles/components/custom-block.css +208 -0
- package/dist/client/theme-default/styles/components/vp-code-group.css +85 -0
- package/dist/client/theme-default/styles/components/vp-code.css +7 -0
- package/dist/client/theme-default/styles/components/vp-doc.css +570 -0
- package/dist/client/theme-default/styles/components/vp-sponsor.css +155 -0
- package/dist/client/theme-default/styles/fonts.css +157 -0
- package/dist/client/theme-default/styles/icons.css +123 -0
- package/dist/client/theme-default/styles/utils.css +9 -0
- package/dist/client/theme-default/styles/vars.css +563 -0
- package/dist/client/theme-default/support/lru.js +33 -0
- package/dist/client/theme-default/support/sidebar.js +89 -0
- package/dist/client/theme-default/support/translation.js +49 -0
- package/dist/client/theme-default/support/utils.js +33 -0
- package/dist/client/theme-default/without-fonts.js +32 -0
- package/dist/node/cli.js +444 -0
- package/dist/node/index.d.ts +4588 -0
- package/dist/node/index.js +198 -0
- package/dist/node/serve-BjvG349_.js +50301 -0
- package/lib/vue-demi.mjs +34 -0
- package/package.json +223 -0
- package/template/.vitepress/config.js +28 -0
- package/template/.vitepress/theme/Layout.vue +21 -0
- package/template/.vitepress/theme/index.js +29 -0
- package/template/.vitepress/theme/style.css +143 -0
- package/template/api-examples.md +49 -0
- package/template/index.md +28 -0
- package/template/markdown-examples.md +85 -0
- package/theme-without-fonts.d.ts +2 -0
- package/theme.d.ts +30 -0
- package/types/default-theme.d.ts +533 -0
- package/types/docsearch.d.ts +144 -0
- package/types/index.d.ts +3 -0
- package/types/local-search.d.ts +33 -0
- package/types/shared.d.ts +199 -0
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colors: Solid
|
|
3
|
+
* -------------------------------------------------------------------------- */
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--vp-c-white: #ffffff;
|
|
7
|
+
--vp-c-black: #000000;
|
|
8
|
+
|
|
9
|
+
--vp-c-neutral: var(--vp-c-black);
|
|
10
|
+
--vp-c-neutral-inverse: var(--vp-c-white);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.dark {
|
|
14
|
+
--vp-c-neutral: var(--vp-c-white);
|
|
15
|
+
--vp-c-neutral-inverse: var(--vp-c-black);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Colors: Palette
|
|
20
|
+
*
|
|
21
|
+
* The primitive colors used for accent colors. These colors are referenced
|
|
22
|
+
* by functional colors such as "Text", "Background", or "Brand".
|
|
23
|
+
*
|
|
24
|
+
* Each colors have exact same color scale system with 3 levels of solid
|
|
25
|
+
* colors with different brightness, and 1 soft color.
|
|
26
|
+
*
|
|
27
|
+
* - `XXX-1`: The most solid color used mainly for colored text. It must
|
|
28
|
+
* satisfy the contrast ratio against when used on top of `XXX-soft`.
|
|
29
|
+
*
|
|
30
|
+
* - `XXX-2`: The color used mainly for hover state of the button.
|
|
31
|
+
*
|
|
32
|
+
* - `XXX-3`: The color for solid background, such as bg color of the button.
|
|
33
|
+
* It must satisfy the contrast ratio with pure white (#ffffff) text on
|
|
34
|
+
* top of it.
|
|
35
|
+
*
|
|
36
|
+
* - `XXX-soft`: The color used for subtle background such as custom container
|
|
37
|
+
* or badges. It must satisfy the contrast ratio when putting `XXX-1` colors
|
|
38
|
+
* on top of it.
|
|
39
|
+
*
|
|
40
|
+
* The soft color must be semi transparent alpha channel. This is crucial
|
|
41
|
+
* because it allows adding multiple "soft" colors on top of each other
|
|
42
|
+
* to create a accent, such as when having inline code block inside
|
|
43
|
+
* custom containers.
|
|
44
|
+
* -------------------------------------------------------------------------- */
|
|
45
|
+
|
|
46
|
+
:root {
|
|
47
|
+
--vp-c-gray-1: #dddde3;
|
|
48
|
+
--vp-c-gray-2: #e4e4e9;
|
|
49
|
+
--vp-c-gray-3: #ebebef;
|
|
50
|
+
--vp-c-gray-soft: rgba(142, 150, 170, 0.14);
|
|
51
|
+
|
|
52
|
+
--vp-c-indigo-1: #3451b2;
|
|
53
|
+
--vp-c-indigo-2: #3a5ccc;
|
|
54
|
+
--vp-c-indigo-3: #5672cd;
|
|
55
|
+
--vp-c-indigo-soft: rgba(100, 108, 255, 0.14);
|
|
56
|
+
|
|
57
|
+
--vp-c-purple-1: #6f42c1;
|
|
58
|
+
--vp-c-purple-2: #7e4cc9;
|
|
59
|
+
--vp-c-purple-3: #8e5cd9;
|
|
60
|
+
--vp-c-purple-soft: rgba(159, 122, 234, 0.14);
|
|
61
|
+
|
|
62
|
+
--vp-c-green-1: #18794e;
|
|
63
|
+
--vp-c-green-2: #299764;
|
|
64
|
+
--vp-c-green-3: #30a46c;
|
|
65
|
+
--vp-c-green-soft: rgba(16, 185, 129, 0.14);
|
|
66
|
+
|
|
67
|
+
--vp-c-yellow-1: #915930;
|
|
68
|
+
--vp-c-yellow-2: #946300;
|
|
69
|
+
--vp-c-yellow-3: #9f6a00;
|
|
70
|
+
--vp-c-yellow-soft: rgba(234, 179, 8, 0.14);
|
|
71
|
+
|
|
72
|
+
--vp-c-red-1: #b8272c;
|
|
73
|
+
--vp-c-red-2: #d5393e;
|
|
74
|
+
--vp-c-red-3: #e0575b;
|
|
75
|
+
--vp-c-red-soft: rgba(244, 63, 94, 0.14);
|
|
76
|
+
|
|
77
|
+
--vp-c-sponsor: #db2777;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.dark {
|
|
81
|
+
--vp-c-gray-1: #515c67;
|
|
82
|
+
--vp-c-gray-2: #414853;
|
|
83
|
+
--vp-c-gray-3: #32363f;
|
|
84
|
+
--vp-c-gray-soft: rgba(101, 117, 133, 0.16);
|
|
85
|
+
|
|
86
|
+
--vp-c-indigo-1: #a8b1ff;
|
|
87
|
+
--vp-c-indigo-2: #5c73e7;
|
|
88
|
+
--vp-c-indigo-3: #3e63dd;
|
|
89
|
+
--vp-c-indigo-soft: rgba(100, 108, 255, 0.16);
|
|
90
|
+
|
|
91
|
+
--vp-c-purple-1: #c8abfa;
|
|
92
|
+
--vp-c-purple-2: #a879e6;
|
|
93
|
+
--vp-c-purple-3: #8e5cd9;
|
|
94
|
+
--vp-c-purple-soft: rgba(159, 122, 234, 0.16);
|
|
95
|
+
|
|
96
|
+
--vp-c-green-1: #3dd68c;
|
|
97
|
+
--vp-c-green-2: #30a46c;
|
|
98
|
+
--vp-c-green-3: #298459;
|
|
99
|
+
--vp-c-green-soft: rgba(16, 185, 129, 0.16);
|
|
100
|
+
|
|
101
|
+
--vp-c-yellow-1: #f9b44e;
|
|
102
|
+
--vp-c-yellow-2: #da8b17;
|
|
103
|
+
--vp-c-yellow-3: #a46a0a;
|
|
104
|
+
--vp-c-yellow-soft: rgba(234, 179, 8, 0.16);
|
|
105
|
+
|
|
106
|
+
--vp-c-red-1: #f66f81;
|
|
107
|
+
--vp-c-red-2: #f14158;
|
|
108
|
+
--vp-c-red-3: #b62a3c;
|
|
109
|
+
--vp-c-red-soft: rgba(244, 63, 94, 0.16);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Colors: Background
|
|
114
|
+
*
|
|
115
|
+
* - `bg`: The bg color used for main screen.
|
|
116
|
+
*
|
|
117
|
+
* - `bg-alt`: The alternative bg color used in places such as "sidebar",
|
|
118
|
+
* or "code block".
|
|
119
|
+
*
|
|
120
|
+
* - `bg-elv`: The elevated bg color. This is used at parts where it "floats",
|
|
121
|
+
* such as "dialog".
|
|
122
|
+
*
|
|
123
|
+
* - `bg-soft`: The bg color to slightly distinguish some components from
|
|
124
|
+
* the page. Used for things like "carbon ads" or "table".
|
|
125
|
+
* -------------------------------------------------------------------------- */
|
|
126
|
+
|
|
127
|
+
:root {
|
|
128
|
+
--vp-c-bg: #ffffff;
|
|
129
|
+
--vp-c-bg-alt: #f6f6f7;
|
|
130
|
+
--vp-c-bg-elv: #ffffff;
|
|
131
|
+
--vp-c-bg-soft: #f6f6f7;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.dark {
|
|
135
|
+
--vp-c-bg: #1b1b1f;
|
|
136
|
+
--vp-c-bg-alt: #161618;
|
|
137
|
+
--vp-c-bg-elv: #202127;
|
|
138
|
+
--vp-c-bg-soft: #202127;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Colors: Borders
|
|
143
|
+
*
|
|
144
|
+
* - `divider`: This is used for separators. This is used to divide sections
|
|
145
|
+
* within the same components, such as having separator on "h2" heading.
|
|
146
|
+
*
|
|
147
|
+
* - `border`: This is designed for borders on interactive components.
|
|
148
|
+
* For example this should be used for a button outline.
|
|
149
|
+
*
|
|
150
|
+
* - `gutter`: This is used to divide components in the page. For example
|
|
151
|
+
* the header and the lest of the page.
|
|
152
|
+
* -------------------------------------------------------------------------- */
|
|
153
|
+
|
|
154
|
+
:root {
|
|
155
|
+
--vp-c-border: #c2c2c4;
|
|
156
|
+
--vp-c-divider: #e2e2e3;
|
|
157
|
+
--vp-c-gutter: #e2e2e3;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.dark {
|
|
161
|
+
--vp-c-border: #3c3f44;
|
|
162
|
+
--vp-c-divider: #2e2e32;
|
|
163
|
+
--vp-c-gutter: #000000;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Colors: Text
|
|
168
|
+
*
|
|
169
|
+
* - `text-1`: Used for primary text.
|
|
170
|
+
*
|
|
171
|
+
* - `text-2`: Used for muted texts, such as "inactive menu" or "info texts".
|
|
172
|
+
*
|
|
173
|
+
* - `text-3`: Used for subtle texts, such as "placeholders" or "caret icon".
|
|
174
|
+
* -------------------------------------------------------------------------- */
|
|
175
|
+
|
|
176
|
+
:root {
|
|
177
|
+
--vp-c-text-1: rgba(60, 60, 67);
|
|
178
|
+
--vp-c-text-2: rgba(60, 60, 67, 0.78);
|
|
179
|
+
--vp-c-text-3: rgba(60, 60, 67, 0.56);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.dark {
|
|
183
|
+
--vp-c-text-1: rgba(255, 255, 245, 0.86);
|
|
184
|
+
--vp-c-text-2: rgba(235, 235, 245, 0.6);
|
|
185
|
+
--vp-c-text-3: rgba(235, 235, 245, 0.38);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Colors: Function
|
|
190
|
+
*
|
|
191
|
+
* - `default`: The color used purely for subtle indication without any
|
|
192
|
+
* special meanings attached to it such as bg color for menu hover state.
|
|
193
|
+
*
|
|
194
|
+
* - `brand`: Used for primary brand colors, such as link text, button with
|
|
195
|
+
* brand theme, etc.
|
|
196
|
+
*
|
|
197
|
+
* - `tip`: Used to indicate useful information. The default theme uses the
|
|
198
|
+
* brand color for this by default.
|
|
199
|
+
*
|
|
200
|
+
* - `warning`: Used to indicate warning to the users. Used in custom
|
|
201
|
+
* container, badges, etc.
|
|
202
|
+
*
|
|
203
|
+
* - `danger`: Used to show error, or dangerous message to the users. Used
|
|
204
|
+
* in custom container, badges, etc.
|
|
205
|
+
*
|
|
206
|
+
* To understand the scaling system, refer to "Colors: Palette" section.
|
|
207
|
+
* -------------------------------------------------------------------------- */
|
|
208
|
+
|
|
209
|
+
:root {
|
|
210
|
+
--vp-c-default-1: var(--vp-c-gray-1);
|
|
211
|
+
--vp-c-default-2: var(--vp-c-gray-2);
|
|
212
|
+
--vp-c-default-3: var(--vp-c-gray-3);
|
|
213
|
+
--vp-c-default-soft: var(--vp-c-gray-soft);
|
|
214
|
+
|
|
215
|
+
--vp-c-brand-1: var(--vp-c-indigo-1);
|
|
216
|
+
--vp-c-brand-2: var(--vp-c-indigo-2);
|
|
217
|
+
--vp-c-brand-3: var(--vp-c-indigo-3);
|
|
218
|
+
--vp-c-brand-soft: var(--vp-c-indigo-soft);
|
|
219
|
+
|
|
220
|
+
/* DEPRECATED: Use `--vp-c-brand-1` instead. */
|
|
221
|
+
--vp-c-brand: var(--vp-c-brand-1);
|
|
222
|
+
|
|
223
|
+
--vp-c-tip-1: var(--vp-c-brand-1);
|
|
224
|
+
--vp-c-tip-2: var(--vp-c-brand-2);
|
|
225
|
+
--vp-c-tip-3: var(--vp-c-brand-3);
|
|
226
|
+
--vp-c-tip-soft: var(--vp-c-brand-soft);
|
|
227
|
+
|
|
228
|
+
--vp-c-note-1: var(--vp-c-brand-1);
|
|
229
|
+
--vp-c-note-2: var(--vp-c-brand-2);
|
|
230
|
+
--vp-c-note-3: var(--vp-c-brand-3);
|
|
231
|
+
--vp-c-note-soft: var(--vp-c-brand-soft);
|
|
232
|
+
|
|
233
|
+
--vp-c-success-1: var(--vp-c-green-1);
|
|
234
|
+
--vp-c-success-2: var(--vp-c-green-2);
|
|
235
|
+
--vp-c-success-3: var(--vp-c-green-3);
|
|
236
|
+
--vp-c-success-soft: var(--vp-c-green-soft);
|
|
237
|
+
|
|
238
|
+
--vp-c-important-1: var(--vp-c-purple-1);
|
|
239
|
+
--vp-c-important-2: var(--vp-c-purple-2);
|
|
240
|
+
--vp-c-important-3: var(--vp-c-purple-3);
|
|
241
|
+
--vp-c-important-soft: var(--vp-c-purple-soft);
|
|
242
|
+
|
|
243
|
+
--vp-c-warning-1: var(--vp-c-yellow-1);
|
|
244
|
+
--vp-c-warning-2: var(--vp-c-yellow-2);
|
|
245
|
+
--vp-c-warning-3: var(--vp-c-yellow-3);
|
|
246
|
+
--vp-c-warning-soft: var(--vp-c-yellow-soft);
|
|
247
|
+
|
|
248
|
+
--vp-c-danger-1: var(--vp-c-red-1);
|
|
249
|
+
--vp-c-danger-2: var(--vp-c-red-2);
|
|
250
|
+
--vp-c-danger-3: var(--vp-c-red-3);
|
|
251
|
+
--vp-c-danger-soft: var(--vp-c-red-soft);
|
|
252
|
+
|
|
253
|
+
--vp-c-caution-1: var(--vp-c-red-1);
|
|
254
|
+
--vp-c-caution-2: var(--vp-c-red-2);
|
|
255
|
+
--vp-c-caution-3: var(--vp-c-red-3);
|
|
256
|
+
--vp-c-caution-soft: var(--vp-c-red-soft);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Typography
|
|
261
|
+
* -------------------------------------------------------------------------- */
|
|
262
|
+
|
|
263
|
+
:root {
|
|
264
|
+
--vp-font-family-base: 'Chinese Quotes', Inter, ui-sans-serif, system-ui,
|
|
265
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
|
266
|
+
'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
|
267
|
+
'Noto Color Emoji';
|
|
268
|
+
--vp-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
|
269
|
+
'Liberation Mono', 'Courier New', monospace;
|
|
270
|
+
font-optical-sizing: auto;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Shadows
|
|
275
|
+
* -------------------------------------------------------------------------- */
|
|
276
|
+
|
|
277
|
+
:root {
|
|
278
|
+
--vp-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
|
|
279
|
+
--vp-shadow-2: 0 3px 12px rgba(0, 0, 0, 0.07), 0 1px 4px rgba(0, 0, 0, 0.07);
|
|
280
|
+
--vp-shadow-3: 0 12px 32px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.08);
|
|
281
|
+
--vp-shadow-4: 0 14px 44px rgba(0, 0, 0, 0.12), 0 3px 9px rgba(0, 0, 0, 0.12);
|
|
282
|
+
--vp-shadow-5: 0 18px 56px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.16);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Z-indexes
|
|
287
|
+
* -------------------------------------------------------------------------- */
|
|
288
|
+
|
|
289
|
+
:root {
|
|
290
|
+
--vp-z-index-footer: 10;
|
|
291
|
+
--vp-z-index-local-nav: 20;
|
|
292
|
+
--vp-z-index-nav: 30;
|
|
293
|
+
--vp-z-index-layout-top: 40;
|
|
294
|
+
--vp-z-index-backdrop: 50;
|
|
295
|
+
--vp-z-index-sidebar: 60;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
@media (min-width: 960px) {
|
|
299
|
+
:root {
|
|
300
|
+
--vp-z-index-sidebar: 25;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Layouts
|
|
306
|
+
* -------------------------------------------------------------------------- */
|
|
307
|
+
|
|
308
|
+
:root {
|
|
309
|
+
--vp-layout-max-width: 1440px;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Component: Header Anchor
|
|
314
|
+
* -------------------------------------------------------------------------- */
|
|
315
|
+
|
|
316
|
+
:root {
|
|
317
|
+
--vp-header-anchor-symbol: '#';
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Component: Code
|
|
322
|
+
* -------------------------------------------------------------------------- */
|
|
323
|
+
|
|
324
|
+
:root {
|
|
325
|
+
--vp-code-line-height: 1.7;
|
|
326
|
+
--vp-code-font-size: 0.875em;
|
|
327
|
+
--vp-code-color: var(--vp-c-brand-1);
|
|
328
|
+
--vp-code-link-color: var(--vp-c-brand-1);
|
|
329
|
+
--vp-code-link-hover-color: var(--vp-c-brand-2);
|
|
330
|
+
--vp-code-bg: var(--vp-c-default-soft);
|
|
331
|
+
|
|
332
|
+
--vp-code-block-color: var(--vp-c-text-2);
|
|
333
|
+
--vp-code-block-bg: var(--vp-c-bg-alt);
|
|
334
|
+
--vp-code-block-divider-color: var(--vp-c-gutter);
|
|
335
|
+
|
|
336
|
+
--vp-code-lang-color: var(--vp-c-text-3);
|
|
337
|
+
|
|
338
|
+
--vp-code-line-highlight-color: var(--vp-c-default-soft);
|
|
339
|
+
--vp-code-line-number-color: var(--vp-c-text-3);
|
|
340
|
+
|
|
341
|
+
--vp-code-line-diff-add-color: var(--vp-c-success-soft);
|
|
342
|
+
--vp-code-line-diff-add-symbol-color: var(--vp-c-success-1);
|
|
343
|
+
|
|
344
|
+
--vp-code-line-diff-remove-color: var(--vp-c-danger-soft);
|
|
345
|
+
--vp-code-line-diff-remove-symbol-color: var(--vp-c-danger-1);
|
|
346
|
+
|
|
347
|
+
--vp-code-line-warning-color: var(--vp-c-warning-soft);
|
|
348
|
+
--vp-code-line-error-color: var(--vp-c-danger-soft);
|
|
349
|
+
|
|
350
|
+
--vp-code-copy-code-border-color: var(--vp-c-divider);
|
|
351
|
+
--vp-code-copy-code-bg: var(--vp-c-bg-soft);
|
|
352
|
+
--vp-code-copy-code-hover-border-color: var(--vp-c-divider);
|
|
353
|
+
--vp-code-copy-code-hover-bg: var(--vp-c-bg);
|
|
354
|
+
--vp-code-copy-code-active-text: var(--vp-c-text-2);
|
|
355
|
+
--vp-code-copy-copied-text-content: 'Copied';
|
|
356
|
+
|
|
357
|
+
--vp-code-tab-divider: var(--vp-code-block-divider-color);
|
|
358
|
+
--vp-code-tab-text-color: var(--vp-c-text-2);
|
|
359
|
+
--vp-code-tab-bg: var(--vp-code-block-bg);
|
|
360
|
+
--vp-code-tab-hover-text-color: var(--vp-c-text-1);
|
|
361
|
+
--vp-code-tab-active-text-color: var(--vp-c-text-1);
|
|
362
|
+
--vp-code-tab-active-bar-color: var(--vp-c-brand-1);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Component: Button
|
|
367
|
+
* -------------------------------------------------------------------------- */
|
|
368
|
+
|
|
369
|
+
:root {
|
|
370
|
+
--vp-button-brand-border: transparent;
|
|
371
|
+
--vp-button-brand-text: var(--vp-c-white);
|
|
372
|
+
--vp-button-brand-bg: var(--vp-c-brand-3);
|
|
373
|
+
--vp-button-brand-hover-border: transparent;
|
|
374
|
+
--vp-button-brand-hover-text: var(--vp-c-white);
|
|
375
|
+
--vp-button-brand-hover-bg: var(--vp-c-brand-2);
|
|
376
|
+
--vp-button-brand-active-border: transparent;
|
|
377
|
+
--vp-button-brand-active-text: var(--vp-c-white);
|
|
378
|
+
--vp-button-brand-active-bg: var(--vp-c-brand-1);
|
|
379
|
+
|
|
380
|
+
--vp-button-alt-border: transparent;
|
|
381
|
+
--vp-button-alt-text: var(--vp-c-text-1);
|
|
382
|
+
--vp-button-alt-bg: var(--vp-c-default-3);
|
|
383
|
+
--vp-button-alt-hover-border: transparent;
|
|
384
|
+
--vp-button-alt-hover-text: var(--vp-c-text-1);
|
|
385
|
+
--vp-button-alt-hover-bg: var(--vp-c-default-2);
|
|
386
|
+
--vp-button-alt-active-border: transparent;
|
|
387
|
+
--vp-button-alt-active-text: var(--vp-c-text-1);
|
|
388
|
+
--vp-button-alt-active-bg: var(--vp-c-default-1);
|
|
389
|
+
|
|
390
|
+
--vp-button-sponsor-border: var(--vp-c-text-2);
|
|
391
|
+
--vp-button-sponsor-text: var(--vp-c-text-2);
|
|
392
|
+
--vp-button-sponsor-bg: transparent;
|
|
393
|
+
--vp-button-sponsor-hover-border: var(--vp-c-sponsor);
|
|
394
|
+
--vp-button-sponsor-hover-text: var(--vp-c-sponsor);
|
|
395
|
+
--vp-button-sponsor-hover-bg: transparent;
|
|
396
|
+
--vp-button-sponsor-active-border: var(--vp-c-sponsor);
|
|
397
|
+
--vp-button-sponsor-active-text: var(--vp-c-sponsor);
|
|
398
|
+
--vp-button-sponsor-active-bg: transparent;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Component: Custom Block
|
|
403
|
+
* -------------------------------------------------------------------------- */
|
|
404
|
+
|
|
405
|
+
:root {
|
|
406
|
+
--vp-custom-block-font-size: 14px;
|
|
407
|
+
--vp-custom-block-code-font-size: 13px;
|
|
408
|
+
|
|
409
|
+
--vp-custom-block-info-border: transparent;
|
|
410
|
+
--vp-custom-block-info-text: var(--vp-c-text-1);
|
|
411
|
+
--vp-custom-block-info-bg: var(--vp-c-default-soft);
|
|
412
|
+
--vp-custom-block-info-code-bg: var(--vp-c-default-soft);
|
|
413
|
+
|
|
414
|
+
--vp-custom-block-note-border: transparent;
|
|
415
|
+
--vp-custom-block-note-text: var(--vp-c-text-1);
|
|
416
|
+
--vp-custom-block-note-bg: var(--vp-c-default-soft);
|
|
417
|
+
--vp-custom-block-note-code-bg: var(--vp-c-default-soft);
|
|
418
|
+
|
|
419
|
+
--vp-custom-block-tip-border: transparent;
|
|
420
|
+
--vp-custom-block-tip-text: var(--vp-c-text-1);
|
|
421
|
+
--vp-custom-block-tip-bg: var(--vp-c-tip-soft);
|
|
422
|
+
--vp-custom-block-tip-code-bg: var(--vp-c-tip-soft);
|
|
423
|
+
|
|
424
|
+
--vp-custom-block-important-border: transparent;
|
|
425
|
+
--vp-custom-block-important-text: var(--vp-c-text-1);
|
|
426
|
+
--vp-custom-block-important-bg: var(--vp-c-important-soft);
|
|
427
|
+
--vp-custom-block-important-code-bg: var(--vp-c-important-soft);
|
|
428
|
+
|
|
429
|
+
--vp-custom-block-warning-border: transparent;
|
|
430
|
+
--vp-custom-block-warning-text: var(--vp-c-text-1);
|
|
431
|
+
--vp-custom-block-warning-bg: var(--vp-c-warning-soft);
|
|
432
|
+
--vp-custom-block-warning-code-bg: var(--vp-c-warning-soft);
|
|
433
|
+
|
|
434
|
+
--vp-custom-block-danger-border: transparent;
|
|
435
|
+
--vp-custom-block-danger-text: var(--vp-c-text-1);
|
|
436
|
+
--vp-custom-block-danger-bg: var(--vp-c-danger-soft);
|
|
437
|
+
--vp-custom-block-danger-code-bg: var(--vp-c-danger-soft);
|
|
438
|
+
|
|
439
|
+
--vp-custom-block-caution-border: transparent;
|
|
440
|
+
--vp-custom-block-caution-text: var(--vp-c-text-1);
|
|
441
|
+
--vp-custom-block-caution-bg: var(--vp-c-caution-soft);
|
|
442
|
+
--vp-custom-block-caution-code-bg: var(--vp-c-caution-soft);
|
|
443
|
+
|
|
444
|
+
--vp-custom-block-details-border: var(--vp-custom-block-info-border);
|
|
445
|
+
--vp-custom-block-details-text: var(--vp-custom-block-info-text);
|
|
446
|
+
--vp-custom-block-details-bg: var(--vp-custom-block-info-bg);
|
|
447
|
+
--vp-custom-block-details-code-bg: var(--vp-custom-block-info-code-bg);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Component: Input
|
|
452
|
+
* -------------------------------------------------------------------------- */
|
|
453
|
+
|
|
454
|
+
:root {
|
|
455
|
+
--vp-input-border-color: var(--vp-c-border);
|
|
456
|
+
--vp-input-bg-color: var(--vp-c-bg-alt);
|
|
457
|
+
|
|
458
|
+
--vp-input-switch-bg-color: var(--vp-c-default-soft);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Component: Nav
|
|
463
|
+
* -------------------------------------------------------------------------- */
|
|
464
|
+
|
|
465
|
+
:root {
|
|
466
|
+
--vp-nav-height: 64px;
|
|
467
|
+
--vp-nav-bg-color: var(--vp-c-bg);
|
|
468
|
+
--vp-nav-screen-bg-color: var(--vp-c-bg);
|
|
469
|
+
--vp-nav-logo-height: 24px;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.hide-nav {
|
|
473
|
+
--vp-nav-height: 0px;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.hide-nav .VPSidebar {
|
|
477
|
+
--vp-nav-height: 22px;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Component: Local Nav
|
|
482
|
+
* -------------------------------------------------------------------------- */
|
|
483
|
+
|
|
484
|
+
:root {
|
|
485
|
+
--vp-local-nav-bg-color: var(--vp-c-bg);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Component: Sidebar
|
|
490
|
+
* -------------------------------------------------------------------------- */
|
|
491
|
+
|
|
492
|
+
:root {
|
|
493
|
+
--vp-sidebar-width: 272px;
|
|
494
|
+
--vp-sidebar-bg-color: var(--vp-c-bg-alt);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Colors Backdrop
|
|
499
|
+
* -------------------------------------------------------------------------- */
|
|
500
|
+
|
|
501
|
+
:root {
|
|
502
|
+
--vp-backdrop-bg-color: rgba(0, 0, 0, 0.6);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Component: Home
|
|
507
|
+
* -------------------------------------------------------------------------- */
|
|
508
|
+
|
|
509
|
+
:root {
|
|
510
|
+
--vp-home-hero-name-color: var(--vp-c-brand-1);
|
|
511
|
+
--vp-home-hero-name-background: transparent;
|
|
512
|
+
|
|
513
|
+
--vp-home-hero-image-background-image: none;
|
|
514
|
+
--vp-home-hero-image-filter: none;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Component: Badge
|
|
519
|
+
* -------------------------------------------------------------------------- */
|
|
520
|
+
|
|
521
|
+
:root {
|
|
522
|
+
--vp-badge-info-border: transparent;
|
|
523
|
+
--vp-badge-info-text: var(--vp-c-text-2);
|
|
524
|
+
--vp-badge-info-bg: var(--vp-c-default-soft);
|
|
525
|
+
|
|
526
|
+
--vp-badge-tip-border: transparent;
|
|
527
|
+
--vp-badge-tip-text: var(--vp-c-tip-1);
|
|
528
|
+
--vp-badge-tip-bg: var(--vp-c-tip-soft);
|
|
529
|
+
|
|
530
|
+
--vp-badge-warning-border: transparent;
|
|
531
|
+
--vp-badge-warning-text: var(--vp-c-warning-1);
|
|
532
|
+
--vp-badge-warning-bg: var(--vp-c-warning-soft);
|
|
533
|
+
|
|
534
|
+
--vp-badge-danger-border: transparent;
|
|
535
|
+
--vp-badge-danger-text: var(--vp-c-danger-1);
|
|
536
|
+
--vp-badge-danger-bg: var(--vp-c-danger-soft);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Component: Carbon Ads
|
|
541
|
+
* -------------------------------------------------------------------------- */
|
|
542
|
+
|
|
543
|
+
:root {
|
|
544
|
+
--vp-carbon-ads-text-color: var(--vp-c-text-1);
|
|
545
|
+
--vp-carbon-ads-poweredby-color: var(--vp-c-text-2);
|
|
546
|
+
--vp-carbon-ads-bg-color: var(--vp-c-bg-soft);
|
|
547
|
+
--vp-carbon-ads-hover-text-color: var(--vp-c-brand-1);
|
|
548
|
+
--vp-carbon-ads-hover-poweredby-color: var(--vp-c-text-1);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Component: Local Search
|
|
553
|
+
* -------------------------------------------------------------------------- */
|
|
554
|
+
|
|
555
|
+
:root {
|
|
556
|
+
--vp-local-search-bg: var(--vp-c-bg);
|
|
557
|
+
--vp-local-search-result-bg: var(--vp-c-bg);
|
|
558
|
+
--vp-local-search-result-border: var(--vp-c-divider);
|
|
559
|
+
--vp-local-search-result-selected-bg: var(--vp-c-bg);
|
|
560
|
+
--vp-local-search-result-selected-border: var(--vp-c-brand-1);
|
|
561
|
+
--vp-local-search-highlight-bg: var(--vp-c-brand-1);
|
|
562
|
+
--vp-local-search-highlight-text: var(--vp-c-neutral-inverse);
|
|
563
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// adapted from https://stackoverflow.com/a/46432113/11613622
|
|
2
|
+
export class LRUCache {
|
|
3
|
+
max;
|
|
4
|
+
cache;
|
|
5
|
+
constructor(max = 10) {
|
|
6
|
+
this.max = max;
|
|
7
|
+
this.cache = new Map();
|
|
8
|
+
}
|
|
9
|
+
get(key) {
|
|
10
|
+
let item = this.cache.get(key);
|
|
11
|
+
if (item !== undefined) {
|
|
12
|
+
// refresh key
|
|
13
|
+
this.cache.delete(key);
|
|
14
|
+
this.cache.set(key, item);
|
|
15
|
+
}
|
|
16
|
+
return item;
|
|
17
|
+
}
|
|
18
|
+
set(key, val) {
|
|
19
|
+
// refresh key
|
|
20
|
+
if (this.cache.has(key))
|
|
21
|
+
this.cache.delete(key);
|
|
22
|
+
// evict oldest
|
|
23
|
+
else if (this.cache.size === this.max)
|
|
24
|
+
this.cache.delete(this.first());
|
|
25
|
+
this.cache.set(key, val);
|
|
26
|
+
}
|
|
27
|
+
first() {
|
|
28
|
+
return this.cache.keys().next().value;
|
|
29
|
+
}
|
|
30
|
+
clear() {
|
|
31
|
+
this.cache.clear();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ensureStartingSlash } from './utils';
|
|
2
|
+
import { isActive } from '../../shared';
|
|
3
|
+
/**
|
|
4
|
+
* Get the `Sidebar` from sidebar option. This method will ensure to get correct
|
|
5
|
+
* sidebar config from `MultiSideBarConfig` with various path combinations such
|
|
6
|
+
* as matching `guide/` and `/guide/`. If no matching config was found, it will
|
|
7
|
+
* return empty array.
|
|
8
|
+
*/
|
|
9
|
+
export function getSidebar(_sidebar, path) {
|
|
10
|
+
if (Array.isArray(_sidebar))
|
|
11
|
+
return addBase(_sidebar);
|
|
12
|
+
if (_sidebar == null)
|
|
13
|
+
return [];
|
|
14
|
+
path = ensureStartingSlash(path);
|
|
15
|
+
const dir = Object.keys(_sidebar)
|
|
16
|
+
.sort((a, b) => {
|
|
17
|
+
return b.split('/').length - a.split('/').length;
|
|
18
|
+
})
|
|
19
|
+
.find((dir) => {
|
|
20
|
+
// make sure the multi sidebar key starts with slash too
|
|
21
|
+
return path.startsWith(ensureStartingSlash(dir));
|
|
22
|
+
});
|
|
23
|
+
const sidebar = dir ? _sidebar[dir] : [];
|
|
24
|
+
return Array.isArray(sidebar)
|
|
25
|
+
? addBase(sidebar)
|
|
26
|
+
: addBase(sidebar.items, sidebar.base);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get or generate sidebar group from the given sidebar items.
|
|
30
|
+
*/
|
|
31
|
+
export function getSidebarGroups(sidebar) {
|
|
32
|
+
const groups = [];
|
|
33
|
+
let lastGroupIndex = 0;
|
|
34
|
+
for (const index in sidebar) {
|
|
35
|
+
const item = sidebar[index];
|
|
36
|
+
if (item.items) {
|
|
37
|
+
lastGroupIndex = groups.push(item);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (!groups[lastGroupIndex]) {
|
|
41
|
+
groups.push({ items: [] });
|
|
42
|
+
}
|
|
43
|
+
groups[lastGroupIndex].items.push(item);
|
|
44
|
+
}
|
|
45
|
+
return groups;
|
|
46
|
+
}
|
|
47
|
+
export function getFlatSideBarLinks(sidebar) {
|
|
48
|
+
const links = [];
|
|
49
|
+
function recursivelyExtractLinks(items) {
|
|
50
|
+
for (const item of items) {
|
|
51
|
+
if (item.text && item.link) {
|
|
52
|
+
links.push({
|
|
53
|
+
text: item.text,
|
|
54
|
+
link: item.link,
|
|
55
|
+
docFooterText: item.docFooterText
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (item.items) {
|
|
59
|
+
recursivelyExtractLinks(item.items);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
recursivelyExtractLinks(sidebar);
|
|
64
|
+
return links;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if the given sidebar item contains any active link.
|
|
68
|
+
*/
|
|
69
|
+
export function hasActiveLink(path, items) {
|
|
70
|
+
if (Array.isArray(items)) {
|
|
71
|
+
return items.some((item) => hasActiveLink(path, item));
|
|
72
|
+
}
|
|
73
|
+
return isActive(path, items.link)
|
|
74
|
+
? true
|
|
75
|
+
: items.items
|
|
76
|
+
? hasActiveLink(path, items.items)
|
|
77
|
+
: false;
|
|
78
|
+
}
|
|
79
|
+
function addBase(items, _base) {
|
|
80
|
+
return [...items].map((_item) => {
|
|
81
|
+
const item = { ..._item };
|
|
82
|
+
const base = item.base || _base;
|
|
83
|
+
if (base && item.link)
|
|
84
|
+
item.link = base + item.link;
|
|
85
|
+
if (item.items)
|
|
86
|
+
item.items = addBase(item.items, base);
|
|
87
|
+
return item;
|
|
88
|
+
});
|
|
89
|
+
}
|