@koine/next 1.0.67 → 1.0.70
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/config/index.d.ts +30 -3
- package/config/index.js +54 -46
- package/load.d.ts +1 -1
- package/load.js +1 -1
- package/node/config/index.js +54 -46
- package/node/load.js +1 -1
- package/node/to.js +1 -1
- package/package.json +3 -3
- package/to.d.ts +2 -2
- package/to.js +1 -1
package/config/index.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ declare type Route = string | {
|
|
|
4
4
|
[key: string]: Route | string;
|
|
5
5
|
};
|
|
6
6
|
declare type Routes = Record<string, Route>;
|
|
7
|
+
declare type RoutesMapRoute = {
|
|
8
|
+
template: string;
|
|
9
|
+
pathname: string;
|
|
10
|
+
wildcard?: boolean;
|
|
11
|
+
};
|
|
7
12
|
/**
|
|
8
13
|
* Normalise pathname
|
|
9
14
|
*
|
|
@@ -34,14 +39,14 @@ export declare function encodePathname(pathname?: string): string;
|
|
|
34
39
|
/**
|
|
35
40
|
* Get path rewrite
|
|
36
41
|
*/
|
|
37
|
-
export declare function getPathRewrite(
|
|
42
|
+
export declare function getPathRewrite(route: RoutesMapRoute): {
|
|
38
43
|
source: string;
|
|
39
44
|
destination: string;
|
|
40
45
|
};
|
|
41
46
|
/**
|
|
42
47
|
* Get path redirect
|
|
43
48
|
*/
|
|
44
|
-
export declare function getPathRedirect(locale: string | undefined,
|
|
49
|
+
export declare function getPathRedirect(locale: string | undefined, route: RoutesMapRoute, permanent?: boolean): {
|
|
45
50
|
source: string;
|
|
46
51
|
destination: string;
|
|
47
52
|
permanent: boolean;
|
|
@@ -89,12 +94,34 @@ declare type KoineNextConfig = {
|
|
|
89
94
|
* }
|
|
90
95
|
* ```
|
|
91
96
|
*
|
|
97
|
+
* Here we also account for wildcards, those should only be defined in the
|
|
98
|
+
* pathname part of the JSON file, e.g.:
|
|
99
|
+
*
|
|
100
|
+
* ```json
|
|
101
|
+
* {
|
|
102
|
+
* "category": {
|
|
103
|
+
* "[slug]": {
|
|
104
|
+
* "[id]": "/categories/{{ slug }}/{{ id }}*"
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
* This might be desired when we want to have param-based pagination, e.g. when
|
|
110
|
+
* we have the following folder structure:
|
|
111
|
+
*
|
|
112
|
+
* ```yml
|
|
113
|
+
* |__/category
|
|
114
|
+
* |__/[slug]
|
|
115
|
+
* |__/[id]
|
|
116
|
+
* |__/[[...page]].tsx
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
92
119
|
* NOTE1:
|
|
93
120
|
* You cannot name your dynamic template file "index.tsx" when they have nested
|
|
94
121
|
* segments or the rewrites won't work. So while this is allowed:
|
|
95
122
|
* `/pages/cats/[category]/index.tsx` it is not when you also have e.g.:
|
|
96
123
|
* `/pages/cats/[category]/reviews.tsx`
|
|
97
|
-
* TODO: This might be fixable?
|
|
124
|
+
* TODO: This might be fixable? Is this fixed now?
|
|
98
125
|
*
|
|
99
126
|
* NOTE2:
|
|
100
127
|
* When `routes` is used be sure to pass before than the `i18n.defaultLocale`
|
package/config/index.js
CHANGED
|
@@ -52,47 +52,53 @@ export function encodePathname(pathname) {
|
|
|
52
52
|
.join("/");
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* Transform the route translated defintion into a `pathname` and a `template`.
|
|
56
|
+
*
|
|
57
|
+
* Here we add the wildcard flag maybe found in the pathname to the template
|
|
58
|
+
* name too, this is because we do not want to have the wildcard in the JSON
|
|
59
|
+
* keys as those are also used to throught the `useT` hook and having asterisks
|
|
60
|
+
* there is a bit cumbersome.
|
|
61
|
+
*
|
|
62
|
+
* @see https://nextjs.org/docs/messages/invalid-multi-match
|
|
56
63
|
*/
|
|
57
|
-
function
|
|
58
|
-
var
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
function transformRoute(route) {
|
|
65
|
+
var rawPathname = route.pathname, rawTemplate = route.template;
|
|
66
|
+
var pathnameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
67
|
+
var templateParts = rawTemplate.split("/").filter(function (part) { return !!part; });
|
|
68
|
+
var mapPartsByIdx = {};
|
|
69
|
+
var pathname = pathnameParts
|
|
70
|
+
.map(function (part) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
var hasWildcard = part.endsWith("*");
|
|
73
|
+
part = part.replace("*", "");
|
|
62
74
|
var isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
63
|
-
var
|
|
64
|
-
?
|
|
65
|
-
:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
var asValue = isDynamic
|
|
76
|
+
? (_b = (_a = part.match(/{{(.+)}}/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
|
|
77
|
+
: part.trim();
|
|
78
|
+
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
79
|
+
mapPartsByIdx[asValue] = {
|
|
80
|
+
isDynamic: isDynamic,
|
|
81
|
+
hasWildcard: hasWildcard,
|
|
82
|
+
};
|
|
83
|
+
return isDynamic ? ":".concat(asPath) : asPath;
|
|
71
84
|
})
|
|
72
85
|
.join("/");
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*/
|
|
77
|
-
function transformRouteTemplate(rawPathname) {
|
|
78
|
-
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
79
|
-
return pathNameParts
|
|
80
|
-
.map(function (part, _idx) {
|
|
81
|
-
var _a;
|
|
86
|
+
var template = templateParts
|
|
87
|
+
.map(function (part) {
|
|
88
|
+
var _a, _b, _c;
|
|
82
89
|
var isDynamic = part.startsWith("[") && part.endsWith("]");
|
|
83
|
-
var
|
|
84
|
-
?
|
|
85
|
-
:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// }
|
|
90
|
-
return isDynamic ? part : encodeURIComponent(part);
|
|
90
|
+
var asValue = isDynamic
|
|
91
|
+
? (_b = (_a = part.match(/\[(.+)\]/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
|
|
92
|
+
: part.trim();
|
|
93
|
+
var hasWildcard = (_c = mapPartsByIdx[asValue]) === null || _c === void 0 ? void 0 : _c.hasWildcard;
|
|
94
|
+
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
95
|
+
return isDynamic ? ":".concat(asPath) : asPath;
|
|
91
96
|
})
|
|
92
97
|
.join("/");
|
|
98
|
+
return { pathname: pathname, template: template };
|
|
93
99
|
}
|
|
94
100
|
/**
|
|
95
|
-
* Get
|
|
101
|
+
* Get routes map dictionary
|
|
96
102
|
*/
|
|
97
103
|
function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
98
104
|
if (map === void 0) { map = {}; }
|
|
@@ -102,7 +108,11 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
102
108
|
var pathOrNestedRoutes = routes[key];
|
|
103
109
|
var template = "".concat(templateBuffer, "/").concat(key);
|
|
104
110
|
if (typeof pathOrNestedRoutes === "string") {
|
|
105
|
-
map[template] =
|
|
111
|
+
map[template] = {
|
|
112
|
+
template: template,
|
|
113
|
+
pathname: pathOrNestedRoutes,
|
|
114
|
+
wildcard: pathOrNestedRoutes.includes("*"),
|
|
115
|
+
};
|
|
106
116
|
}
|
|
107
117
|
else {
|
|
108
118
|
getRoutesMap(map, pathOrNestedRoutes, pathnameBuffer, template);
|
|
@@ -113,9 +123,8 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
113
123
|
/**
|
|
114
124
|
* Get path rewrite
|
|
115
125
|
*/
|
|
116
|
-
export function getPathRewrite(
|
|
117
|
-
|
|
118
|
-
template = transformRouteTemplate(template);
|
|
126
|
+
export function getPathRewrite(route) {
|
|
127
|
+
var _a = transformRoute(route), pathname = _a.pathname, template = _a.template;
|
|
119
128
|
var source = "/".concat(normaliseUrlPathname(pathname));
|
|
120
129
|
var destination = "/".concat(normaliseUrlPathname(template));
|
|
121
130
|
// console.log(`rewrite pathname "${source}" to template "${destination}"`);
|
|
@@ -127,10 +136,9 @@ export function getPathRewrite(pathname, template) {
|
|
|
127
136
|
/**
|
|
128
137
|
* Get path redirect
|
|
129
138
|
*/
|
|
130
|
-
export function getPathRedirect(locale,
|
|
139
|
+
export function getPathRedirect(locale, route, permanent) {
|
|
131
140
|
if (locale === void 0) { locale = ""; }
|
|
132
|
-
|
|
133
|
-
pathname = transformRoutePathname(pathname);
|
|
141
|
+
var _a = transformRoute(route), template = _a.template, pathname = _a.pathname;
|
|
134
142
|
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
135
143
|
var destination = "/".concat(normaliseUrlPathname(pathname));
|
|
136
144
|
// console.log(`redirect template "${source}" to pathname "${destination}"`);
|
|
@@ -150,10 +158,10 @@ export function getRedirects(defaultLocale, routes, permanent, debug) {
|
|
|
150
158
|
redirects = [];
|
|
151
159
|
routesMap = getRoutesMap({}, routes);
|
|
152
160
|
Object.keys(routesMap).forEach(function (template) {
|
|
153
|
-
var
|
|
154
|
-
if (pathname !== template) {
|
|
155
|
-
redirects.push(getPathRedirect(defaultLocale,
|
|
156
|
-
redirects.push(getPathRedirect("",
|
|
161
|
+
var route = routesMap[template];
|
|
162
|
+
if (route.pathname !== template) {
|
|
163
|
+
redirects.push(getPathRedirect(defaultLocale, route, permanent));
|
|
164
|
+
redirects.push(getPathRedirect("", route, permanent));
|
|
157
165
|
}
|
|
158
166
|
});
|
|
159
167
|
if (debug)
|
|
@@ -171,9 +179,9 @@ export function getRewrites(routes, debug) {
|
|
|
171
179
|
rewrites = [];
|
|
172
180
|
routesMap = getRoutesMap({}, routes);
|
|
173
181
|
Object.keys(routesMap).forEach(function (template) {
|
|
174
|
-
var
|
|
175
|
-
if (pathname !== template) {
|
|
176
|
-
rewrites.push(getPathRewrite(
|
|
182
|
+
var route = routesMap[template];
|
|
183
|
+
if (route.pathname !== template) {
|
|
184
|
+
rewrites.push(getPathRewrite(route));
|
|
177
185
|
}
|
|
178
186
|
});
|
|
179
187
|
if (debug)
|
package/load.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility to load a component with an optional pre-determined delay.
|
|
3
3
|
*
|
|
4
|
-
* This was designed to improve anti spam
|
|
4
|
+
* This was designed to improve anti spam with async form loading.
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
7
7
|
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
package/load.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility to load a component with an optional pre-determined delay.
|
|
3
3
|
*
|
|
4
|
-
* This was designed to improve anti spam
|
|
4
|
+
* This was designed to improve anti spam with async form loading.
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
7
7
|
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
package/node/config/index.js
CHANGED
|
@@ -58,47 +58,53 @@ function encodePathname(pathname) {
|
|
|
58
58
|
}
|
|
59
59
|
exports.encodePathname = encodePathname;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Transform the route translated defintion into a `pathname` and a `template`.
|
|
62
|
+
*
|
|
63
|
+
* Here we add the wildcard flag maybe found in the pathname to the template
|
|
64
|
+
* name too, this is because we do not want to have the wildcard in the JSON
|
|
65
|
+
* keys as those are also used to throught the `useT` hook and having asterisks
|
|
66
|
+
* there is a bit cumbersome.
|
|
67
|
+
*
|
|
68
|
+
* @see https://nextjs.org/docs/messages/invalid-multi-match
|
|
62
69
|
*/
|
|
63
|
-
function
|
|
64
|
-
var
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
function transformRoute(route) {
|
|
71
|
+
var rawPathname = route.pathname, rawTemplate = route.template;
|
|
72
|
+
var pathnameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
73
|
+
var templateParts = rawTemplate.split("/").filter(function (part) { return !!part; });
|
|
74
|
+
var mapPartsByIdx = {};
|
|
75
|
+
var pathname = pathnameParts
|
|
76
|
+
.map(function (part) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
var hasWildcard = part.endsWith("*");
|
|
79
|
+
part = part.replace("*", "");
|
|
68
80
|
var isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
69
|
-
var
|
|
70
|
-
?
|
|
71
|
-
:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
var asValue = isDynamic
|
|
82
|
+
? (_b = (_a = part.match(/{{(.+)}}/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
|
|
83
|
+
: part.trim();
|
|
84
|
+
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
85
|
+
mapPartsByIdx[asValue] = {
|
|
86
|
+
isDynamic: isDynamic,
|
|
87
|
+
hasWildcard: hasWildcard,
|
|
88
|
+
};
|
|
89
|
+
return isDynamic ? ":".concat(asPath) : asPath;
|
|
77
90
|
})
|
|
78
91
|
.join("/");
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*/
|
|
83
|
-
function transformRouteTemplate(rawPathname) {
|
|
84
|
-
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
85
|
-
return pathNameParts
|
|
86
|
-
.map(function (part, _idx) {
|
|
87
|
-
var _a;
|
|
92
|
+
var template = templateParts
|
|
93
|
+
.map(function (part) {
|
|
94
|
+
var _a, _b, _c;
|
|
88
95
|
var isDynamic = part.startsWith("[") && part.endsWith("]");
|
|
89
|
-
var
|
|
90
|
-
?
|
|
91
|
-
:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// }
|
|
96
|
-
return isDynamic ? part : encodeURIComponent(part);
|
|
96
|
+
var asValue = isDynamic
|
|
97
|
+
? (_b = (_a = part.match(/\[(.+)\]/)) === null || _a === void 0 ? void 0 : _a[1].trim()) !== null && _b !== void 0 ? _b : ""
|
|
98
|
+
: part.trim();
|
|
99
|
+
var hasWildcard = (_c = mapPartsByIdx[asValue]) === null || _c === void 0 ? void 0 : _c.hasWildcard;
|
|
100
|
+
var asPath = encodeURIComponent(asValue) + (hasWildcard ? "*" : "");
|
|
101
|
+
return isDynamic ? ":".concat(asPath) : asPath;
|
|
97
102
|
})
|
|
98
103
|
.join("/");
|
|
104
|
+
return { pathname: pathname, template: template };
|
|
99
105
|
}
|
|
100
106
|
/**
|
|
101
|
-
* Get
|
|
107
|
+
* Get routes map dictionary
|
|
102
108
|
*/
|
|
103
109
|
function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
104
110
|
if (map === void 0) { map = {}; }
|
|
@@ -108,7 +114,11 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
108
114
|
var pathOrNestedRoutes = routes[key];
|
|
109
115
|
var template = "".concat(templateBuffer, "/").concat(key);
|
|
110
116
|
if (typeof pathOrNestedRoutes === "string") {
|
|
111
|
-
map[template] =
|
|
117
|
+
map[template] = {
|
|
118
|
+
template: template,
|
|
119
|
+
pathname: pathOrNestedRoutes,
|
|
120
|
+
wildcard: pathOrNestedRoutes.includes("*"),
|
|
121
|
+
};
|
|
112
122
|
}
|
|
113
123
|
else {
|
|
114
124
|
getRoutesMap(map, pathOrNestedRoutes, pathnameBuffer, template);
|
|
@@ -119,9 +129,8 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
119
129
|
/**
|
|
120
130
|
* Get path rewrite
|
|
121
131
|
*/
|
|
122
|
-
function getPathRewrite(
|
|
123
|
-
|
|
124
|
-
template = transformRouteTemplate(template);
|
|
132
|
+
function getPathRewrite(route) {
|
|
133
|
+
var _a = transformRoute(route), pathname = _a.pathname, template = _a.template;
|
|
125
134
|
var source = "/".concat(normaliseUrlPathname(pathname));
|
|
126
135
|
var destination = "/".concat(normaliseUrlPathname(template));
|
|
127
136
|
// console.log(`rewrite pathname "${source}" to template "${destination}"`);
|
|
@@ -134,10 +143,9 @@ exports.getPathRewrite = getPathRewrite;
|
|
|
134
143
|
/**
|
|
135
144
|
* Get path redirect
|
|
136
145
|
*/
|
|
137
|
-
function getPathRedirect(locale,
|
|
146
|
+
function getPathRedirect(locale, route, permanent) {
|
|
138
147
|
if (locale === void 0) { locale = ""; }
|
|
139
|
-
|
|
140
|
-
pathname = transformRoutePathname(pathname);
|
|
148
|
+
var _a = transformRoute(route), template = _a.template, pathname = _a.pathname;
|
|
141
149
|
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
142
150
|
var destination = "/".concat(normaliseUrlPathname(pathname));
|
|
143
151
|
// console.log(`redirect template "${source}" to pathname "${destination}"`);
|
|
@@ -158,10 +166,10 @@ function getRedirects(defaultLocale, routes, permanent, debug) {
|
|
|
158
166
|
redirects = [];
|
|
159
167
|
routesMap = getRoutesMap({}, routes);
|
|
160
168
|
Object.keys(routesMap).forEach(function (template) {
|
|
161
|
-
var
|
|
162
|
-
if (pathname !== template) {
|
|
163
|
-
redirects.push(getPathRedirect(defaultLocale,
|
|
164
|
-
redirects.push(getPathRedirect("",
|
|
169
|
+
var route = routesMap[template];
|
|
170
|
+
if (route.pathname !== template) {
|
|
171
|
+
redirects.push(getPathRedirect(defaultLocale, route, permanent));
|
|
172
|
+
redirects.push(getPathRedirect("", route, permanent));
|
|
165
173
|
}
|
|
166
174
|
});
|
|
167
175
|
if (debug)
|
|
@@ -180,9 +188,9 @@ function getRewrites(routes, debug) {
|
|
|
180
188
|
rewrites = [];
|
|
181
189
|
routesMap = getRoutesMap({}, routes);
|
|
182
190
|
Object.keys(routesMap).forEach(function (template) {
|
|
183
|
-
var
|
|
184
|
-
if (pathname !== template) {
|
|
185
|
-
rewrites.push(getPathRewrite(
|
|
191
|
+
var route = routesMap[template];
|
|
192
|
+
if (route.pathname !== template) {
|
|
193
|
+
rewrites.push(getPathRewrite(route));
|
|
186
194
|
}
|
|
187
195
|
});
|
|
188
196
|
if (debug)
|
package/node/load.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.load = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Utility to load a component with an optional pre-determined delay.
|
|
6
6
|
*
|
|
7
|
-
* This was designed to improve anti spam
|
|
7
|
+
* This was designed to improve anti spam with async form loading.
|
|
8
8
|
*
|
|
9
9
|
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
10
10
|
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
package/node/to.js
CHANGED
package/package.json
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^16.8 || ^17 || ^18",
|
|
20
20
|
"next": "^12.2.3",
|
|
21
|
-
"@koine/utils": "1.0.
|
|
21
|
+
"@koine/utils": "1.0.70",
|
|
22
22
|
"framer-motion": "^6.5.1",
|
|
23
|
-
"@koine/react": "1.0.
|
|
23
|
+
"@koine/react": "1.0.70",
|
|
24
24
|
"styled-components": "^5.3.5",
|
|
25
25
|
"@mui/base": "^5.0.0-alpha.90",
|
|
26
26
|
"react-icons": "^4.4.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"next-seo": "^5.5.0",
|
|
42
42
|
"@hookform/resolvers": "^2.9.6"
|
|
43
43
|
},
|
|
44
|
-
"version": "1.0.
|
|
44
|
+
"version": "1.0.70",
|
|
45
45
|
"module": "./index.js",
|
|
46
46
|
"types": "./index.d.ts"
|
|
47
47
|
}
|
package/to.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TranslateNamespaced, TranslatedRoute } from "./types-i18n";
|
|
2
|
-
declare type OnlyStatic<T extends string> = T extends `${string}.[${string}]` | `[${string}].${string}` | `[${string}]` ? never : T;
|
|
3
|
-
declare type OnlyDynamic<T extends string> = T extends `${string}.[${string}]` | `[${string}].${string}` | `[${string}]` ? T : never;
|
|
2
|
+
declare type OnlyStatic<T extends string> = T extends `${string}.[${string}].${string}` | `${string}.[${string}]` | `[${string}].${string}` | `[${string}]` ? never : T;
|
|
3
|
+
declare type OnlyDynamic<T extends string> = T extends `${string}.[${string}].${string}` | `${string}.[${string}]` | `[${string}].${string}` | `[${string}]` ? T : never;
|
|
4
4
|
/**
|
|
5
5
|
* @borrows [awesome-template-literal-types](https://github.com/ghoullier/awesome-template-literal-types#router-params-parsing)
|
|
6
6
|
*/
|