@vuepress/shared 2.0.0-beta.37 → 2.0.0-beta.40

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.
Files changed (108) hide show
  1. package/dist/index.cjs +198 -0
  2. package/dist/index.d.ts +289 -0
  3. package/dist/index.js +152 -0
  4. package/package.json +36 -13
  5. package/lib/esm/index.d.ts +0 -2
  6. package/lib/esm/index.js +0 -2
  7. package/lib/esm/types/head.d.ts +0 -27
  8. package/lib/esm/types/head.js +0 -1
  9. package/lib/esm/types/index.d.ts +0 -5
  10. package/lib/esm/types/index.js +0 -5
  11. package/lib/esm/types/locale.d.ts +0 -13
  12. package/lib/esm/types/locale.js +0 -1
  13. package/lib/esm/types/page.d.ts +0 -71
  14. package/lib/esm/types/page.js +0 -1
  15. package/lib/esm/types/site.d.ts +0 -42
  16. package/lib/esm/types/site.js +0 -1
  17. package/lib/esm/types/ssr.d.ts +0 -8
  18. package/lib/esm/types/ssr.js +0 -1
  19. package/lib/esm/utils/dedupeHead.d.ts +0 -7
  20. package/lib/esm/utils/dedupeHead.js +0 -18
  21. package/lib/esm/utils/ensureEndingSlash.d.ts +0 -4
  22. package/lib/esm/utils/ensureEndingSlash.js +0 -4
  23. package/lib/esm/utils/ensureLeadingSlash.d.ts +0 -4
  24. package/lib/esm/utils/ensureLeadingSlash.js +0 -4
  25. package/lib/esm/utils/formatDateString.d.ts +0 -4
  26. package/lib/esm/utils/formatDateString.js +0 -14
  27. package/lib/esm/utils/htmlEscape.d.ts +0 -4
  28. package/lib/esm/utils/htmlEscape.js +0 -12
  29. package/lib/esm/utils/htmlUnescape.d.ts +0 -4
  30. package/lib/esm/utils/htmlUnescape.js +0 -17
  31. package/lib/esm/utils/index.d.ts +0 -19
  32. package/lib/esm/utils/index.js +0 -19
  33. package/lib/esm/utils/isLinkExternal.d.ts +0 -4
  34. package/lib/esm/utils/isLinkExternal.js +0 -16
  35. package/lib/esm/utils/isLinkFtp.d.ts +0 -4
  36. package/lib/esm/utils/isLinkFtp.js +0 -4
  37. package/lib/esm/utils/isLinkHttp.d.ts +0 -8
  38. package/lib/esm/utils/isLinkHttp.js +0 -8
  39. package/lib/esm/utils/isLinkMailto.d.ts +0 -4
  40. package/lib/esm/utils/isLinkMailto.js +0 -4
  41. package/lib/esm/utils/isLinkTel.d.ts +0 -4
  42. package/lib/esm/utils/isLinkTel.js +0 -4
  43. package/lib/esm/utils/isPlainObject.d.ts +0 -4
  44. package/lib/esm/utils/isPlainObject.js +0 -4
  45. package/lib/esm/utils/normalizePackageName.d.ts +0 -4
  46. package/lib/esm/utils/normalizePackageName.js +0 -37
  47. package/lib/esm/utils/removeEndingSlash.d.ts +0 -4
  48. package/lib/esm/utils/removeEndingSlash.js +0 -4
  49. package/lib/esm/utils/removeLeadingSlash.d.ts +0 -4
  50. package/lib/esm/utils/removeLeadingSlash.js +0 -4
  51. package/lib/esm/utils/resolveHeadIdentifier.d.ts +0 -5
  52. package/lib/esm/utils/resolveHeadIdentifier.js +0 -18
  53. package/lib/esm/utils/resolveLocalePath.d.ts +0 -5
  54. package/lib/esm/utils/resolveLocalePath.js +0 -18
  55. package/lib/esm/utils/resolveRoutePathFromUrl.d.ts +0 -1
  56. package/lib/esm/utils/resolveRoutePathFromUrl.js +0 -5
  57. package/lib/index.d.ts +0 -2
  58. package/lib/index.js +0 -18
  59. package/lib/types/head.d.ts +0 -27
  60. package/lib/types/head.js +0 -2
  61. package/lib/types/index.d.ts +0 -5
  62. package/lib/types/index.js +0 -21
  63. package/lib/types/locale.d.ts +0 -13
  64. package/lib/types/locale.js +0 -2
  65. package/lib/types/page.d.ts +0 -71
  66. package/lib/types/page.js +0 -2
  67. package/lib/types/site.d.ts +0 -42
  68. package/lib/types/site.js +0 -2
  69. package/lib/types/ssr.d.ts +0 -8
  70. package/lib/types/ssr.js +0 -2
  71. package/lib/utils/dedupeHead.d.ts +0 -7
  72. package/lib/utils/dedupeHead.js +0 -22
  73. package/lib/utils/ensureEndingSlash.d.ts +0 -4
  74. package/lib/utils/ensureEndingSlash.js +0 -8
  75. package/lib/utils/ensureLeadingSlash.d.ts +0 -4
  76. package/lib/utils/ensureLeadingSlash.js +0 -8
  77. package/lib/utils/formatDateString.d.ts +0 -4
  78. package/lib/utils/formatDateString.js +0 -18
  79. package/lib/utils/htmlEscape.d.ts +0 -4
  80. package/lib/utils/htmlEscape.js +0 -16
  81. package/lib/utils/htmlUnescape.d.ts +0 -4
  82. package/lib/utils/htmlUnescape.js +0 -21
  83. package/lib/utils/index.d.ts +0 -19
  84. package/lib/utils/index.js +0 -40
  85. package/lib/utils/isLinkExternal.d.ts +0 -4
  86. package/lib/utils/isLinkExternal.js +0 -20
  87. package/lib/utils/isLinkFtp.d.ts +0 -4
  88. package/lib/utils/isLinkFtp.js +0 -8
  89. package/lib/utils/isLinkHttp.d.ts +0 -8
  90. package/lib/utils/isLinkHttp.js +0 -12
  91. package/lib/utils/isLinkMailto.d.ts +0 -4
  92. package/lib/utils/isLinkMailto.js +0 -8
  93. package/lib/utils/isLinkTel.d.ts +0 -4
  94. package/lib/utils/isLinkTel.js +0 -8
  95. package/lib/utils/isPlainObject.d.ts +0 -4
  96. package/lib/utils/isPlainObject.js +0 -8
  97. package/lib/utils/normalizePackageName.d.ts +0 -4
  98. package/lib/utils/normalizePackageName.js +0 -41
  99. package/lib/utils/removeEndingSlash.d.ts +0 -4
  100. package/lib/utils/removeEndingSlash.js +0 -8
  101. package/lib/utils/removeLeadingSlash.d.ts +0 -4
  102. package/lib/utils/removeLeadingSlash.js +0 -8
  103. package/lib/utils/resolveHeadIdentifier.d.ts +0 -5
  104. package/lib/utils/resolveHeadIdentifier.js +0 -22
  105. package/lib/utils/resolveLocalePath.d.ts +0 -5
  106. package/lib/utils/resolveLocalePath.js +0 -22
  107. package/lib/utils/resolveRoutePathFromUrl.d.ts +0 -1
  108. package/lib/utils/resolveRoutePathFromUrl.js +0 -9
@@ -1,27 +0,0 @@
1
- /**
2
- * Config for `<head>` tags
3
- *
4
- * @example ['link', { rel: 'icon', href: '/logo.png' }]
5
- * @example ['style', { type: 'text/css' }, 'p { color: red; }']
6
- *
7
- * @remark suffix `Config` means this is for user config
8
- */
9
- export declare type HeadConfig = [HeadTagEmpty, HeadAttrsConfig] | [HeadTagNonEmpty, HeadAttrsConfig, string];
10
- /**
11
- * Allowed tags in `<head>`
12
- *
13
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head
14
- */
15
- export declare type HeadTag = HeadTagNonEmpty | HeadTagEmpty;
16
- /**
17
- * Non-empty tags in `<head>`
18
- */
19
- export declare type HeadTagNonEmpty = 'title' | 'style' | 'script' | 'noscript' | 'template';
20
- /**
21
- * Empty tags in `<head>`
22
- */
23
- export declare type HeadTagEmpty = 'base' | 'link' | 'meta' | 'script';
24
- /**
25
- * Attributes to be set for tags in `<head>`
26
- */
27
- export declare type HeadAttrsConfig = Record<string, string | boolean>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- export * from './head';
2
- export * from './locale';
3
- export * from './page';
4
- export * from './site';
5
- export * from './ssr';
@@ -1,5 +0,0 @@
1
- export * from './head';
2
- export * from './locale';
3
- export * from './page';
4
- export * from './site';
5
- export * from './ssr';
@@ -1,13 +0,0 @@
1
- /**
2
- * Locales config, a key-value object
3
- *
4
- * - Key is the locale path (prefix)
5
- * - Value is the locales data
6
- *
7
- * @remark suffix `Config` means this is for user config
8
- */
9
- export declare type LocaleConfig<T extends LocaleData = LocaleData> = Record<string, Partial<T>>;
10
- /**
11
- * Locales data
12
- */
13
- export declare type LocaleData = Record<string, any>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,71 +0,0 @@
1
- import type { HeadConfig } from './head';
2
- /**
3
- * Vuepress page data
4
- */
5
- export declare type PageData<ExtraPageData extends Record<any, any> = Record<never, never>> = ExtraPageData & {
6
- /**
7
- * Identifier of the page
8
- *
9
- * Will also be used as the component name
10
- *
11
- * @example 'v-foobar'
12
- */
13
- key: string;
14
- /**
15
- * Route path of the page
16
- *
17
- * Firstly inferred from the file path
18
- *
19
- * Might be overridden by permalink
20
- *
21
- * @example '/guide/index.html'
22
- * @example '/2020/02/02/hello-world.html'
23
- */
24
- path: string;
25
- /**
26
- * Title of the page
27
- */
28
- title: string;
29
- /**
30
- * Language of the page
31
- */
32
- lang: string;
33
- /**
34
- * Front matter of the page
35
- */
36
- frontmatter: PageFrontmatter;
37
- /**
38
- * Excerpt of the page
39
- */
40
- excerpt: string;
41
- /**
42
- * Headers of the page
43
- */
44
- headers: PageHeader[];
45
- };
46
- /**
47
- * Vuepress page frontmatter
48
- *
49
- * Notice that frontmatter is parsed from yaml or other languages,
50
- * so we cannot guarantee the type safety
51
- */
52
- export declare type PageFrontmatter<T extends Record<any, any> = Record<string, unknown>> = Partial<T> & {
53
- date?: string | Date;
54
- description?: string;
55
- head?: HeadConfig[];
56
- lang?: string;
57
- layout?: string;
58
- permalink?: string;
59
- permalinkPattern?: string;
60
- routeMeta?: Record<string, unknown>;
61
- title?: string;
62
- };
63
- /**
64
- * Vuepress page header
65
- */
66
- export interface PageHeader {
67
- level: number;
68
- title: string;
69
- slug: string;
70
- children: PageHeader[];
71
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,42 +0,0 @@
1
- import type { HeadConfig } from './head';
2
- import type { LocaleConfig } from './locale';
3
- /**
4
- * Vuepress site data
5
- */
6
- export interface SiteData extends SiteLocaleData {
7
- base: '/' | `/${string}/`;
8
- locales: SiteLocaleConfig;
9
- }
10
- /**
11
- * Locales data of vuepress site
12
- *
13
- * If they are set in the root of site data, they will be used
14
- * as the default value
15
- *
16
- * If they are set in the `locales` of site data, they will be
17
- * used for specific locale
18
- */
19
- export interface SiteLocaleData {
20
- lang: string;
21
- title: string;
22
- description: string;
23
- head: HeadConfig[];
24
- }
25
- /**
26
- * Site locale config
27
- *
28
- * @example
29
- * {
30
- * '/en/': {
31
- * lang: 'en-US',
32
- * title: 'Hello',
33
- * },
34
- * '/zh/: {
35
- * lang: 'zh-CN',
36
- * title: '你好',
37
- * }
38
- * }
39
- *
40
- * @remark suffix `Config` means this is for user config
41
- */
42
- export declare type SiteLocaleConfig = LocaleConfig<SiteLocaleData>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import type { HeadConfig } from './head';
2
- /**
3
- * Context for SSR
4
- */
5
- export interface VuepressSSRContext {
6
- lang: string;
7
- head: HeadConfig[];
8
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import type { HeadConfig } from '../types';
2
- /**
3
- * Dedupe head config with identifier
4
- *
5
- * Items that appear earlier have higher priority
6
- */
7
- export declare const dedupeHead: (head: HeadConfig[]) => HeadConfig[];
@@ -1,18 +0,0 @@
1
- import { resolveHeadIdentifier } from './resolveHeadIdentifier';
2
- /**
3
- * Dedupe head config with identifier
4
- *
5
- * Items that appear earlier have higher priority
6
- */
7
- export const dedupeHead = (head) => {
8
- const identifierSet = new Set();
9
- const result = [];
10
- head.forEach((item) => {
11
- const identifier = resolveHeadIdentifier(item);
12
- if (!identifierSet.has(identifier)) {
13
- identifierSet.add(identifier);
14
- result.push(item);
15
- }
16
- });
17
- return result;
18
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * Ensure a url string to have ending slash /
3
- */
4
- export declare const ensureEndingSlash: (str: string) => string;
@@ -1,4 +0,0 @@
1
- /**
2
- * Ensure a url string to have ending slash /
3
- */
4
- export const ensureEndingSlash = (str) => /(\.html|\/)$/.test(str) ? str : str + '/';
@@ -1,4 +0,0 @@
1
- /**
2
- * Ensure a url string to have leading slash /
3
- */
4
- export declare const ensureLeadingSlash: (str: string) => string;
@@ -1,4 +0,0 @@
1
- /**
2
- * Ensure a url string to have leading slash /
3
- */
4
- export const ensureLeadingSlash = (str) => str.replace(/^\/?/, '/');
@@ -1,4 +0,0 @@
1
- /**
2
- * Format a date string to `yyyy-MM-dd`
3
- */
4
- export declare const formatDateString: (str: string, defaultDateString?: string) => string;
@@ -1,14 +0,0 @@
1
- /**
2
- * Format a date string to `yyyy-MM-dd`
3
- */
4
- export const formatDateString = (str, defaultDateString = '') => {
5
- // match the `yyyy-(M)M-(d)d` pattern
6
- const dateMatch = str.match(/\b(\d{4})-(\d{1,2})-(\d{1,2})\b/);
7
- // return `defaultDateString` if no matched pattern
8
- if (dateMatch === null) {
9
- return defaultDateString;
10
- }
11
- // fill leading zeros for month and day
12
- const [, yearStr, monthStr, dayStr] = dateMatch;
13
- return [yearStr, monthStr.padStart(2, '0'), dayStr.padStart(2, '0')].join('-');
14
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * Escape html chars
3
- */
4
- export declare const htmlEscape: (str: string) => string;
@@ -1,12 +0,0 @@
1
- const htmlEscapeMap = {
2
- '&': '&amp;',
3
- '<': '&lt;',
4
- '>': '&gt;',
5
- "'": '&#39;',
6
- '"': '&quot;',
7
- };
8
- const htmlEscapeRegexp = /[&<>'"]/g;
9
- /**
10
- * Escape html chars
11
- */
12
- export const htmlEscape = (str) => str.replace(htmlEscapeRegexp, (char) => htmlEscapeMap[char]);
@@ -1,4 +0,0 @@
1
- /**
2
- * Unescape html chars
3
- */
4
- export declare const htmlUnescape: (str: string) => string;
@@ -1,17 +0,0 @@
1
- const htmlUnescapeMap = {
2
- '&amp;': '&',
3
- '&#38;': '&',
4
- '&lt;': '<',
5
- '&#60;': '<',
6
- '&gt;': '>',
7
- '&#62;': '>',
8
- '&apos;': "'",
9
- '&#39;': "'",
10
- '&quot;': '"',
11
- '&#34;': '"',
12
- };
13
- const htmlUnescapeRegexp = /&(amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
14
- /**
15
- * Unescape html chars
16
- */
17
- export const htmlUnescape = (str) => str.replace(htmlUnescapeRegexp, (char) => htmlUnescapeMap[char]);
@@ -1,19 +0,0 @@
1
- export { isArray, isFunction, isPromise, isString } from '@vue/shared';
2
- export * from './dedupeHead';
3
- export * from './ensureLeadingSlash';
4
- export * from './ensureEndingSlash';
5
- export * from './formatDateString';
6
- export * from './htmlEscape';
7
- export * from './htmlUnescape';
8
- export * from './isLinkExternal';
9
- export * from './isLinkFtp';
10
- export * from './isLinkHttp';
11
- export * from './isLinkMailto';
12
- export * from './isLinkTel';
13
- export * from './isPlainObject';
14
- export * from './normalizePackageName';
15
- export * from './removeEndingSlash';
16
- export * from './removeLeadingSlash';
17
- export * from './resolveHeadIdentifier';
18
- export * from './resolveLocalePath';
19
- export * from './resolveRoutePathFromUrl';
@@ -1,19 +0,0 @@
1
- export { isArray, isFunction, isPromise, isString } from '@vue/shared';
2
- export * from './dedupeHead';
3
- export * from './ensureLeadingSlash';
4
- export * from './ensureEndingSlash';
5
- export * from './formatDateString';
6
- export * from './htmlEscape';
7
- export * from './htmlUnescape';
8
- export * from './isLinkExternal';
9
- export * from './isLinkFtp';
10
- export * from './isLinkHttp';
11
- export * from './isLinkMailto';
12
- export * from './isLinkTel';
13
- export * from './isPlainObject';
14
- export * from './normalizePackageName';
15
- export * from './removeEndingSlash';
16
- export * from './removeLeadingSlash';
17
- export * from './resolveHeadIdentifier';
18
- export * from './resolveLocalePath';
19
- export * from './resolveRoutePathFromUrl';
@@ -1,4 +0,0 @@
1
- /**
2
- * Determine a link is external or not
3
- */
4
- export declare const isLinkExternal: (link: string, base?: string) => boolean;
@@ -1,16 +0,0 @@
1
- import { isLinkFtp } from './isLinkFtp';
2
- import { isLinkHttp } from './isLinkHttp';
3
- /**
4
- * Determine a link is external or not
5
- */
6
- export const isLinkExternal = (link, base = '/') => {
7
- // http link or ftp link
8
- if (isLinkHttp(link) || isLinkFtp(link)) {
9
- return true;
10
- }
11
- // absolute link that does not start with `base`
12
- if (link.startsWith('/') && !link.startsWith(base)) {
13
- return true;
14
- }
15
- return false;
16
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * Determine a link is ftp link or not
3
- */
4
- export declare const isLinkFtp: (link: string) => boolean;
@@ -1,4 +0,0 @@
1
- /**
2
- * Determine a link is ftp link or not
3
- */
4
- export const isLinkFtp = (link) => link.startsWith('ftp://');
@@ -1,8 +0,0 @@
1
- /**
2
- * Determine a link is http link or not
3
- *
4
- * - http://github.com
5
- * - https://github.com
6
- * - //github.com
7
- */
8
- export declare const isLinkHttp: (link: string) => boolean;
@@ -1,8 +0,0 @@
1
- /**
2
- * Determine a link is http link or not
3
- *
4
- * - http://github.com
5
- * - https://github.com
6
- * - //github.com
7
- */
8
- export const isLinkHttp = (link) => /^(https?:)?\/\//.test(link);
@@ -1,4 +0,0 @@
1
- /**
2
- * Determine a link is a mailto: address or not
3
- */
4
- export declare const isLinkMailto: (link: string) => boolean;
@@ -1,4 +0,0 @@
1
- /**
2
- * Determine a link is a mailto: address or not
3
- */
4
- export const isLinkMailto = (link) => /^mailto:/.test(link);
@@ -1,4 +0,0 @@
1
- /**
2
- * Determine a link is a tel: address or not
3
- */
4
- export declare const isLinkTel: (link: string) => boolean;
@@ -1,4 +0,0 @@
1
- /**
2
- * Determine a link is a tel: address or not
3
- */
4
- export const isLinkTel = (link) => /^tel:/.test(link);
@@ -1,4 +0,0 @@
1
- /**
2
- * Check if a value is plain object, with generic type support
3
- */
4
- export declare const isPlainObject: <T extends Record<any, any> = Record<any, any>>(val: unknown) => val is T;
@@ -1,4 +0,0 @@
1
- /**
2
- * Check if a value is plain object, with generic type support
3
- */
4
- export const isPlainObject = (val) => Object.prototype.toString.call(val) === '[object Object]';
@@ -1,4 +0,0 @@
1
- /**
2
- * Normalize package name
3
- */
4
- export declare const normalizePackageName: (request: string, org: string, type?: string | null) => string;
@@ -1,37 +0,0 @@
1
- /**
2
- * Normalize package name
3
- */
4
- export const normalizePackageName = (request, org, type = null) => {
5
- // org prefix and type prefix
6
- const orgPrefix = `${org}-`;
7
- const typePrefix = type === null ? '' : `${type}-`;
8
- // scoped package pattern
9
- const scopedMatch = request.match(/^@(.*)\/(.*)$/);
10
- // handle non-scoped package
11
- if (scopedMatch === null) {
12
- // full name, return as is
13
- if (request.startsWith(`${orgPrefix}${typePrefix}`)) {
14
- return request;
15
- }
16
- // short name, add org prefix and type prefix
17
- return `${orgPrefix}${typePrefix}${request}`;
18
- }
19
- // handle scoped package
20
- const [, reqOrg, reqName] = scopedMatch;
21
- // handle default org
22
- if (reqOrg === org) {
23
- // full name, return as is
24
- if (reqName.startsWith(typePrefix)) {
25
- return request;
26
- }
27
- // short name, add type prefix
28
- return `@${reqOrg}/${typePrefix}${reqName}`;
29
- }
30
- // handle other org
31
- // full name, return as is
32
- if (reqName.startsWith(`${orgPrefix}${typePrefix}`)) {
33
- return request;
34
- }
35
- // short name, add org prefix and type prefix
36
- return `@${reqOrg}/${orgPrefix}${typePrefix}${reqName}`;
37
- };
@@ -1,4 +0,0 @@
1
- /**
2
- * Remove ending slash / from a string
3
- */
4
- export declare const removeEndingSlash: (str: string) => string;
@@ -1,4 +0,0 @@
1
- /**
2
- * Remove ending slash / from a string
3
- */
4
- export const removeEndingSlash = (str) => str.replace(/\/$/, '');
@@ -1,4 +0,0 @@
1
- /**
2
- * Remove leading slash / from a string
3
- */
4
- export declare const removeLeadingSlash: (str: string) => string;
@@ -1,4 +0,0 @@
1
- /**
2
- * Remove leading slash / from a string
3
- */
4
- export const removeLeadingSlash = (str) => str.replace(/^\//, '');
@@ -1,5 +0,0 @@
1
- import type { HeadConfig } from '../types';
2
- /**
3
- * Resolve identifier of a tag, to avoid duplicated tags in `<head>`
4
- */
5
- export declare const resolveHeadIdentifier: ([tag, attrs, content,]: HeadConfig) => string;
@@ -1,18 +0,0 @@
1
- /**
2
- * Resolve identifier of a tag, to avoid duplicated tags in `<head>`
3
- */
4
- export const resolveHeadIdentifier = ([tag, attrs, content,]) => {
5
- // avoid duplicated `<meta>` with same `name`
6
- if (tag === 'meta' && attrs.name) {
7
- return `${tag}.${attrs.name}`;
8
- }
9
- // there should be only one `<title>` or `<base>`
10
- if (['title', 'base'].includes(tag)) {
11
- return tag;
12
- }
13
- // avoid duplicated `<template>` with same `id`
14
- if (tag === 'template' && attrs.id) {
15
- return `${tag}.${attrs.id}`;
16
- }
17
- return JSON.stringify([tag, attrs, content]);
18
- };
@@ -1,5 +0,0 @@
1
- import type { LocaleConfig } from '../types';
2
- /**
3
- * Resolve the matched locale path of route path
4
- */
5
- export declare const resolveLocalePath: (locales: LocaleConfig, routePath: string) => string;
@@ -1,18 +0,0 @@
1
- /**
2
- * Resolve the matched locale path of route path
3
- */
4
- export const resolveLocalePath = (locales, routePath) => {
5
- const localePaths = Object.keys(locales).sort((a, b) => {
6
- const levelDelta = b.split('/').length - a.split('/').length;
7
- if (levelDelta !== 0) {
8
- return levelDelta;
9
- }
10
- return b.length - a.length;
11
- });
12
- for (const localePath of localePaths) {
13
- if (routePath.startsWith(localePath)) {
14
- return localePath;
15
- }
16
- }
17
- return '/';
18
- };
@@ -1 +0,0 @@
1
- export declare const resolveRoutePathFromUrl: (url: string, base?: string) => string;
@@ -1,5 +0,0 @@
1
- export const resolveRoutePathFromUrl = (url, base = '/') => url
2
- // remove url origin
3
- .replace(/^(https?:)?\/\/[^/]*/, '')
4
- // remove site base
5
- .replace(new RegExp(`^${base}`), '/');
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './utils';
package/lib/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./utils"), exports);
@@ -1,27 +0,0 @@
1
- /**
2
- * Config for `<head>` tags
3
- *
4
- * @example ['link', { rel: 'icon', href: '/logo.png' }]
5
- * @example ['style', { type: 'text/css' }, 'p { color: red; }']
6
- *
7
- * @remark suffix `Config` means this is for user config
8
- */
9
- export declare type HeadConfig = [HeadTagEmpty, HeadAttrsConfig] | [HeadTagNonEmpty, HeadAttrsConfig, string];
10
- /**
11
- * Allowed tags in `<head>`
12
- *
13
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head
14
- */
15
- export declare type HeadTag = HeadTagNonEmpty | HeadTagEmpty;
16
- /**
17
- * Non-empty tags in `<head>`
18
- */
19
- export declare type HeadTagNonEmpty = 'title' | 'style' | 'script' | 'noscript' | 'template';
20
- /**
21
- * Empty tags in `<head>`
22
- */
23
- export declare type HeadTagEmpty = 'base' | 'link' | 'meta' | 'script';
24
- /**
25
- * Attributes to be set for tags in `<head>`
26
- */
27
- export declare type HeadAttrsConfig = Record<string, string | boolean>;
package/lib/types/head.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export * from './head';
2
- export * from './locale';
3
- export * from './page';
4
- export * from './site';
5
- export * from './ssr';