@scribe-atp/next 0.1.0 → 0.3.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.cjs +17 -8
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +16 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
createScribeSite: () => createScribeSite
|
|
23
|
+
createScribeSite: () => createScribeSite,
|
|
24
|
+
createWellKnownHandler: () => createWellKnownHandler
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(index_exports);
|
|
26
27
|
|
|
@@ -34,12 +35,12 @@ function createScribeSite(author, siteSlug) {
|
|
|
34
35
|
},
|
|
35
36
|
generateArticleParams: async () => {
|
|
36
37
|
const site = await (0, import_core.fetchSite)(author, siteSlug);
|
|
37
|
-
return site.groups.flatMap((g) => g.articles).filter((a) => !!a.
|
|
38
|
+
return site.groups.flatMap((g) => g.articles).filter((a) => !!a.slug).map((a) => ({ articleSlug: a.slug }));
|
|
38
39
|
},
|
|
39
40
|
generateGroupArticleParams: async () => {
|
|
40
41
|
const site = await (0, import_core.fetchSite)(author, siteSlug);
|
|
41
42
|
return site.groups.flatMap(
|
|
42
|
-
(g) => g.articles.filter((a) => !!a.
|
|
43
|
+
(g) => g.articles.filter((a) => !!a.slug).map((a) => ({ groupSlug: g.slug, articleSlug: a.slug }))
|
|
43
44
|
);
|
|
44
45
|
},
|
|
45
46
|
generateSiteMetadata: async () => {
|
|
@@ -65,21 +66,29 @@ function createScribeSite(author, siteSlug) {
|
|
|
65
66
|
},
|
|
66
67
|
generateArticleMetadata: async (articleSlug) => {
|
|
67
68
|
const site = await (0, import_core.fetchSite)(author, siteSlug);
|
|
68
|
-
const article = site.groups.flatMap((g) => g.articles).find((a) => a.
|
|
69
|
+
const article = site.groups.flatMap((g) => g.articles).find((a) => a.slug === articleSlug);
|
|
69
70
|
const title = article ? `${article.title} \u2014 ${site.title}` : site.title;
|
|
70
71
|
return {
|
|
71
72
|
title,
|
|
72
|
-
description: article?.
|
|
73
|
+
description: article?.description ?? void 0,
|
|
73
74
|
openGraph: {
|
|
74
75
|
title,
|
|
75
|
-
description: article?.
|
|
76
|
+
description: article?.description ?? void 0,
|
|
76
77
|
...article?.splashImageUrl ? { images: [article.splashImageUrl] } : {}
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
|
-
}
|
|
80
|
+
},
|
|
81
|
+
getDocumentUri: (articleSlug) => (0, import_core.resolveDocumentUri)(author, articleSlug)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function createWellKnownHandler(author, siteSlug) {
|
|
85
|
+
return async (request) => {
|
|
86
|
+
const uri = await (0, import_core.resolvePublicationUri)(author, siteSlug, request.signal);
|
|
87
|
+
return new Response(uri, { headers: { "Content-Type": "text/plain" } });
|
|
80
88
|
};
|
|
81
89
|
}
|
|
82
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
91
|
0 && (module.exports = {
|
|
84
|
-
createScribeSite
|
|
92
|
+
createScribeSite,
|
|
93
|
+
createWellKnownHandler
|
|
85
94
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -15,6 +15,8 @@ declare function createScribeSite(author: string, siteSlug: string): {
|
|
|
15
15
|
generateSiteMetadata: () => Promise<Metadata>;
|
|
16
16
|
generateGroupMetadata: (groupSlug: string) => Promise<Metadata>;
|
|
17
17
|
generateArticleMetadata: (articleSlug: string) => Promise<Metadata>;
|
|
18
|
+
getDocumentUri: (articleSlug: string) => Promise<string>;
|
|
18
19
|
};
|
|
20
|
+
declare function createWellKnownHandler(author: string, siteSlug: string): (request: Request) => Promise<Response>;
|
|
19
21
|
|
|
20
|
-
export { createScribeSite };
|
|
22
|
+
export { createScribeSite, createWellKnownHandler };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ declare function createScribeSite(author: string, siteSlug: string): {
|
|
|
15
15
|
generateSiteMetadata: () => Promise<Metadata>;
|
|
16
16
|
generateGroupMetadata: (groupSlug: string) => Promise<Metadata>;
|
|
17
17
|
generateArticleMetadata: (articleSlug: string) => Promise<Metadata>;
|
|
18
|
+
getDocumentUri: (articleSlug: string) => Promise<string>;
|
|
18
19
|
};
|
|
20
|
+
declare function createWellKnownHandler(author: string, siteSlug: string): (request: Request) => Promise<Response>;
|
|
19
21
|
|
|
20
|
-
export { createScribeSite };
|
|
22
|
+
export { createScribeSite, createWellKnownHandler };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/create-scribe-site.ts
|
|
2
|
-
import { fetchSite } from "@scribe-atp/core";
|
|
2
|
+
import { fetchSite, resolveDocumentUri, resolvePublicationUri } from "@scribe-atp/core";
|
|
3
3
|
function createScribeSite(author, siteSlug) {
|
|
4
4
|
return {
|
|
5
5
|
generateGroupParams: async () => {
|
|
@@ -8,12 +8,12 @@ function createScribeSite(author, siteSlug) {
|
|
|
8
8
|
},
|
|
9
9
|
generateArticleParams: async () => {
|
|
10
10
|
const site = await fetchSite(author, siteSlug);
|
|
11
|
-
return site.groups.flatMap((g) => g.articles).filter((a) => !!a.
|
|
11
|
+
return site.groups.flatMap((g) => g.articles).filter((a) => !!a.slug).map((a) => ({ articleSlug: a.slug }));
|
|
12
12
|
},
|
|
13
13
|
generateGroupArticleParams: async () => {
|
|
14
14
|
const site = await fetchSite(author, siteSlug);
|
|
15
15
|
return site.groups.flatMap(
|
|
16
|
-
(g) => g.articles.filter((a) => !!a.
|
|
16
|
+
(g) => g.articles.filter((a) => !!a.slug).map((a) => ({ groupSlug: g.slug, articleSlug: a.slug }))
|
|
17
17
|
);
|
|
18
18
|
},
|
|
19
19
|
generateSiteMetadata: async () => {
|
|
@@ -39,20 +39,28 @@ function createScribeSite(author, siteSlug) {
|
|
|
39
39
|
},
|
|
40
40
|
generateArticleMetadata: async (articleSlug) => {
|
|
41
41
|
const site = await fetchSite(author, siteSlug);
|
|
42
|
-
const article = site.groups.flatMap((g) => g.articles).find((a) => a.
|
|
42
|
+
const article = site.groups.flatMap((g) => g.articles).find((a) => a.slug === articleSlug);
|
|
43
43
|
const title = article ? `${article.title} \u2014 ${site.title}` : site.title;
|
|
44
44
|
return {
|
|
45
45
|
title,
|
|
46
|
-
description: article?.
|
|
46
|
+
description: article?.description ?? void 0,
|
|
47
47
|
openGraph: {
|
|
48
48
|
title,
|
|
49
|
-
description: article?.
|
|
49
|
+
description: article?.description ?? void 0,
|
|
50
50
|
...article?.splashImageUrl ? { images: [article.splashImageUrl] } : {}
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
}
|
|
53
|
+
},
|
|
54
|
+
getDocumentUri: (articleSlug) => resolveDocumentUri(author, articleSlug)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function createWellKnownHandler(author, siteSlug) {
|
|
58
|
+
return async (request) => {
|
|
59
|
+
const uri = await resolvePublicationUri(author, siteSlug, request.signal);
|
|
60
|
+
return new Response(uri, { headers: { "Content-Type": "text/plain" } });
|
|
54
61
|
};
|
|
55
62
|
}
|
|
56
63
|
export {
|
|
57
|
-
createScribeSite
|
|
64
|
+
createScribeSite,
|
|
65
|
+
createWellKnownHandler
|
|
58
66
|
};
|