@lupinum/ginko-content 0.3.0 → 0.3.1
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/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/storage/graph.d.ts +1 -0
- package/dist/storage/graph.js +1 -0
- package/dist/storage/references.js +18 -3
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
package/dist/storage/graph.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const getContentGraph: (event: H3Event) => Promise<ContentGraph>;
|
|
|
19
19
|
export declare function resolveVariant(event: H3Event, canonicalKey: string, requestedLocale?: string, options?: {
|
|
20
20
|
fallback?: string[];
|
|
21
21
|
exact?: boolean;
|
|
22
|
+
collection?: string;
|
|
22
23
|
}): Promise<import("../types/runtime").ResolvedVariant | null>;
|
|
23
24
|
export declare function resolveRouteVariant(event: H3Event, routePath: string, requestedLocale?: string, options?: {
|
|
24
25
|
fallback?: string[];
|
package/dist/storage/graph.js
CHANGED
|
@@ -17,6 +17,19 @@ const isConfiguredQuickLink = (href) => {
|
|
|
17
17
|
const links = contentConfig().links;
|
|
18
18
|
return Boolean(links?.[namespace]?.[key]);
|
|
19
19
|
};
|
|
20
|
+
const resolveReferenceTarget = async (event, identity, collections) => {
|
|
21
|
+
const canonicalKey = await resolveCanonicalKey(event, identity);
|
|
22
|
+
if (canonicalKey) {
|
|
23
|
+
return { canonicalKey };
|
|
24
|
+
}
|
|
25
|
+
const scopedMatches = (await Promise.all(
|
|
26
|
+
Object.keys(collections).map(async (collection) => {
|
|
27
|
+
const scopedCanonicalKey = await resolveCanonicalKey(event, identity, collection);
|
|
28
|
+
return scopedCanonicalKey ? { canonicalKey: scopedCanonicalKey, collection } : null;
|
|
29
|
+
})
|
|
30
|
+
)).filter((match) => Boolean(match));
|
|
31
|
+
return scopedMatches.length === 1 ? scopedMatches[0] : null;
|
|
32
|
+
};
|
|
20
33
|
const resolveDocumentRefLinks = async (event, content, requestedLocale) => {
|
|
21
34
|
if (!content || content.type !== "markdown" || !content.body) {
|
|
22
35
|
return void 0;
|
|
@@ -33,8 +46,8 @@ const resolveDocumentRefLinks = async (event, content, requestedLocale) => {
|
|
|
33
46
|
if (!parsed) {
|
|
34
47
|
return null;
|
|
35
48
|
}
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
49
|
+
const target = await resolveReferenceTarget(event, parsed.ref, config.collections || {});
|
|
50
|
+
if (!target) {
|
|
38
51
|
if (isConfiguredQuickLink(href)) {
|
|
39
52
|
return [href, href];
|
|
40
53
|
}
|
|
@@ -45,7 +58,9 @@ const resolveDocumentRefLinks = async (event, content, requestedLocale) => {
|
|
|
45
58
|
}
|
|
46
59
|
return [href, href];
|
|
47
60
|
}
|
|
48
|
-
const variant = await resolveVariant(event, canonicalKey, requestedLocale
|
|
61
|
+
const variant = await resolveVariant(event, target.canonicalKey, requestedLocale, {
|
|
62
|
+
collection: target.collection
|
|
63
|
+
});
|
|
49
64
|
if (!variant?.path) {
|
|
50
65
|
if (import.meta.dev) {
|
|
51
66
|
console.warn(
|
package/dist/web-types.json
CHANGED