@scribe-atp/next 0.3.0 → 1.0.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/README.md +4 -4
- package/dist/index.cjs +10 -10
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Create a factory once and export its functions from your route files:
|
|
|
23
23
|
// lib/scribe.ts
|
|
24
24
|
import { createScribeSite } from "@scribe-atp/next";
|
|
25
25
|
|
|
26
|
-
export const scribe = createScribeSite("alice.bsky.social", "alice
|
|
26
|
+
export const scribe = createScribeSite("alice.bsky.social", "https://alice.bsky.social");
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### Group index route — `/blog/[groupSlug]`
|
|
@@ -98,7 +98,7 @@ import { fetchSite } from "@scribe-atp/core";
|
|
|
98
98
|
import type { Metadata } from "next";
|
|
99
99
|
|
|
100
100
|
export async function generateMetadata(): Promise<Metadata> {
|
|
101
|
-
const site = await fetchSite("alice.bsky.social", "alice
|
|
101
|
+
const site = await fetchSite("alice.bsky.social", "https://alice.bsky.social");
|
|
102
102
|
return {
|
|
103
103
|
title: `${site.title} | My Platform`,
|
|
104
104
|
// custom fields...
|
|
@@ -122,10 +122,10 @@ export const revalidate = 3600; // revalidate every hour
|
|
|
122
122
|
```ts
|
|
123
123
|
// pages/blog/[slug].tsx
|
|
124
124
|
import type { GetStaticPaths, GetStaticProps } from "next";
|
|
125
|
-
import { fetchSite, fetchArticle
|
|
125
|
+
import { fetchSite, fetchArticle } from "@scribe-atp/core";
|
|
126
126
|
|
|
127
127
|
export const getStaticPaths: GetStaticPaths = async () => {
|
|
128
|
-
const site = await fetchSite("alice.bsky.social",
|
|
128
|
+
const site = await fetchSite("alice.bsky.social", "https://alice.bsky.social");
|
|
129
129
|
const paths = site.groups.flatMap((group) =>
|
|
130
130
|
group.articles.map((article) => ({ params: { slug: article.url ?? "" } }))
|
|
131
131
|
);
|
package/dist/index.cjs
CHANGED
|
@@ -27,24 +27,24 @@ module.exports = __toCommonJS(index_exports);
|
|
|
27
27
|
|
|
28
28
|
// src/create-scribe-site.ts
|
|
29
29
|
var import_core = require("@scribe-atp/core");
|
|
30
|
-
function createScribeSite(author,
|
|
30
|
+
function createScribeSite(author, publicationUrl) {
|
|
31
31
|
return {
|
|
32
32
|
generateGroupParams: async () => {
|
|
33
|
-
const site = await (0, import_core.fetchSite)(author,
|
|
33
|
+
const site = await (0, import_core.fetchSite)(author, publicationUrl);
|
|
34
34
|
return site.groups.map((g) => ({ groupSlug: g.slug }));
|
|
35
35
|
},
|
|
36
36
|
generateArticleParams: async () => {
|
|
37
|
-
const site = await (0, import_core.fetchSite)(author,
|
|
37
|
+
const site = await (0, import_core.fetchSite)(author, publicationUrl);
|
|
38
38
|
return site.groups.flatMap((g) => g.articles).filter((a) => !!a.slug).map((a) => ({ articleSlug: a.slug }));
|
|
39
39
|
},
|
|
40
40
|
generateGroupArticleParams: async () => {
|
|
41
|
-
const site = await (0, import_core.fetchSite)(author,
|
|
41
|
+
const site = await (0, import_core.fetchSite)(author, publicationUrl);
|
|
42
42
|
return site.groups.flatMap(
|
|
43
43
|
(g) => g.articles.filter((a) => !!a.slug).map((a) => ({ groupSlug: g.slug, articleSlug: a.slug }))
|
|
44
44
|
);
|
|
45
45
|
},
|
|
46
46
|
generateSiteMetadata: async () => {
|
|
47
|
-
const site = await (0, import_core.fetchSite)(author,
|
|
47
|
+
const site = await (0, import_core.fetchSite)(author, publicationUrl);
|
|
48
48
|
return {
|
|
49
49
|
title: site.title,
|
|
50
50
|
description: site.description ?? void 0,
|
|
@@ -56,7 +56,7 @@ function createScribeSite(author, siteSlug) {
|
|
|
56
56
|
};
|
|
57
57
|
},
|
|
58
58
|
generateGroupMetadata: async (groupSlug) => {
|
|
59
|
-
const site = await (0, import_core.fetchSite)(author,
|
|
59
|
+
const site = await (0, import_core.fetchSite)(author, publicationUrl);
|
|
60
60
|
const group = site.groups.find((g) => g.slug === groupSlug);
|
|
61
61
|
const title = group ? `${group.title} \u2014 ${site.title}` : site.title;
|
|
62
62
|
return {
|
|
@@ -65,7 +65,7 @@ function createScribeSite(author, siteSlug) {
|
|
|
65
65
|
};
|
|
66
66
|
},
|
|
67
67
|
generateArticleMetadata: async (articleSlug) => {
|
|
68
|
-
const site = await (0, import_core.fetchSite)(author,
|
|
68
|
+
const site = await (0, import_core.fetchSite)(author, publicationUrl);
|
|
69
69
|
const article = site.groups.flatMap((g) => g.articles).find((a) => a.slug === articleSlug);
|
|
70
70
|
const title = article ? `${article.title} \u2014 ${site.title}` : site.title;
|
|
71
71
|
return {
|
|
@@ -78,12 +78,12 @@ function createScribeSite(author, siteSlug) {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
},
|
|
81
|
-
getDocumentUri: (articleSlug) => (0, import_core.
|
|
81
|
+
getDocumentUri: (articleSlug) => (0, import_core.fetchArticleBySlug)(author, publicationUrl, articleSlug).then(({ uri }) => uri)
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
function createWellKnownHandler(author,
|
|
84
|
+
function createWellKnownHandler(author, publicationUrl) {
|
|
85
85
|
return async (request) => {
|
|
86
|
-
const uri = await (0, import_core.resolvePublicationUri)(author,
|
|
86
|
+
const uri = await (0, import_core.resolvePublicationUri)(author, publicationUrl, request.signal);
|
|
87
87
|
return new Response(uri, { headers: { "Content-Type": "text/plain" } });
|
|
88
88
|
};
|
|
89
89
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Metadata } from 'next';
|
|
2
2
|
export { Article, ArticleRef, Site, SiteGroup } from '@scribe-atp/core';
|
|
3
3
|
|
|
4
|
-
declare function createScribeSite(author: string,
|
|
4
|
+
declare function createScribeSite(author: string, publicationUrl: string): {
|
|
5
5
|
generateGroupParams: () => Promise<{
|
|
6
6
|
groupSlug: string;
|
|
7
7
|
}[]>;
|
|
@@ -17,6 +17,6 @@ declare function createScribeSite(author: string, siteSlug: string): {
|
|
|
17
17
|
generateArticleMetadata: (articleSlug: string) => Promise<Metadata>;
|
|
18
18
|
getDocumentUri: (articleSlug: string) => Promise<string>;
|
|
19
19
|
};
|
|
20
|
-
declare function createWellKnownHandler(author: string,
|
|
20
|
+
declare function createWellKnownHandler(author: string, publicationUrl: string): (request: Request) => Promise<Response>;
|
|
21
21
|
|
|
22
22
|
export { createScribeSite, createWellKnownHandler };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Metadata } from 'next';
|
|
2
2
|
export { Article, ArticleRef, Site, SiteGroup } from '@scribe-atp/core';
|
|
3
3
|
|
|
4
|
-
declare function createScribeSite(author: string,
|
|
4
|
+
declare function createScribeSite(author: string, publicationUrl: string): {
|
|
5
5
|
generateGroupParams: () => Promise<{
|
|
6
6
|
groupSlug: string;
|
|
7
7
|
}[]>;
|
|
@@ -17,6 +17,6 @@ declare function createScribeSite(author: string, siteSlug: string): {
|
|
|
17
17
|
generateArticleMetadata: (articleSlug: string) => Promise<Metadata>;
|
|
18
18
|
getDocumentUri: (articleSlug: string) => Promise<string>;
|
|
19
19
|
};
|
|
20
|
-
declare function createWellKnownHandler(author: string,
|
|
20
|
+
declare function createWellKnownHandler(author: string, publicationUrl: string): (request: Request) => Promise<Response>;
|
|
21
21
|
|
|
22
22
|
export { createScribeSite, createWellKnownHandler };
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
// src/create-scribe-site.ts
|
|
2
|
-
import { fetchSite,
|
|
3
|
-
function createScribeSite(author,
|
|
2
|
+
import { fetchSite, fetchArticleBySlug, resolvePublicationUri } from "@scribe-atp/core";
|
|
3
|
+
function createScribeSite(author, publicationUrl) {
|
|
4
4
|
return {
|
|
5
5
|
generateGroupParams: async () => {
|
|
6
|
-
const site = await fetchSite(author,
|
|
6
|
+
const site = await fetchSite(author, publicationUrl);
|
|
7
7
|
return site.groups.map((g) => ({ groupSlug: g.slug }));
|
|
8
8
|
},
|
|
9
9
|
generateArticleParams: async () => {
|
|
10
|
-
const site = await fetchSite(author,
|
|
10
|
+
const site = await fetchSite(author, publicationUrl);
|
|
11
11
|
return site.groups.flatMap((g) => g.articles).filter((a) => !!a.slug).map((a) => ({ articleSlug: a.slug }));
|
|
12
12
|
},
|
|
13
13
|
generateGroupArticleParams: async () => {
|
|
14
|
-
const site = await fetchSite(author,
|
|
14
|
+
const site = await fetchSite(author, publicationUrl);
|
|
15
15
|
return site.groups.flatMap(
|
|
16
16
|
(g) => g.articles.filter((a) => !!a.slug).map((a) => ({ groupSlug: g.slug, articleSlug: a.slug }))
|
|
17
17
|
);
|
|
18
18
|
},
|
|
19
19
|
generateSiteMetadata: async () => {
|
|
20
|
-
const site = await fetchSite(author,
|
|
20
|
+
const site = await fetchSite(author, publicationUrl);
|
|
21
21
|
return {
|
|
22
22
|
title: site.title,
|
|
23
23
|
description: site.description ?? void 0,
|
|
@@ -29,7 +29,7 @@ function createScribeSite(author, siteSlug) {
|
|
|
29
29
|
};
|
|
30
30
|
},
|
|
31
31
|
generateGroupMetadata: async (groupSlug) => {
|
|
32
|
-
const site = await fetchSite(author,
|
|
32
|
+
const site = await fetchSite(author, publicationUrl);
|
|
33
33
|
const group = site.groups.find((g) => g.slug === groupSlug);
|
|
34
34
|
const title = group ? `${group.title} \u2014 ${site.title}` : site.title;
|
|
35
35
|
return {
|
|
@@ -38,7 +38,7 @@ function createScribeSite(author, siteSlug) {
|
|
|
38
38
|
};
|
|
39
39
|
},
|
|
40
40
|
generateArticleMetadata: async (articleSlug) => {
|
|
41
|
-
const site = await fetchSite(author,
|
|
41
|
+
const site = await fetchSite(author, publicationUrl);
|
|
42
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 {
|
|
@@ -51,12 +51,12 @@ function createScribeSite(author, siteSlug) {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
},
|
|
54
|
-
getDocumentUri: (articleSlug) =>
|
|
54
|
+
getDocumentUri: (articleSlug) => fetchArticleBySlug(author, publicationUrl, articleSlug).then(({ uri }) => uri)
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
function createWellKnownHandler(author,
|
|
57
|
+
function createWellKnownHandler(author, publicationUrl) {
|
|
58
58
|
return async (request) => {
|
|
59
|
-
const uri = await resolvePublicationUri(author,
|
|
59
|
+
const uri = await resolvePublicationUri(author, publicationUrl, request.signal);
|
|
60
60
|
return new Response(uri, { headers: { "Content-Type": "text/plain" } });
|
|
61
61
|
};
|
|
62
62
|
}
|