@hollware/nuxt 1.7.0 → 1.9.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 +2 -1
- package/dist/index.mjs +3 -1
- package/dist/runtime/composables.d.mts +16 -0
- package/dist/runtime/composables.mjs +16 -1
- package/dist/runtime/server/answer.mjs +2 -0
- package/dist/runtime/server/reader.mjs +5 -0
- package/dist/runtime/server/routes/page.d.mts +16 -0
- package/dist/runtime/server/routes/page.d.ts +1 -0
- package/dist/runtime/server/routes/page.mjs +41 -0
- package/dist/runtime/server/routes/site.d.mts +3 -0
- package/dist/runtime/types.d.mts +4 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PageEntry } from "./runtime/types.mjs";
|
|
2
|
+
import { NavigationEntry, NavigationGroup } from "@hollware/client";
|
|
2
3
|
/** The options of `hollware` in nuxt.config.ts. */
|
|
3
4
|
export interface ModuleOptions {
|
|
4
5
|
/** The key of the site in the Hollware config. Required. */
|
|
@@ -41,4 +42,4 @@ export interface ModuleOptions {
|
|
|
41
42
|
}
|
|
42
43
|
export declare const name = "@hollware/nuxt";
|
|
43
44
|
declare const _default: import("nuxt/schema").NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
44
|
-
export { type PageEntry, _default as default };
|
|
45
|
+
export { type NavigationEntry, type NavigationGroup, type PageEntry, _default as default };
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,8 @@ const ROUTES = [
|
|
|
7
7
|
["/_hollware/entries/:collection", "entries"],
|
|
8
8
|
["/_hollware/entry/:collection/:locale/:slug", "entry"],
|
|
9
9
|
["/_hollware/translations/:collection/:group", "translations"],
|
|
10
|
-
["/_hollware/navigation/:collection", "navigation"]
|
|
10
|
+
["/_hollware/navigation/:collection", "navigation"],
|
|
11
|
+
["/_hollware/page", "page"]
|
|
11
12
|
];
|
|
12
13
|
var src_default = defineNuxtModule({
|
|
13
14
|
meta: {
|
|
@@ -44,6 +45,7 @@ var src_default = defineNuxtModule({
|
|
|
44
45
|
"useHollwareEntry",
|
|
45
46
|
"useHollwareEntries",
|
|
46
47
|
"useHollwareNavigation",
|
|
48
|
+
"useHollwarePage",
|
|
47
49
|
"useHollwareSite",
|
|
48
50
|
"useHollwareTags",
|
|
49
51
|
"useHollwareTranslations",
|
|
@@ -34,6 +34,19 @@ export declare function useHollwareTranslations(collection: MaybeRefOrGetter<str
|
|
|
34
34
|
export declare function useHollwareNavigation(collection: MaybeRefOrGetter<string>, options?: MaybeRefOrGetter<{
|
|
35
35
|
locale?: string;
|
|
36
36
|
}>, fetching?: HollwareFetching): import("nuxt/app").AsyncData<import("@hollware/core").Navigation | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
37
|
+
export interface PageAncestor {
|
|
38
|
+
readonly slug: string;
|
|
39
|
+
readonly title: string;
|
|
40
|
+
readonly path: string | null;
|
|
41
|
+
}
|
|
42
|
+
export declare function useHollwarePage(path: MaybeRefOrGetter<string>, fetching?: HollwareFetching): import("nuxt/app").AsyncData<{
|
|
43
|
+
outcome: 'ok';
|
|
44
|
+
entry: PageEntry;
|
|
45
|
+
ancestors: PageAncestor[];
|
|
46
|
+
} | {
|
|
47
|
+
outcome: 'redirect';
|
|
48
|
+
path: string;
|
|
49
|
+
} | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
37
50
|
export declare function useHollwareSite(fetching?: HollwareFetching): import("nuxt/app").AsyncData<{
|
|
38
51
|
outcome: "ok";
|
|
39
52
|
site: {
|
|
@@ -69,6 +82,9 @@ export declare function useHollwareSite(fetching?: HollwareFetching): import("nu
|
|
|
69
82
|
groups: string[] | null;
|
|
70
83
|
orderBy: string | null;
|
|
71
84
|
} | undefined;
|
|
85
|
+
nesting?: {
|
|
86
|
+
maxDepth: number;
|
|
87
|
+
} | undefined;
|
|
72
88
|
}[];
|
|
73
89
|
};
|
|
74
90
|
} | undefined, import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
@@ -66,6 +66,21 @@ function useHollwareNavigation(collection, options = {}, fetching = {}) {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
+
function useHollwarePage(path, fetching = {}) {
|
|
70
|
+
const event = pageRequest();
|
|
71
|
+
return useFetch("/_hollware/page", {
|
|
72
|
+
query: computed(() => ({ path: toValue(path) })),
|
|
73
|
+
...fetching,
|
|
74
|
+
transform: (answer) => {
|
|
75
|
+
if (answer.outcome === "ok") recordTags(event, entryTags(answer.entry));
|
|
76
|
+
return answer;
|
|
77
|
+
},
|
|
78
|
+
onResponseError: ({ response }) => {
|
|
79
|
+
if (event === void 0) return;
|
|
80
|
+
for (const cookie of response.headers.getSetCookie()) appendResponseHeader(event, "set-cookie", cookie);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
69
84
|
function useHollwareSite(fetching = {}) {
|
|
70
85
|
const event = pageRequest();
|
|
71
86
|
return useFetch("/_hollware/site", {
|
|
@@ -76,4 +91,4 @@ function useHollwareSite(fetching = {}) {
|
|
|
76
91
|
}
|
|
77
92
|
});
|
|
78
93
|
}
|
|
79
|
-
export { hollwareTags, useHollwareEntries, useHollwareEntry, useHollwareNavigation, useHollwareSite, useHollwareTags, useHollwareTranslations };
|
|
94
|
+
export { hollwareTags, useHollwareEntries, useHollwareEntry, useHollwareNavigation, useHollwarePage, useHollwareSite, useHollwareTags, useHollwareTranslations };
|
|
@@ -48,6 +48,11 @@ function tagging(event, reader) {
|
|
|
48
48
|
recordTags(event, navigationTags(args[1], answer.locale));
|
|
49
49
|
return answer;
|
|
50
50
|
},
|
|
51
|
+
resolvePath: async (...args) => {
|
|
52
|
+
const answer = await reader.resolvePath(...args);
|
|
53
|
+
if (answer.outcome !== "not_found" && args[2]?.preview === void 0) recordTags(event, navigationTags(answer.collection, answer.locale));
|
|
54
|
+
return answer;
|
|
55
|
+
},
|
|
51
56
|
describeSite: async (...args) => {
|
|
52
57
|
const answer = await reader.describeSite(...args);
|
|
53
58
|
recordTags(event, siteTags());
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
2
|
+
outcome: string;
|
|
3
|
+
path: string;
|
|
4
|
+
entry?: undefined;
|
|
5
|
+
ancestors?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
path?: undefined;
|
|
8
|
+
outcome: "not_found" | "ok";
|
|
9
|
+
entry: Record<string, unknown> | undefined;
|
|
10
|
+
ancestors: {
|
|
11
|
+
slug: string;
|
|
12
|
+
title: string;
|
|
13
|
+
path: string | null;
|
|
14
|
+
}[];
|
|
15
|
+
}>>;
|
|
16
|
+
export { _default as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './page.mjs'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { answer, forPage } from "../answer.mjs";
|
|
2
|
+
import { requestUrl } from "../url.mjs";
|
|
3
|
+
import { useHollware } from "../reader.mjs";
|
|
4
|
+
import { clearedPreviewCookie, isPreviewRefusal, isSecureRequest, previewTokenFromCookie } from "@hollware/client";
|
|
5
|
+
import { appendResponseHeader, createError, defineEventHandler, getHeader, getQuery } from "h3";
|
|
6
|
+
// src/runtime/server/routes/page.ts
|
|
7
|
+
var page_default = defineEventHandler(async (event) => {
|
|
8
|
+
const { site, reader } = useHollware(event);
|
|
9
|
+
const query = getQuery(event)["path"];
|
|
10
|
+
const path = typeof query === "string" && query.startsWith("/") ? query : "/";
|
|
11
|
+
const preview = previewTokenFromCookie(getHeader(event, "cookie"));
|
|
12
|
+
const options = preview === void 0 ? {} : { preview };
|
|
13
|
+
const refused = (error) => {
|
|
14
|
+
if (preview === void 0 || !isPreviewRefusal(error)) throw error;
|
|
15
|
+
const secure = isSecureRequest(requestUrl(event));
|
|
16
|
+
appendResponseHeader(event, "set-cookie", clearedPreviewCookie({ secure }));
|
|
17
|
+
throw createError({
|
|
18
|
+
statusCode: 404,
|
|
19
|
+
statusMessage: "Not found in Hollware"
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const resolved = await answer(event, () => reader.resolvePath(site, path, options).catch(refused));
|
|
23
|
+
if (resolved.outcome === "redirect") return {
|
|
24
|
+
outcome: "redirect",
|
|
25
|
+
path: resolved.path
|
|
26
|
+
};
|
|
27
|
+
if (resolved.outcome !== "ok") throw createError({
|
|
28
|
+
statusCode: 404,
|
|
29
|
+
statusMessage: "Not found in Hollware"
|
|
30
|
+
});
|
|
31
|
+
const found = await answer(event, () => reader.getEntry(site, resolved.collection, resolved.slug, resolved.locale, {
|
|
32
|
+
formats: ["document"],
|
|
33
|
+
...options
|
|
34
|
+
}).catch(refused));
|
|
35
|
+
return {
|
|
36
|
+
outcome: found.outcome,
|
|
37
|
+
entry: forPage(found.entry),
|
|
38
|
+
ancestors: found.ancestors ?? []
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
export { page_default as default };
|
package/dist/runtime/types.d.mts
CHANGED
|
@@ -4,6 +4,10 @@ export interface PageEntry {
|
|
|
4
4
|
readonly collection: string;
|
|
5
5
|
readonly locale: string;
|
|
6
6
|
readonly slug: string;
|
|
7
|
+
/** In a nested collection, the slug of its parent; `null` at the root and in a flat one. */
|
|
8
|
+
readonly parent?: string | null;
|
|
9
|
+
/** The slugs of its ancestors and its own, joined by `/`. */
|
|
10
|
+
readonly slugPath?: string;
|
|
7
11
|
readonly translationGroup: string | null;
|
|
8
12
|
readonly frontmatter: Record<string, unknown>;
|
|
9
13
|
readonly tags: readonly string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hollware/nuxt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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.9.0",
|
|
33
|
+
"@hollware/core": "1.9.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@nuxt/kit": "4.6.3",
|