@vuepress/client 2.0.0-rc.10 → 2.0.0-rc.11
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/app.js +1 -1
- package/dist/{chunk-GA5RAHE7.js → chunk-MPZOAYAQ.js} +24 -59
- package/dist/index.d.ts +11 -101
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/app.js
CHANGED
|
@@ -154,105 +154,70 @@ var RouteLink = defineComponent({
|
|
|
154
154
|
|
|
155
155
|
// src/components/AutoLink.ts
|
|
156
156
|
import { isLinkWithProtocol } from "@vuepress/shared";
|
|
157
|
-
import { computed as computed2, defineComponent as defineComponent2, h as h2 } from "vue";
|
|
157
|
+
import { computed as computed2, defineComponent as defineComponent2, h as h2, toRef } from "vue";
|
|
158
158
|
import { useRoute as useRoute3 } from "vue-router";
|
|
159
159
|
var AutoLink = defineComponent2({
|
|
160
160
|
name: "AutoLink",
|
|
161
161
|
props: {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*/
|
|
165
|
-
activeMatch: {
|
|
166
|
-
type: [String, RegExp],
|
|
167
|
-
default: ""
|
|
168
|
-
},
|
|
169
|
-
/**
|
|
170
|
-
* The `aria-label` attribute
|
|
171
|
-
*/
|
|
172
|
-
ariaLabel: {
|
|
173
|
-
type: String,
|
|
174
|
-
default: ""
|
|
175
|
-
},
|
|
176
|
-
/**
|
|
177
|
-
* Whether the link should be active only if the url is an exact match
|
|
178
|
-
*/
|
|
179
|
-
exact: Boolean,
|
|
180
|
-
/**
|
|
181
|
-
* URL of the auto link
|
|
182
|
-
*/
|
|
183
|
-
link: {
|
|
184
|
-
type: String,
|
|
185
|
-
required: true
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* The `rel` attribute
|
|
189
|
-
*/
|
|
190
|
-
rel: {
|
|
191
|
-
type: String,
|
|
192
|
-
default: ""
|
|
193
|
-
},
|
|
194
|
-
/**
|
|
195
|
-
* The `target` attribute
|
|
196
|
-
*/
|
|
197
|
-
target: {
|
|
198
|
-
type: String,
|
|
199
|
-
default: ""
|
|
200
|
-
},
|
|
201
|
-
/**
|
|
202
|
-
* Text of the auto link
|
|
203
|
-
*/
|
|
204
|
-
text: {
|
|
205
|
-
type: String,
|
|
162
|
+
config: {
|
|
163
|
+
type: Object,
|
|
206
164
|
required: true
|
|
207
165
|
}
|
|
208
166
|
},
|
|
209
167
|
slots: Object,
|
|
210
168
|
setup(props, { slots }) {
|
|
169
|
+
const config = toRef(props, "config");
|
|
211
170
|
const route = useRoute3();
|
|
212
171
|
const siteData = useSiteData();
|
|
213
|
-
const withProtocol = computed2(() => isLinkWithProtocol(
|
|
172
|
+
const withProtocol = computed2(() => isLinkWithProtocol(config.value.link));
|
|
214
173
|
const linkTarget = computed2(
|
|
215
|
-
() =>
|
|
174
|
+
() => config.value.target || (withProtocol.value ? "_blank" : void 0)
|
|
216
175
|
);
|
|
217
176
|
const isBlankTarget = computed2(() => linkTarget.value === "_blank");
|
|
218
177
|
const isInternal = computed2(
|
|
219
178
|
() => !withProtocol.value && !isBlankTarget.value
|
|
220
179
|
);
|
|
221
180
|
const linkRel = computed2(
|
|
222
|
-
() =>
|
|
181
|
+
() => config.value.rel || (isBlankTarget.value ? "noopener noreferrer" : null)
|
|
182
|
+
);
|
|
183
|
+
const linkAriaLabel = computed2(
|
|
184
|
+
() => config.value.ariaLabel ?? config.value.text
|
|
223
185
|
);
|
|
224
|
-
const linkAriaLabel = computed2(() => props.ariaLabel ?? props.text);
|
|
225
186
|
const shouldBeActiveInSubpath = computed2(() => {
|
|
226
|
-
if (
|
|
187
|
+
if (config.value.exact)
|
|
227
188
|
return false;
|
|
228
189
|
const localePaths = Object.keys(siteData.value.locales);
|
|
229
190
|
return localePaths.length ? (
|
|
230
191
|
// Check all the locales
|
|
231
|
-
localePaths.every((key) => key !==
|
|
192
|
+
localePaths.every((key) => key !== config.value.link)
|
|
232
193
|
) : (
|
|
233
194
|
// Check root
|
|
234
|
-
|
|
195
|
+
config.value.link !== "/"
|
|
235
196
|
);
|
|
236
197
|
});
|
|
237
198
|
const isActive = computed2(() => {
|
|
238
199
|
if (!isInternal.value)
|
|
239
200
|
return false;
|
|
240
|
-
if (
|
|
241
|
-
return (
|
|
201
|
+
if (config.value.activeMatch) {
|
|
202
|
+
return (config.value.activeMatch instanceof RegExp ? config.value.activeMatch : new RegExp(config.value.activeMatch, "u")).test(route.path);
|
|
242
203
|
}
|
|
243
204
|
if (shouldBeActiveInSubpath.value) {
|
|
244
|
-
return route.path.startsWith(
|
|
205
|
+
return route.path.startsWith(config.value.link);
|
|
245
206
|
}
|
|
246
|
-
return route.path ===
|
|
207
|
+
return route.path === config.value.link;
|
|
247
208
|
});
|
|
248
209
|
return () => {
|
|
249
210
|
const { before, after, default: defaultSlot } = slots;
|
|
250
|
-
const content = defaultSlot?.() || [
|
|
211
|
+
const content = defaultSlot?.(config.value) || [
|
|
212
|
+
before?.(config.value),
|
|
213
|
+
config.value.text,
|
|
214
|
+
after?.(config.value)
|
|
215
|
+
];
|
|
251
216
|
return isInternal.value ? h2(
|
|
252
217
|
RouteLink,
|
|
253
218
|
{
|
|
254
219
|
"class": "auto-link",
|
|
255
|
-
"to":
|
|
220
|
+
"to": config.value.link,
|
|
256
221
|
"active": isActive.value,
|
|
257
222
|
"aria-label": linkAriaLabel.value
|
|
258
223
|
},
|
|
@@ -261,7 +226,7 @@ var AutoLink = defineComponent2({
|
|
|
261
226
|
"a",
|
|
262
227
|
{
|
|
263
228
|
"class": "auto-link external-link",
|
|
264
|
-
"href":
|
|
229
|
+
"href": config.value.link,
|
|
265
230
|
"aria-label": linkAriaLabel.value,
|
|
266
231
|
"rel": linkRel.value,
|
|
267
232
|
"target": linkTarget.value
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { Component, ComputedRef, Ref, App, VNode, SlotsType, InjectionKey } from 'vue';
|
|
2
|
+
import { Component, ComputedRef, Ref, App, PropType, VNode, SlotsType, InjectionKey } from 'vue';
|
|
3
3
|
import { PageData, HeadConfig, PageFrontmatter, SiteData, SiteLocaleData } from '@vuepress/shared';
|
|
4
4
|
export { HeadConfig, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleData } from '@vuepress/shared';
|
|
5
5
|
import { Router } from 'vue-router';
|
|
@@ -97,7 +97,7 @@ interface ClientConfig {
|
|
|
97
97
|
rootComponents?: Component[];
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
interface
|
|
100
|
+
interface AutoLinkConfig {
|
|
101
101
|
/**
|
|
102
102
|
* Pattern to determine if the link should be active, which has higher priority than `exact`
|
|
103
103
|
*/
|
|
@@ -134,111 +134,21 @@ interface AutoLinkProps {
|
|
|
134
134
|
* - If the link is external, it will be rendered as a normal `<a>` tag
|
|
135
135
|
*/
|
|
136
136
|
declare const AutoLink: vue.DefineComponent<{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
activeMatch: {
|
|
141
|
-
type: (StringConstructor | RegExpConstructor)[];
|
|
142
|
-
default: string;
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* The `aria-label` attribute
|
|
146
|
-
*/
|
|
147
|
-
ariaLabel: {
|
|
148
|
-
type: StringConstructor;
|
|
149
|
-
default: string;
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Whether the link should be active only if the url is an exact match
|
|
153
|
-
*/
|
|
154
|
-
exact: BooleanConstructor;
|
|
155
|
-
/**
|
|
156
|
-
* URL of the auto link
|
|
157
|
-
*/
|
|
158
|
-
link: {
|
|
159
|
-
type: StringConstructor;
|
|
160
|
-
required: true;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* The `rel` attribute
|
|
164
|
-
*/
|
|
165
|
-
rel: {
|
|
166
|
-
type: StringConstructor;
|
|
167
|
-
default: string;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* The `target` attribute
|
|
171
|
-
*/
|
|
172
|
-
target: {
|
|
173
|
-
type: StringConstructor;
|
|
174
|
-
default: string;
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Text of the auto link
|
|
178
|
-
*/
|
|
179
|
-
text: {
|
|
180
|
-
type: StringConstructor;
|
|
137
|
+
config: {
|
|
138
|
+
type: PropType<AutoLinkConfig>;
|
|
181
139
|
required: true;
|
|
182
140
|
};
|
|
183
141
|
}, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
184
142
|
[key: string]: any;
|
|
185
143
|
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*/
|
|
189
|
-
activeMatch: {
|
|
190
|
-
type: (StringConstructor | RegExpConstructor)[];
|
|
191
|
-
default: string;
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* The `aria-label` attribute
|
|
195
|
-
*/
|
|
196
|
-
ariaLabel: {
|
|
197
|
-
type: StringConstructor;
|
|
198
|
-
default: string;
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* Whether the link should be active only if the url is an exact match
|
|
202
|
-
*/
|
|
203
|
-
exact: BooleanConstructor;
|
|
204
|
-
/**
|
|
205
|
-
* URL of the auto link
|
|
206
|
-
*/
|
|
207
|
-
link: {
|
|
208
|
-
type: StringConstructor;
|
|
144
|
+
config: {
|
|
145
|
+
type: PropType<AutoLinkConfig>;
|
|
209
146
|
required: true;
|
|
210
147
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
type: StringConstructor;
|
|
216
|
-
default: string;
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* The `target` attribute
|
|
220
|
-
*/
|
|
221
|
-
target: {
|
|
222
|
-
type: StringConstructor;
|
|
223
|
-
default: string;
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* Text of the auto link
|
|
227
|
-
*/
|
|
228
|
-
text: {
|
|
229
|
-
type: StringConstructor;
|
|
230
|
-
required: true;
|
|
231
|
-
};
|
|
232
|
-
}>>, {
|
|
233
|
-
target: string;
|
|
234
|
-
activeMatch: string | RegExp;
|
|
235
|
-
ariaLabel: string;
|
|
236
|
-
exact: boolean;
|
|
237
|
-
rel: string;
|
|
238
|
-
}, SlotsType<{
|
|
239
|
-
default?: (() => VNode[] | VNode) | undefined;
|
|
240
|
-
before?: (() => VNode[] | VNode | null) | undefined;
|
|
241
|
-
after?: (() => VNode[] | VNode | null) | undefined;
|
|
148
|
+
}>>, {}, SlotsType<{
|
|
149
|
+
default?: ((config: AutoLinkConfig) => VNode[] | VNode) | undefined;
|
|
150
|
+
before?: ((config: AutoLinkConfig) => VNode[] | VNode | null) | undefined;
|
|
151
|
+
after?: ((config: AutoLinkConfig) => VNode[] | VNode | null) | undefined;
|
|
242
152
|
}>>;
|
|
243
153
|
|
|
244
154
|
/**
|
|
@@ -424,4 +334,4 @@ declare const defineClientConfig: (clientConfig?: ClientConfig) => ClientConfig;
|
|
|
424
334
|
*/
|
|
425
335
|
declare const withBase: (url: string) => string;
|
|
426
336
|
|
|
427
|
-
export { AutoLink, type
|
|
337
|
+
export { AutoLink, type AutoLinkConfig, type ClientConfig, type ClientData, ClientOnly, Content, type Layouts, type LayoutsRef, type PageChunk, type PageComponent, type PageComponentRef, type PageDataRef, type PageFrontmatterRef, type PageHead, type PageHeadRef, type PageHeadTitle, type PageHeadTitleRef, type PageLang, type PageLangRef, type PageLayout, type PageLayoutRef, type Redirects, type RedirectsRef, type ResolvedRoute, type Route, RouteLink, type RouteLinkProps, type RouteLocale, type RouteLocaleRef, type RouteMeta, type RoutePath, type RoutePathRef, type Routes, type RoutesRef, type SiteDataRef, type SiteLocaleDataRef, type UpdateHead, clientDataSymbol, defineClientConfig, resolveRoute, resolveRoutePath, resolvers, updateHeadSymbol, useClientData, useLayouts, usePageComponent, usePageData, usePageFrontmatter, usePageHead, usePageLang, usePageLayout, useRedirects, useRouteLocale, useRoutePath, useRoutes, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/client",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.11",
|
|
4
4
|
"description": "Client package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@vue/devtools-api": "^6.6.1",
|
|
37
37
|
"vue": "^3.4.27",
|
|
38
38
|
"vue-router": "^4.3.2",
|
|
39
|
-
"@vuepress/shared": "2.0.0-rc.
|
|
39
|
+
"@vuepress/shared": "2.0.0-rc.11"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|