@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lupinum/ginko-content",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "configKey": "content",
5
5
  "compatibility": {
6
6
  "nuxt": ">=4.4.7 <5"
package/dist/module.mjs CHANGED
@@ -29,7 +29,7 @@ import { createRouterMatcher } from 'vue-router';
29
29
  import { globby } from 'globby';
30
30
 
31
31
  const name = "@lupinum/ginko-content";
32
- const version = "0.3.0";
32
+ const version = "0.3.1";
33
33
  const peerDependencies = {
34
34
  nuxt: ">=4.4.7 <5"};
35
35
 
@@ -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[];
@@ -40,6 +40,7 @@ export async function resolveVariant(event, canonicalKey, requestedLocale, optio
40
40
  locales: config.locales,
41
41
  fallback: options.fallback,
42
42
  exact: options.exact,
43
+ collection: options.collection,
43
44
  localeFallback: config.localeFallback
44
45
  });
45
46
  }
@@ -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 canonicalKey = await resolveCanonicalKey(event, parsed.ref);
37
- if (!canonicalKey) {
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(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "@lupinum/ginko-content",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lupinum/ginko-content",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Collection-first content engine for Nuxt",
5
5
  "homepage": "https://github.com/lupinum-dev/ginko-content",
6
6
  "bugs": {