@bagelink/blox 1.13.2 → 1.13.3
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/dist/CmsPageView.vue.d.ts.map +1 -1
- package/dist/index.cjs +25 -10
- package/dist/index.mjs +26 -11
- package/dist/style.css +17 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CmsPageView.vue.d.ts","sourceRoot":"","sources":["../src/CmsPageView.vue"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"CmsPageView.vue.d.ts","sourceRoot":"","sources":["../src/CmsPageView.vue"],"names":[],"mappings":";AAoXA,wBAMG"}
|
package/dist/index.cjs
CHANGED
|
@@ -111,6 +111,10 @@ const _hoisted_3 = {
|
|
|
111
111
|
key: 2,
|
|
112
112
|
class: "blox-error"
|
|
113
113
|
};
|
|
114
|
+
const _hoisted_4 = {
|
|
115
|
+
key: 0,
|
|
116
|
+
class: "blox-nav-progress"
|
|
117
|
+
};
|
|
114
118
|
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
115
119
|
__name: "CmsPageView",
|
|
116
120
|
setup(__props) {
|
|
@@ -123,6 +127,8 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
123
127
|
vue.provide("contexts", contexts);
|
|
124
128
|
const notFound = vue.ref(false);
|
|
125
129
|
const error = vue.ref(null);
|
|
130
|
+
const initialLoading = vue.ref(true);
|
|
131
|
+
const navigating = vue.ref(false);
|
|
126
132
|
function tryHydrateFromState(path) {
|
|
127
133
|
var _a, _b;
|
|
128
134
|
const win = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
@@ -136,6 +142,14 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
136
142
|
setAlternates(entry.alternates ?? {});
|
|
137
143
|
return true;
|
|
138
144
|
}
|
|
145
|
+
function updateDocumentTitle(resolved) {
|
|
146
|
+
if (typeof document === "undefined") return;
|
|
147
|
+
const page = resolved.page;
|
|
148
|
+
const ctx = resolved.contexts ? Object.values(resolved.contexts).find((c) => c != null) : null;
|
|
149
|
+
const ctxTitle = ctx && typeof ctx.title === "string" ? ctx.title : null;
|
|
150
|
+
const title = page.meta_title || ctxTitle || page.title;
|
|
151
|
+
if (title) document.title = title;
|
|
152
|
+
}
|
|
139
153
|
const initialSlug = (() => {
|
|
140
154
|
var _a;
|
|
141
155
|
if (strategy) {
|
|
@@ -145,24 +159,24 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
145
159
|
return route.path || "/";
|
|
146
160
|
})();
|
|
147
161
|
const ssrHydrated = tryHydrateFromState(initialSlug);
|
|
148
|
-
|
|
162
|
+
if (ssrHydrated) initialLoading.value = false;
|
|
149
163
|
async function load() {
|
|
150
164
|
var _a;
|
|
151
|
-
loading.value = true;
|
|
152
165
|
notFound.value = false;
|
|
153
166
|
error.value = null;
|
|
154
167
|
const { locale: urlLocale, slug } = strategy ? strategy.detect(typeof window !== "undefined" ? window.location.hostname : "", route.path) : { locale: locale2.value, slug: route.path || "/" };
|
|
155
168
|
if (urlLocale !== locale2.value) setLocale(urlLocale);
|
|
156
|
-
setAlternates({});
|
|
157
169
|
if (tryHydrateFromState(slug)) {
|
|
158
|
-
|
|
170
|
+
initialLoading.value = false;
|
|
159
171
|
return;
|
|
160
172
|
}
|
|
173
|
+
navigating.value = true;
|
|
161
174
|
try {
|
|
162
175
|
const resolved = await resolvePath(slug, urlLocale);
|
|
163
176
|
blocks.value = ((_a = resolved.page.content) == null ? void 0 : _a.blocks) ?? [];
|
|
164
177
|
contexts.value = resolved.contexts ?? {};
|
|
165
178
|
setAlternates(resolved.alternates ?? {});
|
|
179
|
+
updateDocumentTitle(resolved);
|
|
166
180
|
} catch (e) {
|
|
167
181
|
const msg = e instanceof Error ? e.message : String(e);
|
|
168
182
|
if (msg.includes("404")) {
|
|
@@ -172,7 +186,8 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
172
186
|
error.value = msg;
|
|
173
187
|
}
|
|
174
188
|
} finally {
|
|
175
|
-
|
|
189
|
+
initialLoading.value = false;
|
|
190
|
+
navigating.value = false;
|
|
176
191
|
}
|
|
177
192
|
}
|
|
178
193
|
if (!ssrHydrated) {
|
|
@@ -182,7 +197,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
182
197
|
return (_ctx, _cache) => {
|
|
183
198
|
const _component_RouterLink = vue.resolveComponent("RouterLink");
|
|
184
199
|
return vue.openBlock(), vue.createElementBlock("div", null, [
|
|
185
|
-
|
|
200
|
+
initialLoading.value && blocks.value.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, " Loading… ")) : notFound.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [
|
|
186
201
|
_cache[0] || (_cache[0] = vue.createElementVNode("h2", null, "404", -1)),
|
|
187
202
|
vue.createElementVNode("p", null, vue.toDisplayString(vue.unref(locale2) === "he" ? "הדף לא נמצא" : "Page not found"), 1),
|
|
188
203
|
vue.createVNode(_component_RouterLink, { to: "/" }, {
|
|
@@ -191,10 +206,10 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
191
206
|
]),
|
|
192
207
|
_: 1
|
|
193
208
|
})
|
|
194
|
-
])) : error.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, vue.toDisplayString(error.value), 1)) : (vue.openBlock(), vue.
|
|
195
|
-
|
|
196
|
-
blocks: blocks.value
|
|
197
|
-
|
|
209
|
+
])) : error.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, vue.toDisplayString(error.value), 1)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
210
|
+
navigating.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4)) : vue.createCommentVNode("", true),
|
|
211
|
+
vue.createVNode(vue.unref(PageRenderer), { blocks: blocks.value }, null, 8, ["blocks"])
|
|
212
|
+
], 64))
|
|
198
213
|
]);
|
|
199
214
|
};
|
|
200
215
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { computed, ref, defineComponent, inject, h, provide, watch, resolveComponent, createElementBlock, openBlock,
|
|
4
|
+
import { computed, ref, defineComponent, inject, h, provide, watch, resolveComponent, createElementBlock, openBlock, createElementVNode, createVNode, toDisplayString, unref, withCtx, createTextVNode, Fragment, createCommentVNode, createBlock, normalizeProps, guardReactiveProps, renderSlot, onMounted, onUnmounted, nextTick } from "vue";
|
|
5
5
|
import { useRoute, useRouter, RouterLink } from "vue-router";
|
|
6
6
|
import { getI18n } from "@bagelink/vue";
|
|
7
7
|
import { B as BLOX_STATE_WINDOW_KEY } from "./constants-BIbQhd3z.js";
|
|
@@ -109,6 +109,10 @@ const _hoisted_3 = {
|
|
|
109
109
|
key: 2,
|
|
110
110
|
class: "blox-error"
|
|
111
111
|
};
|
|
112
|
+
const _hoisted_4 = {
|
|
113
|
+
key: 0,
|
|
114
|
+
class: "blox-nav-progress"
|
|
115
|
+
};
|
|
112
116
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
113
117
|
__name: "CmsPageView",
|
|
114
118
|
setup(__props) {
|
|
@@ -121,6 +125,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
121
125
|
provide("contexts", contexts);
|
|
122
126
|
const notFound = ref(false);
|
|
123
127
|
const error = ref(null);
|
|
128
|
+
const initialLoading = ref(true);
|
|
129
|
+
const navigating = ref(false);
|
|
124
130
|
function tryHydrateFromState(path) {
|
|
125
131
|
var _a, _b;
|
|
126
132
|
const win = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
@@ -134,6 +140,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
134
140
|
setAlternates(entry.alternates ?? {});
|
|
135
141
|
return true;
|
|
136
142
|
}
|
|
143
|
+
function updateDocumentTitle(resolved) {
|
|
144
|
+
if (typeof document === "undefined") return;
|
|
145
|
+
const page = resolved.page;
|
|
146
|
+
const ctx = resolved.contexts ? Object.values(resolved.contexts).find((c) => c != null) : null;
|
|
147
|
+
const ctxTitle = ctx && typeof ctx.title === "string" ? ctx.title : null;
|
|
148
|
+
const title = page.meta_title || ctxTitle || page.title;
|
|
149
|
+
if (title) document.title = title;
|
|
150
|
+
}
|
|
137
151
|
const initialSlug = (() => {
|
|
138
152
|
var _a;
|
|
139
153
|
if (strategy) {
|
|
@@ -143,24 +157,24 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
143
157
|
return route.path || "/";
|
|
144
158
|
})();
|
|
145
159
|
const ssrHydrated = tryHydrateFromState(initialSlug);
|
|
146
|
-
|
|
160
|
+
if (ssrHydrated) initialLoading.value = false;
|
|
147
161
|
async function load() {
|
|
148
162
|
var _a;
|
|
149
|
-
loading.value = true;
|
|
150
163
|
notFound.value = false;
|
|
151
164
|
error.value = null;
|
|
152
165
|
const { locale: urlLocale, slug } = strategy ? strategy.detect(typeof window !== "undefined" ? window.location.hostname : "", route.path) : { locale: locale2.value, slug: route.path || "/" };
|
|
153
166
|
if (urlLocale !== locale2.value) setLocale(urlLocale);
|
|
154
|
-
setAlternates({});
|
|
155
167
|
if (tryHydrateFromState(slug)) {
|
|
156
|
-
|
|
168
|
+
initialLoading.value = false;
|
|
157
169
|
return;
|
|
158
170
|
}
|
|
171
|
+
navigating.value = true;
|
|
159
172
|
try {
|
|
160
173
|
const resolved = await resolvePath(slug, urlLocale);
|
|
161
174
|
blocks.value = ((_a = resolved.page.content) == null ? void 0 : _a.blocks) ?? [];
|
|
162
175
|
contexts.value = resolved.contexts ?? {};
|
|
163
176
|
setAlternates(resolved.alternates ?? {});
|
|
177
|
+
updateDocumentTitle(resolved);
|
|
164
178
|
} catch (e) {
|
|
165
179
|
const msg = e instanceof Error ? e.message : String(e);
|
|
166
180
|
if (msg.includes("404")) {
|
|
@@ -170,7 +184,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
170
184
|
error.value = msg;
|
|
171
185
|
}
|
|
172
186
|
} finally {
|
|
173
|
-
|
|
187
|
+
initialLoading.value = false;
|
|
188
|
+
navigating.value = false;
|
|
174
189
|
}
|
|
175
190
|
}
|
|
176
191
|
if (!ssrHydrated) {
|
|
@@ -180,7 +195,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
180
195
|
return (_ctx, _cache) => {
|
|
181
196
|
const _component_RouterLink = resolveComponent("RouterLink");
|
|
182
197
|
return openBlock(), createElementBlock("div", null, [
|
|
183
|
-
|
|
198
|
+
initialLoading.value && blocks.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$1, " Loading… ")) : notFound.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
184
199
|
_cache[0] || (_cache[0] = createElementVNode("h2", null, "404", -1)),
|
|
185
200
|
createElementVNode("p", null, toDisplayString(unref(locale2) === "he" ? "הדף לא נמצא" : "Page not found"), 1),
|
|
186
201
|
createVNode(_component_RouterLink, { to: "/" }, {
|
|
@@ -189,10 +204,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
189
204
|
]),
|
|
190
205
|
_: 1
|
|
191
206
|
})
|
|
192
|
-
])) : error.value ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(error.value), 1)) : (openBlock(),
|
|
193
|
-
|
|
194
|
-
blocks: blocks.value
|
|
195
|
-
|
|
207
|
+
])) : error.value ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(error.value), 1)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
208
|
+
navigating.value ? (openBlock(), createElementBlock("div", _hoisted_4)) : createCommentVNode("", true),
|
|
209
|
+
createVNode(unref(PageRenderer), { blocks: blocks.value }, null, 8, ["blocks"])
|
|
210
|
+
], 64))
|
|
196
211
|
]);
|
|
197
212
|
};
|
|
198
213
|
}
|
package/dist/style.css
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
|
|
2
|
+
.blox-nav-progress {
|
|
3
|
+
position: fixed;
|
|
4
|
+
top: 0;
|
|
5
|
+
left: 0;
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 3px;
|
|
8
|
+
z-index: 9999;
|
|
9
|
+
background: linear-gradient(90deg, transparent, var(--blox-accent, #3b82f6), transparent);
|
|
10
|
+
animation: blox-nav-slide 1s ease-in-out infinite;
|
|
11
|
+
}
|
|
12
|
+
@keyframes blox-nav-slide {
|
|
13
|
+
0% { transform: translateX(-100%);
|
|
14
|
+
}
|
|
15
|
+
100% { transform: translateX(100%);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
2
19
|
* {
|
|
3
20
|
box-sizing: border-box;
|
|
4
21
|
}
|
package/package.json
CHANGED