@koine/next 1.0.49 → 1.0.52

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.js CHANGED
@@ -54,11 +54,15 @@ export function encodePathname(pathname) {
54
54
  /**
55
55
  * It replaces `/{{ slug }}/` with the given replacer.
56
56
  */
57
- function transformRoutePathname(rawPathname, replacer) {
57
+ function transformRoutePathname(rawPathname) {
58
58
  var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
59
59
  return pathNameParts
60
60
  .map(function (part, _idx) {
61
+ var _a;
61
62
  var isDynamic = part.startsWith("{{") && part.endsWith("}}");
63
+ var replacer = isDynamic
64
+ ? ":".concat((_a = part.match(/{{(.+)}}/)) === null || _a === void 0 ? void 0 : _a[1].trim())
65
+ : "";
62
66
  part = isDynamic ? replacer : part;
63
67
  // if (isDynamic && _idx === pathNameParts.length - 1) {
64
68
  // part += "*";
@@ -70,11 +74,15 @@ function transformRoutePathname(rawPathname, replacer) {
70
74
  /**
71
75
  * It replaces `/[slug]/` with the given replacer.
72
76
  */
73
- function transformRouteTemplate(rawPathname, replacer) {
77
+ function transformRouteTemplate(rawPathname) {
74
78
  var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
75
79
  return pathNameParts
76
80
  .map(function (part, _idx) {
81
+ var _a;
77
82
  var isDynamic = part.startsWith("[") && part.endsWith("]");
83
+ var replacer = isDynamic
84
+ ? ":".concat((_a = part.match(/\[(.+)\]/)) === null || _a === void 0 ? void 0 : _a[1].trim())
85
+ : "";
78
86
  part = isDynamic ? replacer : part;
79
87
  // if (isDynamic && _idx === pathNameParts.length - 1) {
80
88
  // part += "*";
@@ -106,8 +114,8 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
106
114
  * Get path rewrite
107
115
  */
108
116
  export function getPathRewrite(pathname, template) {
109
- pathname = transformRoutePathname(pathname, ":path");
110
- template = transformRouteTemplate(template, ":path");
117
+ pathname = transformRoutePathname(pathname);
118
+ template = transformRouteTemplate(template);
111
119
  var source = "/".concat(normaliseUrlPathname(pathname));
112
120
  var destination = "/".concat(normaliseUrlPathname(template));
113
121
  // console.log(`rewrite pathname "${source}" to template "${destination}"`);
@@ -121,8 +129,8 @@ export function getPathRewrite(pathname, template) {
121
129
  */
122
130
  export function getPathRedirect(locale, pathname, template, permanent) {
123
131
  if (locale === void 0) { locale = ""; }
124
- template = transformRouteTemplate(template, ":slug");
125
- pathname = transformRoutePathname(pathname, ":slug");
132
+ template = transformRouteTemplate(template);
133
+ pathname = transformRoutePathname(pathname);
126
134
  var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
127
135
  var destination = "/".concat(normaliseUrlPathname(pathname));
128
136
  // console.log(`redirect template "${source}" to pathname "${destination}"`);
@@ -60,11 +60,15 @@ exports.encodePathname = encodePathname;
60
60
  /**
61
61
  * It replaces `/{{ slug }}/` with the given replacer.
62
62
  */
63
- function transformRoutePathname(rawPathname, replacer) {
63
+ function transformRoutePathname(rawPathname) {
64
64
  var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
65
65
  return pathNameParts
66
66
  .map(function (part, _idx) {
67
+ var _a;
67
68
  var isDynamic = part.startsWith("{{") && part.endsWith("}}");
69
+ var replacer = isDynamic
70
+ ? ":".concat((_a = part.match(/{{(.+)}}/)) === null || _a === void 0 ? void 0 : _a[1].trim())
71
+ : "";
68
72
  part = isDynamic ? replacer : part;
69
73
  // if (isDynamic && _idx === pathNameParts.length - 1) {
70
74
  // part += "*";
@@ -76,11 +80,15 @@ function transformRoutePathname(rawPathname, replacer) {
76
80
  /**
77
81
  * It replaces `/[slug]/` with the given replacer.
78
82
  */
79
- function transformRouteTemplate(rawPathname, replacer) {
83
+ function transformRouteTemplate(rawPathname) {
80
84
  var pathNameParts = rawPathname.split("/").filter(function (part) { return !!part; });
81
85
  return pathNameParts
82
86
  .map(function (part, _idx) {
87
+ var _a;
83
88
  var isDynamic = part.startsWith("[") && part.endsWith("]");
89
+ var replacer = isDynamic
90
+ ? ":".concat((_a = part.match(/\[(.+)\]/)) === null || _a === void 0 ? void 0 : _a[1].trim())
91
+ : "";
84
92
  part = isDynamic ? replacer : part;
85
93
  // if (isDynamic && _idx === pathNameParts.length - 1) {
86
94
  // part += "*";
@@ -112,8 +120,8 @@ function getRoutesMap(map, routes, pathnameBuffer, templateBuffer) {
112
120
  * Get path rewrite
113
121
  */
114
122
  function getPathRewrite(pathname, template) {
115
- pathname = transformRoutePathname(pathname, ":path");
116
- template = transformRouteTemplate(template, ":path");
123
+ pathname = transformRoutePathname(pathname);
124
+ template = transformRouteTemplate(template);
117
125
  var source = "/".concat(normaliseUrlPathname(pathname));
118
126
  var destination = "/".concat(normaliseUrlPathname(template));
119
127
  // console.log(`rewrite pathname "${source}" to template "${destination}"`);
@@ -128,8 +136,8 @@ exports.getPathRewrite = getPathRewrite;
128
136
  */
129
137
  function getPathRedirect(locale, pathname, template, permanent) {
130
138
  if (locale === void 0) { locale = ""; }
131
- template = transformRouteTemplate(template, ":slug");
132
- pathname = transformRoutePathname(pathname, ":slug");
139
+ template = transformRouteTemplate(template);
140
+ pathname = transformRoutePathname(pathname);
133
141
  var source = "/".concat(normaliseUrlPathname((locale ? "/".concat(locale, "/") : "/") + template));
134
142
  var destination = "/".concat(normaliseUrlPathname(pathname));
135
143
  // console.log(`redirect template "${source}" to pathname "${destination}"`);
package/package.json CHANGED
@@ -18,14 +18,10 @@
18
18
  "peerDependencies": {
19
19
  "react": "^16.8 || ^17 || ^18",
20
20
  "next": "^12.2.0",
21
- "@koine/utils": "1.0.49",
21
+ "@koine/utils": "1.0.52",
22
22
  "framer-motion": "^6.4.2",
23
- "next-auth": "^4.9.0",
24
- "@mui/material": "^5.8.7",
25
- "@emotion/react": "^11.9.3",
23
+ "@koine/react": "1.0.52",
26
24
  "styled-components": "^5.3.5",
27
- "react-hook-form": "^7.33.1",
28
- "@koine/react": "1.0.49",
29
25
  "@mui/base": "^5.0.0-alpha.88",
30
26
  "react-icons": "^4.4.0",
31
27
  "date-fns": "^2.28.0",
@@ -33,15 +29,19 @@
33
29
  "@tiptap/react": "^2.0.0-beta.114",
34
30
  "@tiptap/starter-kit": "^2.0.0-beta.190",
35
31
  "@kuus/yup": "^1.0.0-beta.4",
32
+ "react-hook-form": "^7.33.1",
36
33
  "type-fest": "^2.16.0",
37
34
  "react-popper": "^2.3.0",
38
35
  "tslib": "^2.4.0",
36
+ "next-auth": "^4.9.0",
37
+ "@mui/material": "^5.8.7",
38
+ "@emotion/react": "^11.9.3",
39
39
  "@emotion/server": "^11.4.0",
40
40
  "next-translate": "^1.5.0",
41
41
  "next-seo": "^5.4.0",
42
42
  "@hookform/resolvers": "^2.9.3"
43
43
  },
44
- "version": "1.0.49",
44
+ "version": "1.0.52",
45
45
  "module": "./index.js",
46
46
  "types": "./index.d.ts"
47
47
  }