@koine/next 1.0.44 → 1.0.45
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/Theme/Theme.d.ts +6 -0
- package/Theme/Theme.js +6 -0
- package/config/index.d.ts +3 -3
- package/config/index.js +19 -3
- package/node/Theme/Theme.js +6 -0
- package/node/config/index.js +19 -3
- package/package.json +3 -3
package/Theme/Theme.d.ts
CHANGED
|
@@ -47,6 +47,12 @@ export declare type ThemeProviderProps = React.PropsWithChildren<{
|
|
|
47
47
|
/** Nonce string to pass to the inline script for CSP headers */
|
|
48
48
|
nonce?: string;
|
|
49
49
|
}>;
|
|
50
|
+
/**
|
|
51
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
52
|
+
*/
|
|
50
53
|
export declare const useTheme: () => UseThemeProps;
|
|
54
|
+
/**
|
|
55
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
56
|
+
*/
|
|
51
57
|
export declare const ThemeProvider: ({ forcedTheme, disableTransitionOnChange, enableSystem, enableColorScheme, themes, defaultTheme, attribute, value, children, nonce, }: ThemeProviderProps) => JSX.Element;
|
|
52
58
|
export {};
|
package/Theme/Theme.js
CHANGED
|
@@ -22,7 +22,13 @@ var ThemeContext = createContext({
|
|
|
22
22
|
setTheme: function (_) { },
|
|
23
23
|
themes: [],
|
|
24
24
|
});
|
|
25
|
+
/**
|
|
26
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
27
|
+
*/
|
|
25
28
|
export var useTheme = function () { return useContext(ThemeContext); };
|
|
29
|
+
/**
|
|
30
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
31
|
+
*/
|
|
26
32
|
export var ThemeProvider = function (_a) {
|
|
27
33
|
var forcedTheme = _a.forcedTheme, _b = _a.disableTransitionOnChange, disableTransitionOnChange = _b === void 0 ? false : _b, _c = _a.enableSystem, enableSystem = _c === void 0 ? true : _c, enableColorScheme = _a.enableColorScheme, _d = _a.themes, themes = _d === void 0 ? ["light", "dark"] : _d, _e = _a.defaultTheme, defaultTheme = _e === void 0 ? enableSystem ? "system" : "light" : _e, _f = _a.attribute, attribute = _f === void 0 ? "data-theme" : _f, value = _a.value, children = _a.children, nonce = _a.nonce;
|
|
28
34
|
var _g = useState(function () {
|
package/config/index.d.ts
CHANGED
|
@@ -76,10 +76,10 @@ declare type KoineNextConfig = {
|
|
|
76
76
|
* "home": "/",
|
|
77
77
|
* "products": {
|
|
78
78
|
* "list": "/products",
|
|
79
|
-
* "[category]": "/products/
|
|
79
|
+
* "[category]": "/products/{{ category }}",
|
|
80
80
|
* "[tag]": {
|
|
81
|
-
* "view": "/products/
|
|
82
|
-
* "related": "/products/
|
|
81
|
+
* "view": "/products/{{ category }}/{{ tag }}",
|
|
82
|
+
* "related": "/products/{{ category }}/{{ tag }}/related"
|
|
83
83
|
* }
|
|
84
84
|
* },
|
|
85
85
|
* "company": {
|
package/config/index.js
CHANGED
|
@@ -52,9 +52,25 @@ export function encodePathname(pathname) {
|
|
|
52
52
|
.join("/");
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* It replaces `/
|
|
55
|
+
* It replaces `/{{ slug }}/` with the given replacer.
|
|
56
56
|
*/
|
|
57
57
|
function transformRoutePathname(rawPathname, replacer) {
|
|
58
|
+
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
59
|
+
return pathNameParts
|
|
60
|
+
.map(function (part, _idx) {
|
|
61
|
+
var isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
62
|
+
part = isDynamic ? replacer : part;
|
|
63
|
+
// if (isDynamic && _idx === pathNameParts.length - 1) {
|
|
64
|
+
// part += "*";
|
|
65
|
+
// }
|
|
66
|
+
return isDynamic ? part : encodeURIComponent(part);
|
|
67
|
+
})
|
|
68
|
+
.join("/");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* It replaces `/[slug]/` with the given replacer.
|
|
72
|
+
*/
|
|
73
|
+
function transformRouteTemplate(rawPathname, replacer) {
|
|
58
74
|
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
59
75
|
return pathNameParts
|
|
60
76
|
.map(function (part, _idx) {
|
|
@@ -91,7 +107,7 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
91
107
|
*/
|
|
92
108
|
export function getPathRewrite(pathname, template) {
|
|
93
109
|
pathname = transformRoutePathname(pathname, ":path");
|
|
94
|
-
template =
|
|
110
|
+
template = transformRouteTemplate(template, ":path");
|
|
95
111
|
var source = "/".concat(normaliseUrlPathname(pathname));
|
|
96
112
|
var destination = "/".concat(normaliseUrlPathname(template));
|
|
97
113
|
// console.log(`rewrite pathname "${source}" to template "${destination}"`);
|
|
@@ -105,7 +121,7 @@ export function getPathRewrite(pathname, template) {
|
|
|
105
121
|
*/
|
|
106
122
|
export function getPathRedirect(locale, pathname, template, permanent) {
|
|
107
123
|
if (locale === void 0) { locale = ""; }
|
|
108
|
-
template =
|
|
124
|
+
template = transformRouteTemplate(template, ":slug");
|
|
109
125
|
pathname = transformRoutePathname(pathname, ":slug");
|
|
110
126
|
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
111
127
|
var destination = "/".concat(normaliseUrlPathname(pathname));
|
package/node/Theme/Theme.js
CHANGED
|
@@ -25,8 +25,14 @@ var ThemeContext = (0, react_1.createContext)({
|
|
|
25
25
|
setTheme: function (_) { },
|
|
26
26
|
themes: [],
|
|
27
27
|
});
|
|
28
|
+
/**
|
|
29
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
30
|
+
*/
|
|
28
31
|
var useTheme = function () { return (0, react_1.useContext)(ThemeContext); };
|
|
29
32
|
exports.useTheme = useTheme;
|
|
33
|
+
/**
|
|
34
|
+
* @borrows [next-themes](https://github.com/pacocoursey/next-themes)
|
|
35
|
+
*/
|
|
30
36
|
var ThemeProvider = function (_a) {
|
|
31
37
|
var forcedTheme = _a.forcedTheme, _b = _a.disableTransitionOnChange, disableTransitionOnChange = _b === void 0 ? false : _b, _c = _a.enableSystem, enableSystem = _c === void 0 ? true : _c, enableColorScheme = _a.enableColorScheme, _d = _a.themes, themes = _d === void 0 ? ["light", "dark"] : _d, _e = _a.defaultTheme, defaultTheme = _e === void 0 ? enableSystem ? "system" : "light" : _e, _f = _a.attribute, attribute = _f === void 0 ? "data-theme" : _f, value = _a.value, children = _a.children, nonce = _a.nonce;
|
|
32
38
|
var _g = (0, react_1.useState)(function () {
|
package/node/config/index.js
CHANGED
|
@@ -58,9 +58,25 @@ function encodePathname(pathname) {
|
|
|
58
58
|
}
|
|
59
59
|
exports.encodePathname = encodePathname;
|
|
60
60
|
/**
|
|
61
|
-
* It replaces `/
|
|
61
|
+
* It replaces `/{{ slug }}/` with the given replacer.
|
|
62
62
|
*/
|
|
63
63
|
function transformRoutePathname(rawPathname, replacer) {
|
|
64
|
+
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
65
|
+
return pathNameParts
|
|
66
|
+
.map(function (part, _idx) {
|
|
67
|
+
var isDynamic = part.startsWith("{{") && part.endsWith("}}");
|
|
68
|
+
part = isDynamic ? replacer : part;
|
|
69
|
+
// if (isDynamic && _idx === pathNameParts.length - 1) {
|
|
70
|
+
// part += "*";
|
|
71
|
+
// }
|
|
72
|
+
return isDynamic ? part : encodeURIComponent(part);
|
|
73
|
+
})
|
|
74
|
+
.join("/");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* It replaces `/[slug]/` with the given replacer.
|
|
78
|
+
*/
|
|
79
|
+
function transformRouteTemplate(rawPathname, replacer) {
|
|
64
80
|
var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
|
|
65
81
|
return pathNameParts
|
|
66
82
|
.map(function (part, _idx) {
|
|
@@ -97,7 +113,7 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
|
|
|
97
113
|
*/
|
|
98
114
|
function getPathRewrite(pathname, template) {
|
|
99
115
|
pathname = transformRoutePathname(pathname, ":path");
|
|
100
|
-
template =
|
|
116
|
+
template = transformRouteTemplate(template, ":path");
|
|
101
117
|
var source = "/".concat(normaliseUrlPathname(pathname));
|
|
102
118
|
var destination = "/".concat(normaliseUrlPathname(template));
|
|
103
119
|
// console.log(`rewrite pathname "${source}" to template "${destination}"`);
|
|
@@ -112,7 +128,7 @@ exports.getPathRewrite = getPathRewrite;
|
|
|
112
128
|
*/
|
|
113
129
|
function getPathRedirect(locale, pathname, template, permanent) {
|
|
114
130
|
if (locale === void 0) { locale = ""; }
|
|
115
|
-
template =
|
|
131
|
+
template = transformRouteTemplate(template, ":slug");
|
|
116
132
|
pathname = transformRoutePathname(pathname, ":slug");
|
|
117
133
|
var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
|
|
118
134
|
var destination = "/".concat(normaliseUrlPathname(pathname));
|
package/package.json
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^16.8 || ^17 || ^18",
|
|
20
20
|
"next": "^12.2.0",
|
|
21
|
-
"@koine/utils": "1.0.
|
|
21
|
+
"@koine/utils": "1.0.45",
|
|
22
22
|
"framer-motion": "^6.3.16",
|
|
23
|
-
"@koine/react": "1.0.
|
|
23
|
+
"@koine/react": "1.0.45",
|
|
24
24
|
"styled-components": "^5.3.5",
|
|
25
25
|
"@mui/base": "^5.0.0-alpha.87",
|
|
26
26
|
"react-icons": "^4.4.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"next-translate": "^1.4.0",
|
|
42
42
|
"next-seo": "^5.4.0"
|
|
43
43
|
},
|
|
44
|
-
"version": "1.0.
|
|
44
|
+
"version": "1.0.45",
|
|
45
45
|
"module": "./index.js",
|
|
46
46
|
"types": "./index.d.ts"
|
|
47
47
|
}
|