@redneckz/wildless-cms-uni-blocks 0.14.1012 → 0.14.1013

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.
@@ -0,0 +1,34 @@
1
+ export const description = 'v0.14.1013';
2
+
3
+ export default (uniPath, content) => {
4
+ modifyBlock(content, uniPath);
5
+
6
+ return content;
7
+ };
8
+
9
+ function modifyBlock(data, uniPath) {
10
+ if (!uniPath.includes('.page.json')) return;
11
+
12
+ const slug = data?.slug;
13
+ const canonical = data?.main?.canonical || '';
14
+ const ogUrl = data?.og?.url || '';
15
+
16
+ if (slug && !canonical.includes(slug) && !ogUrl.includes(slug)) {
17
+ const relativePath = uniPath;
18
+ const cleanPath = relativePath.replace('content/', '').replace(/\.page\.json$/, ''); // убираем расширение на всякий случай
19
+ const isSubFolder = cleanPath.includes('/');
20
+ const newValue = (isSubFolder ? '/' : '') + cleanPath;
21
+
22
+ if (data.main) {
23
+ data.main.canonical = newValue;
24
+ } else {
25
+ data.main = { canonical: newValue };
26
+ }
27
+
28
+ if (data.og) {
29
+ data.og.url = newValue;
30
+ } else {
31
+ data.og = { url: newValue };
32
+ }
33
+ }
34
+ }
@@ -14163,7 +14163,7 @@
14163
14163
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
14164
14164
  });
14165
14165
 
14166
- const packageVersion = "0.14.1010";
14166
+ const packageVersion = "0.14.1012";
14167
14167
 
14168
14168
  exports.Blocks = Blocks;
14169
14169
  exports.ContentPage = ContentPage;