@hollware/nuxt 1.0.0 → 1.2.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/README.md +12 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +7 -4
- package/dist/route-rules.mjs +1 -2
- package/dist/runtime/components/HollwareContent.d.mts +0 -2
- package/dist/runtime/components/HollwareContent.mjs +1 -2
- package/dist/runtime/components/HollwareImage.d.mts +0 -2
- package/dist/runtime/components/HollwareImage.mjs +1 -2
- package/dist/runtime/composables.d.mts +25 -8
- package/dist/runtime/composables.mjs +44 -16
- package/dist/runtime/generator.d.mts +0 -2
- package/dist/runtime/generator.mjs +1 -2
- package/dist/runtime/server/answer.d.mts +1 -3
- package/dist/runtime/server/answer.mjs +1 -2
- package/dist/runtime/server/cache.d.mts +0 -2
- package/dist/runtime/server/cache.mjs +1 -2
- package/dist/runtime/server/preview-exchange.d.mts +0 -2
- package/dist/runtime/server/preview-exchange.mjs +1 -2
- package/dist/runtime/server/preview.d.mts +0 -2
- package/dist/runtime/server/preview.mjs +1 -2
- package/dist/runtime/server/reader.d.mts +1 -3
- package/dist/runtime/server/reader.mjs +10 -5
- package/dist/runtime/server/routes/entries.d.mts +0 -2
- package/dist/runtime/server/routes/entries.mjs +1 -2
- package/dist/runtime/server/routes/entry.d.mts +0 -2
- package/dist/runtime/server/routes/entry.mjs +1 -2
- package/dist/runtime/server/routes/navigation.d.mts +2 -0
- package/dist/runtime/server/routes/navigation.mjs +10 -0
- package/dist/runtime/server/routes/site.d.mts +5 -2
- package/dist/runtime/server/routes/site.mjs +1 -2
- package/dist/runtime/server/routes/translations.d.mts +0 -2
- package/dist/runtime/server/routes/translations.mjs +1 -2
- package/dist/runtime/server/routes/webhook.d.mts +1 -3
- package/dist/runtime/server/routes/webhook.mjs +5 -6
- package/dist/runtime/server/url.d.mts +1 -3
- package/dist/runtime/server/url.mjs +1 -2
- package/dist/runtime/tags.d.mts +1 -2
- package/dist/runtime/tags.mjs +7 -5
- package/dist/runtime/types.d.mts +1 -3
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -45,6 +45,18 @@ const { data } = await useHollwareEntry('blog', 'en', useRoute().params.slug as
|
|
|
45
45
|
| `useHollwareSite()` | The site: its locales and collections |
|
|
46
46
|
| `<HollwareContent :entry :components>` | Renders the document with `@comark/vue` |
|
|
47
47
|
| `useHollware(event)` (server) | The reader itself, for routes of your own |
|
|
48
|
+
| `useHollwareTags(tags)`, `hollwareTags` | The cache tags of what a route of your own read |
|
|
49
|
+
|
|
50
|
+
Each composable takes `{ lazy, server }` last, as `useFetch` does: with `server: false`, a
|
|
51
|
+
prerendered page reads in the browser only.
|
|
52
|
+
|
|
53
|
+
A route of your own that reads through `useHollware(event).reader` tags its own answer. A page
|
|
54
|
+
that reads that route gives the page the same tags, so `cache: 'purge'` keeps and purges it:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
const { data } = await useFetch('/api/jobs')
|
|
58
|
+
useHollwareTags(hollwareTags.list('jobs', 'es', data.value?.entries ?? []))
|
|
59
|
+
```
|
|
48
60
|
|
|
49
61
|
Every page carries `<meta name="generator" content="Hollware">`; set `hollware.generator: false`
|
|
50
62
|
to leave it out.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PageEntry } from "./runtime/types.mjs";
|
|
2
|
-
//#region src/index.d.ts
|
|
3
2
|
/** The options of `hollware` in nuxt.config.ts. */
|
|
4
3
|
export interface ModuleOptions {
|
|
5
4
|
/** The key of the site in the Hollware config. Required. */
|
|
@@ -27,8 +26,10 @@ export interface ModuleOptions {
|
|
|
27
26
|
*
|
|
28
27
|
* - `'purge'`: in Cloudflare's Workers Cache, which serves them without running the Worker, each
|
|
29
28
|
* tagged with what it showed, until Hollware's webhook to `/_hollware/webhook` (signed with
|
|
30
|
-
* `NUXT_HOLLWARE_WEBHOOK_SECRET`)
|
|
31
|
-
* in seconds everywhere.
|
|
29
|
+
* `NUXT_HOLLWARE_WEBHOOK_SECRET`) marks what changed stale: a publish, an edit or an unpublish
|
|
30
|
+
* shows in seconds everywhere. A page the Worker fails to render again (an error or a `5xx`)
|
|
31
|
+
* is served as it was until it renders. It needs `"cache": { "enabled": true }` in the site's
|
|
32
|
+
* wrangler.jsonc.
|
|
32
33
|
* - a number of seconds: kept by Nitro (`swr`) in each isolate, and rendered again in the
|
|
33
34
|
* background once that old; a change shows within that time.
|
|
34
35
|
*
|
|
@@ -40,5 +41,4 @@ export interface ModuleOptions {
|
|
|
40
41
|
}
|
|
41
42
|
export declare const name = "@hollware/nuxt";
|
|
42
43
|
declare const _default: import("nuxt/schema").NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
43
|
-
//#endregion
|
|
44
44
|
export { type PageEntry, _default as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { secondsCacheRules } from "./route-rules.mjs";
|
|
2
2
|
import { addComponent, addImports, addPlugin, addServerHandler, addServerImports, addServerPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
|
|
3
|
-
|
|
3
|
+
// src/index.ts
|
|
4
4
|
const name = "@hollware/nuxt";
|
|
5
5
|
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,8 +43,11 @@ var src_default = defineNuxtModule({
|
|
|
42
43
|
addImports([
|
|
43
44
|
"useHollwareEntry",
|
|
44
45
|
"useHollwareEntries",
|
|
46
|
+
"useHollwareNavigation",
|
|
45
47
|
"useHollwareSite",
|
|
46
|
-
"
|
|
48
|
+
"useHollwareTags",
|
|
49
|
+
"useHollwareTranslations",
|
|
50
|
+
"hollwareTags"
|
|
47
51
|
].map((imported) => ({
|
|
48
52
|
name: imported,
|
|
49
53
|
from: resolve("./runtime/composables")
|
|
@@ -76,5 +80,4 @@ var src_default = defineNuxtModule({
|
|
|
76
80
|
};
|
|
77
81
|
}
|
|
78
82
|
});
|
|
79
|
-
//#endregion
|
|
80
83
|
export { src_default as default, name };
|
package/dist/route-rules.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PREVIEW_HEADER } from "./runtime/tags.mjs";
|
|
2
|
-
|
|
2
|
+
// src/route-rules.ts
|
|
3
3
|
function secondsCacheRules(seconds) {
|
|
4
4
|
return {
|
|
5
5
|
"/**": { cache: {
|
|
@@ -13,5 +13,4 @@ function secondsCacheRules(seconds) {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { secondsCacheRules };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PropType } from "vue";
|
|
2
|
-
//#region src/runtime/components/HollwareContent.d.ts
|
|
3
2
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
3
|
entry: {
|
|
5
4
|
type: PropType<{
|
|
@@ -30,5 +29,4 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
30
29
|
} | null | undefined;
|
|
31
30
|
components: Record<string, unknown>;
|
|
32
31
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
33
|
-
//#endregion
|
|
34
32
|
export { _default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, h } from "vue";
|
|
2
2
|
import { MarkdownDocument } from "@comark/vue";
|
|
3
|
-
|
|
3
|
+
// src/runtime/components/HollwareContent.ts
|
|
4
4
|
var HollwareContent_default = defineComponent({
|
|
5
5
|
name: "HollwareContent",
|
|
6
6
|
props: {
|
|
@@ -24,5 +24,4 @@ var HollwareContent_default = defineComponent({
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
//#endregion
|
|
28
27
|
export { HollwareContent_default as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { imageOf } from "@hollware/client";
|
|
2
2
|
import { PropType } from "vue";
|
|
3
|
-
//#region src/runtime/components/HollwareImage.d.ts
|
|
4
3
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
4
|
entry: {
|
|
6
5
|
type: PropType<Parameters<typeof imageOf>[0]>;
|
|
@@ -27,5 +26,4 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
27
26
|
readonly images?: Readonly<Record<string, import("@hollware/client").PageImage>>;
|
|
28
27
|
} | null | undefined;
|
|
29
28
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
30
|
-
//#endregion
|
|
31
29
|
export { _default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { imageOf } from "@hollware/client";
|
|
2
2
|
import { defineComponent, h } from "vue";
|
|
3
|
-
|
|
3
|
+
// src/runtime/components/HollwareImage.ts
|
|
4
4
|
var HollwareImage_default = defineComponent({
|
|
5
5
|
name: "HollwareImage",
|
|
6
6
|
props: {
|
|
@@ -28,5 +28,4 @@ var HollwareImage_default = defineComponent({
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
//#endregion
|
|
32
31
|
export { HollwareImage_default as default };
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { PageEntry } from "./types.mjs";
|
|
2
|
+
import { entryTags, groupTags, listTags, navigationTags, siteTags } from "./tags.mjs";
|
|
2
3
|
import { MaybeRefOrGetter } from "vue";
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
export interface HollwareFetching {
|
|
5
|
+
readonly lazy?: boolean;
|
|
6
|
+
readonly server?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const hollwareTags: {
|
|
9
|
+
entry: typeof entryTags;
|
|
10
|
+
list: typeof listTags;
|
|
11
|
+
group: typeof groupTags;
|
|
12
|
+
navigation: typeof navigationTags;
|
|
13
|
+
site: typeof siteTags;
|
|
14
|
+
};
|
|
15
|
+
export declare function useHollwareTags(tags: readonly string[]): void;
|
|
16
|
+
export declare function useHollwareEntry(collection: MaybeRefOrGetter<string>, locale: MaybeRefOrGetter<string>, slug: MaybeRefOrGetter<string>, fetching?: HollwareFetching): import("nuxt/app").AsyncData<{
|
|
5
17
|
outcome: 'ok';
|
|
6
18
|
entry: PageEntry;
|
|
7
19
|
} | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
@@ -10,18 +22,19 @@ export declare function useHollwareEntries(collection: MaybeRefOrGetter<string>,
|
|
|
10
22
|
tag?: string;
|
|
11
23
|
limit?: number;
|
|
12
24
|
cursor?: string;
|
|
13
|
-
}>, fetching?: {
|
|
14
|
-
lazy?: boolean;
|
|
15
|
-
}): import("nuxt/app").AsyncData<{
|
|
25
|
+
}>, fetching?: HollwareFetching): import("nuxt/app").AsyncData<{
|
|
16
26
|
outcome: 'ok';
|
|
17
27
|
entries: PageEntry[];
|
|
18
28
|
nextCursor: string | null;
|
|
19
29
|
} | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
20
|
-
export declare function useHollwareTranslations(collection: MaybeRefOrGetter<string>, group: MaybeRefOrGetter<string
|
|
30
|
+
export declare function useHollwareTranslations(collection: MaybeRefOrGetter<string>, group: MaybeRefOrGetter<string>, fetching?: HollwareFetching): import("nuxt/app").AsyncData<{
|
|
21
31
|
outcome: 'ok';
|
|
22
32
|
entries: PageEntry[];
|
|
23
33
|
} | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
24
|
-
export declare function
|
|
34
|
+
export declare function useHollwareNavigation(collection: MaybeRefOrGetter<string>, options?: MaybeRefOrGetter<{
|
|
35
|
+
locale?: string;
|
|
36
|
+
}>, fetching?: HollwareFetching): import("nuxt/app").AsyncData<import("@hollware/core").Navigation | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
37
|
+
export declare function useHollwareSite(fetching?: HollwareFetching): import("nuxt/app").AsyncData<{
|
|
25
38
|
outcome: "ok";
|
|
26
39
|
site: {
|
|
27
40
|
key: string;
|
|
@@ -51,8 +64,12 @@ export declare function useHollwareSite(): import("nuxt/app").AsyncData<{
|
|
|
51
64
|
}[];
|
|
52
65
|
maxMarkdownBytes: number;
|
|
53
66
|
styleGuide: string | null;
|
|
67
|
+
navigation?: {
|
|
68
|
+
groupBy: string | null;
|
|
69
|
+
groups: string[] | null;
|
|
70
|
+
orderBy: string | null;
|
|
71
|
+
} | undefined;
|
|
54
72
|
}[];
|
|
55
73
|
};
|
|
56
74
|
} | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
57
|
-
//#endregion
|
|
58
75
|
export type { PageEntry };
|
|
@@ -1,15 +1,26 @@
|
|
|
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";
|
|
5
|
-
|
|
5
|
+
// src/runtime/composables.ts
|
|
6
6
|
function pageRequest() {
|
|
7
|
-
return
|
|
7
|
+
return useRequestEvent();
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
const hollwareTags = {
|
|
10
|
+
entry: entryTags,
|
|
11
|
+
list: listTags,
|
|
12
|
+
group: groupTags,
|
|
13
|
+
navigation: navigationTags,
|
|
14
|
+
site: siteTags
|
|
15
|
+
};
|
|
16
|
+
function useHollwareTags(tags) {
|
|
17
|
+
recordTags(pageRequest(), tags);
|
|
18
|
+
}
|
|
19
|
+
function useHollwareEntry(collection, locale, slug, fetching = {}) {
|
|
10
20
|
const path = computed(() => `/_hollware/entry/${encodeURIComponent(toValue(collection))}/${encodeURIComponent(toValue(locale))}/${encodeURIComponent(toValue(slug))}`);
|
|
11
21
|
const event = pageRequest();
|
|
12
22
|
return useFetch(path, {
|
|
23
|
+
...fetching,
|
|
13
24
|
transform: (answer) => {
|
|
14
25
|
recordTags(event, entryTags(answer.entry));
|
|
15
26
|
return answer;
|
|
@@ -32,20 +43,37 @@ function useHollwareEntries(collection, options = {}, fetching = {}) {
|
|
|
32
43
|
}
|
|
33
44
|
});
|
|
34
45
|
}
|
|
35
|
-
function useHollwareTranslations(collection, group) {
|
|
46
|
+
function useHollwareTranslations(collection, group, fetching = {}) {
|
|
36
47
|
const path = computed(() => `/_hollware/translations/${encodeURIComponent(toValue(collection))}/${encodeURIComponent(toValue(group))}`);
|
|
37
48
|
const event = pageRequest();
|
|
38
|
-
return useFetch(path, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
return useFetch(path, {
|
|
50
|
+
...fetching,
|
|
51
|
+
transform: (answer) => {
|
|
52
|
+
recordTags(event, groupTags(toValue(collection), toValue(group), answer.entries));
|
|
53
|
+
return answer;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function useHollwareNavigation(collection, options = {}, fetching = {}) {
|
|
58
|
+
const path = computed(() => `/_hollware/navigation/${encodeURIComponent(toValue(collection))}`);
|
|
59
|
+
const event = pageRequest();
|
|
60
|
+
return useFetch(path, {
|
|
61
|
+
query: computed(() => toValue(options)),
|
|
62
|
+
...fetching,
|
|
63
|
+
transform: (answer) => {
|
|
64
|
+
recordTags(event, navigationTags(toValue(collection), answer.locale));
|
|
65
|
+
return answer;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
42
68
|
}
|
|
43
|
-
function useHollwareSite() {
|
|
69
|
+
function useHollwareSite(fetching = {}) {
|
|
44
70
|
const event = pageRequest();
|
|
45
|
-
return useFetch("/_hollware/site", {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
71
|
+
return useFetch("/_hollware/site", {
|
|
72
|
+
...fetching,
|
|
73
|
+
transform: (answer) => {
|
|
74
|
+
recordTags(event, siteTags());
|
|
75
|
+
return answer;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
49
78
|
}
|
|
50
|
-
|
|
51
|
-
export { useHollwareEntries, useHollwareEntry, useHollwareSite, useHollwareTranslations };
|
|
79
|
+
export { hollwareTags, useHollwareEntries, useHollwareEntry, useHollwareNavigation, useHollwareSite, useHollwareTags, useHollwareTranslations };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { defineNuxtPlugin, useHead } from "nuxt/app";
|
|
2
|
-
|
|
2
|
+
// src/runtime/generator.ts
|
|
3
3
|
var generator_default = defineNuxtPlugin(() => {
|
|
4
4
|
useHead({ meta: [{
|
|
5
5
|
name: "generator",
|
|
6
6
|
content: "Hollware"
|
|
7
7
|
}] });
|
|
8
8
|
});
|
|
9
|
-
//#endregion
|
|
10
9
|
export { generator_default as default };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { H3Event } from "h3";
|
|
2
|
-
//#region src/runtime/server/answer.d.ts
|
|
3
2
|
export declare function answer<Value extends {
|
|
4
3
|
outcome: string;
|
|
5
4
|
}>(event: H3Event, read: () => Promise<Value>): Promise<Value>;
|
|
6
|
-
export declare function forPage(entry: unknown): Record<string, unknown> | undefined;
|
|
7
|
-
//#endregion
|
|
5
|
+
export declare function forPage(entry: unknown): Record<string, unknown> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HollwareClientError } from "@hollware/client";
|
|
2
2
|
import { createError, setResponseHeader } from "h3";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/answer.ts
|
|
4
4
|
async function answer(event, read) {
|
|
5
5
|
let value;
|
|
6
6
|
try {
|
|
@@ -36,5 +36,4 @@ function forPage(entry) {
|
|
|
36
36
|
if (typeof entry !== "object" || entry === null) return void 0;
|
|
37
37
|
return Object.fromEntries(PUBLIC_FIELDS.filter((field) => field in entry).map((field) => [field, Reflect.get(entry, field)]));
|
|
38
38
|
}
|
|
39
|
-
//#endregion
|
|
40
39
|
export { answer, forPage };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { edgeHeaders, tagsOf } from "../tags.mjs";
|
|
2
2
|
import { previewTokenFromCookie } from "@hollware/client";
|
|
3
3
|
import { defineNitroPlugin } from "nitropack/runtime";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/cache.ts
|
|
5
5
|
var cache_default = defineNitroPlugin((nitroApp) => {
|
|
6
6
|
nitroApp.hooks.hook("beforeResponse", (event) => {
|
|
7
7
|
if (previewTokenFromCookie(event.node.req.headers.cookie) !== void 0) return;
|
|
@@ -9,5 +9,4 @@ var cache_default = defineNitroPlugin((nitroApp) => {
|
|
|
9
9
|
for (const [name, value] of Object.entries(headers ?? {})) event.node.res.setHeader(name, value);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
|
-
//#endregion
|
|
13
12
|
export { cache_default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { requestUrl } from "./url.mjs";
|
|
2
2
|
import { exchangeHeaders, exchangePreviewLink } from "@hollware/client";
|
|
3
3
|
import { defineEventHandler, sendRedirect, setResponseHeader } from "h3";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/preview-exchange.ts
|
|
5
5
|
var preview_exchange_default = defineEventHandler((event) => {
|
|
6
6
|
if (event.method !== "GET" && event.method !== "HEAD") return;
|
|
7
7
|
const url = requestUrl(event);
|
|
@@ -11,5 +11,4 @@ var preview_exchange_default = defineEventHandler((event) => {
|
|
|
11
11
|
for (const [name, value] of exchangeHeaders(exchange, url)) if (name !== "location") setResponseHeader(event, name, value);
|
|
12
12
|
return sendRedirect(event, exchange.location, 303);
|
|
13
13
|
});
|
|
14
|
-
//#endregion
|
|
15
14
|
export { preview_exchange_default as default };
|
|
@@ -2,7 +2,7 @@ import { markPreviewRequest } from "../tags.mjs";
|
|
|
2
2
|
import { previewTokenFromCookie } from "@hollware/client";
|
|
3
3
|
import { removeResponseHeader, setResponseHeader } from "h3";
|
|
4
4
|
import { defineNitroPlugin } from "nitropack/runtime";
|
|
5
|
-
|
|
5
|
+
// src/runtime/server/preview.ts
|
|
6
6
|
var preview_default = defineNitroPlugin((nitroApp) => {
|
|
7
7
|
nitroApp.hooks.hook("request", (event) => {
|
|
8
8
|
markPreviewRequest(event.node.req.headers);
|
|
@@ -13,5 +13,4 @@ var preview_default = defineNitroPlugin((nitroApp) => {
|
|
|
13
13
|
for (const name of ["cache-tag", "cloudflare-cdn-cache-control"]) removeResponseHeader(event, name);
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
|
-
//#endregion
|
|
17
16
|
export { preview_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
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";
|
|
5
|
-
|
|
5
|
+
// src/runtime/server/reader.ts
|
|
6
6
|
function isReader(value) {
|
|
7
7
|
return typeof value === "object" && value !== null && "getEntry" in value;
|
|
8
8
|
}
|
|
@@ -28,7 +28,6 @@ function useHollware(event) {
|
|
|
28
28
|
}
|
|
29
29
|
function tagging(event, reader) {
|
|
30
30
|
return {
|
|
31
|
-
...reader,
|
|
32
31
|
getEntry: async (...args) => {
|
|
33
32
|
const answer = await reader.getEntry(...args);
|
|
34
33
|
if (args[4]?.preview === void 0) recordTags(event, entryTags(answer.entry));
|
|
@@ -44,12 +43,18 @@ function tagging(event, reader) {
|
|
|
44
43
|
recordTags(event, groupTags(args[1], args[2], answer.entries ?? []));
|
|
45
44
|
return answer;
|
|
46
45
|
},
|
|
46
|
+
getNavigation: async (...args) => {
|
|
47
|
+
const answer = await reader.getNavigation(...args);
|
|
48
|
+
recordTags(event, navigationTags(args[1], answer.locale));
|
|
49
|
+
return answer;
|
|
50
|
+
},
|
|
47
51
|
describeSite: async (...args) => {
|
|
48
52
|
const answer = await reader.describeSite(...args);
|
|
49
53
|
recordTags(event, siteTags());
|
|
50
54
|
return answer;
|
|
51
|
-
}
|
|
55
|
+
},
|
|
56
|
+
search: (...args) => reader.search(...args),
|
|
57
|
+
listRedirects: (...args) => reader.listRedirects(...args)
|
|
52
58
|
};
|
|
53
59
|
}
|
|
54
|
-
//#endregion
|
|
55
60
|
export { useHollware };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//#region src/runtime/server/routes/entries.d.ts
|
|
2
1
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
3
2
|
outcome: "ok";
|
|
4
3
|
entries: Record<string, unknown>[];
|
|
5
4
|
nextCursor: string | null;
|
|
6
5
|
}>>;
|
|
7
|
-
//#endregion
|
|
8
6
|
export { _default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { answer, forPage } from "../answer.mjs";
|
|
2
2
|
import { useHollware } from "../reader.mjs";
|
|
3
3
|
import { defineEventHandler, getQuery, getRouterParam } from "h3";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/routes/entries.ts
|
|
5
5
|
const text = (value) => typeof value === "string" && value !== "" ? value : void 0;
|
|
6
6
|
var entries_default = defineEventHandler(async (event) => {
|
|
7
7
|
const { site, reader } = useHollware(event);
|
|
@@ -26,5 +26,4 @@ var entries_default = defineEventHandler(async (event) => {
|
|
|
26
26
|
nextCursor: page.nextCursor
|
|
27
27
|
};
|
|
28
28
|
});
|
|
29
|
-
//#endregion
|
|
30
29
|
export { entries_default as default };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//#region src/runtime/server/routes/entry.d.ts
|
|
2
1
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
3
2
|
outcome: "not_found" | "ok";
|
|
4
3
|
entry: Record<string, unknown> | undefined;
|
|
5
4
|
}>>;
|
|
6
|
-
//#endregion
|
|
7
5
|
export { _default as default };
|
|
@@ -3,7 +3,7 @@ import { requestUrl } from "../url.mjs";
|
|
|
3
3
|
import { useHollware } from "../reader.mjs";
|
|
4
4
|
import { clearedPreviewCookie, isPreviewRefusal, isSecureRequest, previewTokenFromCookie } from "@hollware/client";
|
|
5
5
|
import { appendResponseHeader, createError, defineEventHandler, getHeader, getRouterParam } from "h3";
|
|
6
|
-
|
|
6
|
+
// src/runtime/server/routes/entry.ts
|
|
7
7
|
var entry_default = defineEventHandler(async (event) => {
|
|
8
8
|
const { site, reader } = useHollware(event);
|
|
9
9
|
const param = (name) => getRouterParam(event, name) ?? "";
|
|
@@ -25,5 +25,4 @@ var entry_default = defineEventHandler(async (event) => {
|
|
|
25
25
|
entry: forPage(found.entry)
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
-
//#endregion
|
|
29
28
|
export { entry_default as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { answer } from "../answer.mjs";
|
|
2
|
+
import { useHollware } from "../reader.mjs";
|
|
3
|
+
import { defineEventHandler, getQuery, getRouterParam } from "h3";
|
|
4
|
+
// 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
|
+
export { navigation_default as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/server/routes/site.d.ts
|
|
2
1
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
3
2
|
outcome: "ok";
|
|
4
3
|
site: {
|
|
@@ -29,8 +28,12 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
29
28
|
}[];
|
|
30
29
|
maxMarkdownBytes: number;
|
|
31
30
|
styleGuide: string | null;
|
|
31
|
+
navigation?: {
|
|
32
|
+
groupBy: string | null;
|
|
33
|
+
groups: string[] | null;
|
|
34
|
+
orderBy: string | null;
|
|
35
|
+
} | undefined;
|
|
32
36
|
}[];
|
|
33
37
|
};
|
|
34
38
|
}>>;
|
|
35
|
-
//#endregion
|
|
36
39
|
export { _default as default };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { answer } from "../answer.mjs";
|
|
2
2
|
import { useHollware } from "../reader.mjs";
|
|
3
3
|
import { defineEventHandler } from "h3";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/routes/site.ts
|
|
5
5
|
var site_default = defineEventHandler((event) => {
|
|
6
6
|
const { site, reader } = useHollware(event);
|
|
7
7
|
return answer(event, () => reader.describeSite(site));
|
|
8
8
|
});
|
|
9
|
-
//#endregion
|
|
10
9
|
export { site_default as default };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
//#region src/runtime/server/routes/translations.d.ts
|
|
2
1
|
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
3
2
|
outcome: "not_found" | "ok";
|
|
4
3
|
entries: Record<string, unknown>[];
|
|
5
4
|
}>>;
|
|
6
|
-
//#endregion
|
|
7
5
|
export { _default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { answer, forPage } from "../answer.mjs";
|
|
2
2
|
import { useHollware } from "../reader.mjs";
|
|
3
3
|
import { defineEventHandler, getRouterParam } from "h3";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/routes/translations.ts
|
|
5
5
|
var translations_default = defineEventHandler(async (event) => {
|
|
6
6
|
const { site, reader } = useHollware(event);
|
|
7
7
|
const group = await answer(event, () => reader.getTranslations(site, getRouterParam(event, "collection") ?? "", getRouterParam(event, "group") ?? ""));
|
|
@@ -11,5 +11,4 @@ var translations_default = defineEventHandler(async (event) => {
|
|
|
11
11
|
entries
|
|
12
12
|
};
|
|
13
13
|
});
|
|
14
|
-
//#endregion
|
|
15
14
|
export { translations_default as default };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { verifyWebhook } from "@hollware/core";
|
|
2
2
|
import { createError, defineEventHandler, getRequestHeaders, readRawBody } from "h3";
|
|
3
3
|
import { useRuntimeConfig } from "nitropack/runtime";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/routes/webhook.ts
|
|
5
5
|
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,9 @@ 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
|
-
//#endregion
|
|
43
42
|
export { webhook_default as default };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { getRequestURL } from "h3";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/url.ts
|
|
3
3
|
function requestUrl(event) {
|
|
4
4
|
const request = event.context["cloudflare"]?.request;
|
|
5
5
|
const url = typeof request === "object" && request !== null ? Reflect.get(request, "url") : void 0;
|
|
6
6
|
return typeof url === "string" ? new URL(url) : getRequestURL(event);
|
|
7
7
|
}
|
|
8
|
-
//#endregion
|
|
9
8
|
export { requestUrl };
|
package/dist/runtime/tags.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/tags.d.ts
|
|
2
1
|
interface Tagged {
|
|
3
2
|
readonly context: Record<string, unknown>;
|
|
4
3
|
}
|
|
@@ -9,11 +8,11 @@ interface Entryish {
|
|
|
9
8
|
}
|
|
10
9
|
export declare function entryTags(entry: Entryish | undefined): string[];
|
|
11
10
|
export declare function listTags(collection: string, locale: string | undefined, entries: readonly Entryish[]): string[];
|
|
11
|
+
export declare function navigationTags(collection: string, locale: string): string[];
|
|
12
12
|
export declare function groupTags(collection: string, group: string, entries: readonly Entryish[]): string[];
|
|
13
13
|
export declare function siteTags(): string[];
|
|
14
14
|
export declare const EDGE_SECONDS = 31536000;
|
|
15
15
|
export declare function edgeHeaders(tags: readonly string[], status: number, method: string): Readonly<Record<string, string>> | null;
|
|
16
16
|
export declare const PREVIEW_HEADER = "x-hollware-preview";
|
|
17
17
|
export declare function markPreviewRequest(headers: Record<string, string | string[] | undefined>): void;
|
|
18
|
-
//#endregion
|
|
19
18
|
export {};
|
package/dist/runtime/tags.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { previewTokenFromCookie } from "@hollware/client";
|
|
2
2
|
import { EVERY_LOCALE, SITE_TAG, entryTag, groupTag, listTag } from "@hollware/core";
|
|
3
|
-
|
|
3
|
+
// src/runtime/tags.ts
|
|
4
4
|
const KEY = "hollwareTags";
|
|
5
5
|
function recordTags(event, tags) {
|
|
6
6
|
if (event === void 0 || tags.length === 0) return;
|
|
@@ -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";
|
|
@@ -43,5 +46,4 @@ function markPreviewRequest(headers) {
|
|
|
43
46
|
if (previewTokenFromCookie(typeof cookie === "string" ? cookie : void 0) === void 0) delete headers[PREVIEW_HEADER];
|
|
44
47
|
else headers[PREVIEW_HEADER] = crypto.randomUUID();
|
|
45
48
|
}
|
|
46
|
-
|
|
47
|
-
export { EDGE_SECONDS, PREVIEW_HEADER, edgeHeaders, entryTags, groupTags, listTags, markPreviewRequest, recordTags, siteTags, tagsOf };
|
|
49
|
+
export { EDGE_SECONDS, PREVIEW_HEADER, edgeHeaders, entryTags, groupTags, listTags, markPreviewRequest, navigationTags, recordTags, siteTags, tagsOf };
|
package/dist/runtime/types.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/types.d.ts
|
|
2
1
|
/** An entry as a page of the site gets it: what a reader sees, and how to render it. */
|
|
3
2
|
export interface PageEntry {
|
|
4
3
|
readonly id: string;
|
|
@@ -12,5 +11,4 @@ export interface PageEntry {
|
|
|
12
11
|
readonly updatedAt: string;
|
|
13
12
|
/** The Comark document of the entry: only an entry read alone has it. */
|
|
14
13
|
readonly document?: unknown;
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hollware/nuxt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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,21 +29,22 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@comark/vue": "0.8.1",
|
|
32
|
-
"@hollware/client": "1.
|
|
33
|
-
"@hollware/core": "1.
|
|
34
|
-
"@nuxt/kit": "4.6.2"
|
|
32
|
+
"@hollware/client": "1.2.0",
|
|
33
|
+
"@hollware/core": "1.2.0"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
36
|
+
"@nuxt/kit": "4.6.3",
|
|
37
37
|
"@types/node": "24.19.2",
|
|
38
38
|
"h3": "1.15.11",
|
|
39
|
-
"nitropack": "2.13.
|
|
40
|
-
"nuxt": "4.6.
|
|
39
|
+
"nitropack": "2.13.5",
|
|
40
|
+
"nuxt": "4.6.3",
|
|
41
41
|
"publint": "0.3.25",
|
|
42
42
|
"typescript": "7.0.2",
|
|
43
|
-
"vite-plus": "1.
|
|
43
|
+
"vite-plus": "1.4.0",
|
|
44
44
|
"vue": "3.5.44"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
+
"@nuxt/kit": "^4.6.0",
|
|
47
48
|
"h3": "^1.15.0",
|
|
48
49
|
"nitropack": "^2.13.0",
|
|
49
50
|
"nuxt": "^4.6.0",
|