@hollware/nuxt 1.0.0-rc.9 → 1.1.0
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/index.d.mts +4 -2
- package/dist/index.mjs +3 -1
- package/dist/runtime/composables.d.mts +10 -0
- package/dist/runtime/composables.mjs +14 -2
- package/dist/runtime/server/reader.mjs +6 -1
- package/dist/runtime/server/routes/navigation.d.mts +4 -0
- package/dist/runtime/server/routes/navigation.mjs +11 -0
- package/dist/runtime/server/routes/site.d.mts +5 -0
- package/dist/runtime/server/routes/webhook.d.mts +1 -1
- package/dist/runtime/server/routes/webhook.mjs +4 -4
- package/dist/runtime/tags.d.mts +1 -0
- package/dist/runtime/tags.mjs +6 -3
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -27,8 +27,10 @@ export interface ModuleOptions {
|
|
|
27
27
|
*
|
|
28
28
|
* - `'purge'`: in Cloudflare's Workers Cache, which serves them without running the Worker, each
|
|
29
29
|
* tagged with what it showed, until Hollware's webhook to `/_hollware/webhook` (signed with
|
|
30
|
-
* `NUXT_HOLLWARE_WEBHOOK_SECRET`)
|
|
31
|
-
* in seconds everywhere.
|
|
30
|
+
* `NUXT_HOLLWARE_WEBHOOK_SECRET`) marks what changed stale: a publish, an edit or an unpublish
|
|
31
|
+
* shows in seconds everywhere. A page the Worker fails to render again (an error or a `5xx`)
|
|
32
|
+
* is served as it was until it renders. It needs `"cache": { "enabled": true }` in the site's
|
|
33
|
+
* wrangler.jsonc.
|
|
32
34
|
* - a number of seconds: kept by Nitro (`swr`) in each isolate, and rendered again in the
|
|
33
35
|
* background once that old; a change shows within that time.
|
|
34
36
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,8 @@ const ROUTES = [
|
|
|
6
6
|
["/_hollware/site", "site"],
|
|
7
7
|
["/_hollware/entries/:collection", "entries"],
|
|
8
8
|
["/_hollware/entry/:collection/:locale/:slug", "entry"],
|
|
9
|
-
["/_hollware/translations/:collection/:group", "translations"]
|
|
9
|
+
["/_hollware/translations/:collection/:group", "translations"],
|
|
10
|
+
["/_hollware/navigation/:collection", "navigation"]
|
|
10
11
|
];
|
|
11
12
|
var src_default = defineNuxtModule({
|
|
12
13
|
meta: {
|
|
@@ -42,6 +43,7 @@ var src_default = defineNuxtModule({
|
|
|
42
43
|
addImports([
|
|
43
44
|
"useHollwareEntry",
|
|
44
45
|
"useHollwareEntries",
|
|
46
|
+
"useHollwareNavigation",
|
|
45
47
|
"useHollwareSite",
|
|
46
48
|
"useHollwareTranslations"
|
|
47
49
|
].map((imported) => ({
|
|
@@ -21,6 +21,11 @@ export declare function useHollwareTranslations(collection: MaybeRefOrGetter<str
|
|
|
21
21
|
outcome: 'ok';
|
|
22
22
|
entries: PageEntry[];
|
|
23
23
|
} | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
24
|
+
export declare function useHollwareNavigation(collection: MaybeRefOrGetter<string>, options?: MaybeRefOrGetter<{
|
|
25
|
+
locale?: string;
|
|
26
|
+
}>, fetching?: {
|
|
27
|
+
lazy?: boolean;
|
|
28
|
+
}): import("nuxt/app").AsyncData<import("@hollware/core").Navigation | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
24
29
|
export declare function useHollwareSite(): import("nuxt/app").AsyncData<{
|
|
25
30
|
outcome: "ok";
|
|
26
31
|
site: {
|
|
@@ -51,6 +56,11 @@ export declare function useHollwareSite(): import("nuxt/app").AsyncData<{
|
|
|
51
56
|
}[];
|
|
52
57
|
maxMarkdownBytes: number;
|
|
53
58
|
styleGuide: string | null;
|
|
59
|
+
navigation?: {
|
|
60
|
+
groupBy: string | null;
|
|
61
|
+
groups: string[] | null;
|
|
62
|
+
orderBy: string | null;
|
|
63
|
+
} | undefined;
|
|
54
64
|
}[];
|
|
55
65
|
};
|
|
56
66
|
} | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { entryTags, groupTags, listTags, recordTags, siteTags } from "./tags.mjs";
|
|
1
|
+
import { entryTags, groupTags, listTags, navigationTags, recordTags, siteTags } from "./tags.mjs";
|
|
2
2
|
import { appendResponseHeader } from "h3";
|
|
3
3
|
import { useFetch, useRequestEvent } from "nuxt/app";
|
|
4
4
|
import { computed, toValue } from "vue";
|
|
@@ -40,6 +40,18 @@ function useHollwareTranslations(collection, group) {
|
|
|
40
40
|
return answer;
|
|
41
41
|
} });
|
|
42
42
|
}
|
|
43
|
+
function useHollwareNavigation(collection, options = {}, fetching = {}) {
|
|
44
|
+
const path = computed(() => `/_hollware/navigation/${encodeURIComponent(toValue(collection))}`);
|
|
45
|
+
const event = pageRequest();
|
|
46
|
+
return useFetch(path, {
|
|
47
|
+
query: computed(() => toValue(options)),
|
|
48
|
+
...fetching,
|
|
49
|
+
transform: (answer) => {
|
|
50
|
+
recordTags(event, navigationTags(toValue(collection), answer.locale));
|
|
51
|
+
return answer;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
43
55
|
function useHollwareSite() {
|
|
44
56
|
const event = pageRequest();
|
|
45
57
|
return useFetch("/_hollware/site", { transform: (answer) => {
|
|
@@ -48,4 +60,4 @@ function useHollwareSite() {
|
|
|
48
60
|
} });
|
|
49
61
|
}
|
|
50
62
|
//#endregion
|
|
51
|
-
export { useHollwareEntries, useHollwareEntry, useHollwareSite, useHollwareTranslations };
|
|
63
|
+
export { useHollwareEntries, useHollwareEntry, useHollwareNavigation, useHollwareSite, useHollwareTranslations };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { entryTags, groupTags, listTags, recordTags, siteTags } from "../tags.mjs";
|
|
1
|
+
import { entryTags, groupTags, listTags, navigationTags, recordTags, siteTags } from "../tags.mjs";
|
|
2
2
|
import { createClient } from "@hollware/client";
|
|
3
3
|
import { createError } from "h3";
|
|
4
4
|
import { useRuntimeConfig } from "nitropack/runtime";
|
|
@@ -44,6 +44,11 @@ function tagging(event, reader) {
|
|
|
44
44
|
recordTags(event, groupTags(args[1], args[2], answer.entries ?? []));
|
|
45
45
|
return answer;
|
|
46
46
|
},
|
|
47
|
+
getNavigation: async (...args) => {
|
|
48
|
+
const answer = await reader.getNavigation(...args);
|
|
49
|
+
recordTags(event, navigationTags(args[1], answer.locale));
|
|
50
|
+
return answer;
|
|
51
|
+
},
|
|
47
52
|
describeSite: async (...args) => {
|
|
48
53
|
const answer = await reader.describeSite(...args);
|
|
49
54
|
recordTags(event, siteTags());
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { answer } from "../answer.mjs";
|
|
2
|
+
import { useHollware } from "../reader.mjs";
|
|
3
|
+
import { defineEventHandler, getQuery, getRouterParam } from "h3";
|
|
4
|
+
//#region src/runtime/server/routes/navigation.ts
|
|
5
|
+
var navigation_default = defineEventHandler((event) => {
|
|
6
|
+
const { site, reader } = useHollware(event);
|
|
7
|
+
const locale = getQuery(event)["locale"];
|
|
8
|
+
return answer(event, () => reader.getNavigation(site, getRouterParam(event, "collection") ?? "", typeof locale === "string" && locale !== "" ? { locale } : {}));
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { navigation_default as default };
|
|
@@ -29,6 +29,11 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
29
29
|
}[];
|
|
30
30
|
maxMarkdownBytes: number;
|
|
31
31
|
styleGuide: string | null;
|
|
32
|
+
navigation?: {
|
|
33
|
+
groupBy: string | null;
|
|
34
|
+
groups: string[] | null;
|
|
35
|
+
orderBy: string | null;
|
|
36
|
+
} | undefined;
|
|
32
37
|
}[];
|
|
33
38
|
};
|
|
34
39
|
}>>;
|
|
@@ -6,7 +6,7 @@ function cacheOf(context) {
|
|
|
6
6
|
const cloudflare = typeof context === "object" && context !== null ? Reflect.get(context, "cloudflare") : void 0;
|
|
7
7
|
const ctx = typeof cloudflare === "object" && cloudflare !== null ? Reflect.get(cloudflare, "context") : void 0;
|
|
8
8
|
const cache = typeof ctx === "object" && ctx !== null ? Reflect.get(ctx, "cache") : void 0;
|
|
9
|
-
return typeof cache === "object" && cache !== null && typeof Reflect.get(cache, "
|
|
9
|
+
return typeof cache === "object" && cache !== null && typeof Reflect.get(cache, "invalidate") === "function" ? { invalidate: (options) => Reflect.apply(Reflect.get(cache, "invalidate"), cache, [options]) } : void 0;
|
|
10
10
|
}
|
|
11
11
|
var webhook_default = defineEventHandler(async (event) => {
|
|
12
12
|
const config = useRuntimeConfig(event);
|
|
@@ -34,10 +34,10 @@ var webhook_default = defineEventHandler(async (event) => {
|
|
|
34
34
|
const cache = cacheOf(event.context);
|
|
35
35
|
if (cache === void 0) throw createError({
|
|
36
36
|
statusCode: 501,
|
|
37
|
-
statusMessage: "This Worker has no cache to
|
|
37
|
+
statusMessage: "This Worker has no cache to invalidate: set \"cache\": { \"enabled\": true } in wrangler.jsonc"
|
|
38
38
|
});
|
|
39
|
-
if (tags.length > 0) await cache.
|
|
40
|
-
return {
|
|
39
|
+
if (tags.length > 0) await cache.invalidate({ tags });
|
|
40
|
+
return { invalidated: tags };
|
|
41
41
|
});
|
|
42
42
|
//#endregion
|
|
43
43
|
export { webhook_default as default };
|
package/dist/runtime/tags.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ interface Entryish {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function entryTags(entry: Entryish | undefined): string[];
|
|
11
11
|
export declare function listTags(collection: string, locale: string | undefined, entries: readonly Entryish[]): string[];
|
|
12
|
+
export declare function navigationTags(collection: string, locale: string): string[];
|
|
12
13
|
export declare function groupTags(collection: string, group: string, entries: readonly Entryish[]): string[];
|
|
13
14
|
export declare function siteTags(): string[];
|
|
14
15
|
export declare const EDGE_SECONDS = 31536000;
|
package/dist/runtime/tags.mjs
CHANGED
|
@@ -22,6 +22,9 @@ function entryTags(entry) {
|
|
|
22
22
|
function listTags(collection, locale, entries) {
|
|
23
23
|
return [listTag(collection, locale ?? EVERY_LOCALE), ...idsOf(entries)];
|
|
24
24
|
}
|
|
25
|
+
function navigationTags(collection, locale) {
|
|
26
|
+
return [listTag(collection, locale)];
|
|
27
|
+
}
|
|
25
28
|
function groupTags(collection, group, entries) {
|
|
26
29
|
return [groupTag(collection, group), ...idsOf(entries)];
|
|
27
30
|
}
|
|
@@ -33,8 +36,8 @@ function edgeHeaders(tags, status, method) {
|
|
|
33
36
|
if (tags.length === 0 || status !== 200 || method !== "GET") return null;
|
|
34
37
|
return {
|
|
35
38
|
"cache-tag": tags.join(","),
|
|
36
|
-
"cache-control": "public, max-age=0
|
|
37
|
-
"cloudflare-cdn-cache-control": `max-age=${EDGE_SECONDS}`
|
|
39
|
+
"cache-control": "public, max-age=0",
|
|
40
|
+
"cloudflare-cdn-cache-control": `max-age=${EDGE_SECONDS}, stale-if-error=${EDGE_SECONDS}`
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
const PREVIEW_HEADER = "x-hollware-preview";
|
|
@@ -44,4 +47,4 @@ function markPreviewRequest(headers) {
|
|
|
44
47
|
else headers[PREVIEW_HEADER] = crypto.randomUUID();
|
|
45
48
|
}
|
|
46
49
|
//#endregion
|
|
47
|
-
export { EDGE_SECONDS, PREVIEW_HEADER, edgeHeaders, entryTags, groupTags, listTags, markPreviewRequest, recordTags, siteTags, tagsOf };
|
|
50
|
+
export { EDGE_SECONDS, PREVIEW_HEADER, edgeHeaders, entryTags, groupTags, listTags, markPreviewRequest, navigationTags, recordTags, siteTags, tagsOf };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hollware/nuxt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Read Hollware from a Nuxt site, over a service binding or HTTP.",
|
|
5
5
|
"homepage": "https://hollware.com",
|
|
6
6
|
"bugs": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@comark/vue": "0.8.1",
|
|
32
|
-
"@hollware/client": "1.
|
|
33
|
-
"@hollware/core": "1.
|
|
32
|
+
"@hollware/client": "1.1.0",
|
|
33
|
+
"@hollware/core": "1.1.0",
|
|
34
34
|
"@nuxt/kit": "4.6.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|