@scribe-atp/next 1.0.0 → 1.1.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/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-bsky-social");
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-bsky-social");
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, toSlug } from "@scribe-atp/core";
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", toSlug("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
@@ -20,8 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ articleMetadata: () => articleMetadata,
23
24
  createScribeSite: () => createScribeSite,
24
- createWellKnownHandler: () => createWellKnownHandler
25
+ createWellKnownHandler: () => createWellKnownHandler,
26
+ siteMetadata: () => siteMetadata
25
27
  });
26
28
  module.exports = __toCommonJS(index_exports);
27
29
 
@@ -87,8 +89,55 @@ function createWellKnownHandler(author, publicationUrl) {
87
89
  return new Response(uri, { headers: { "Content-Type": "text/plain" } });
88
90
  };
89
91
  }
92
+
93
+ // src/meta.ts
94
+ var import_core2 = require("@scribe-atp/core");
95
+ function articleMetadata(article, site) {
96
+ const canonicalUrl = (0, import_core2.buildCanonicalUrl)(article, site);
97
+ return {
98
+ title: `${article.title} \u2014 ${site.title}`,
99
+ description: article.description ?? void 0,
100
+ openGraph: {
101
+ type: "article",
102
+ title: article.title,
103
+ description: article.description ?? void 0,
104
+ url: canonicalUrl,
105
+ siteName: site.title,
106
+ ...article.splashImageUrl ? { images: [article.splashImageUrl] } : {}
107
+ },
108
+ twitter: {
109
+ card: article.splashImageUrl ? "summary_large_image" : "summary",
110
+ title: article.title,
111
+ description: article.description ?? void 0,
112
+ ...article.splashImageUrl ? { images: [article.splashImageUrl] } : {}
113
+ }
114
+ };
115
+ }
116
+ function siteMetadata(site) {
117
+ const siteUrl = `https://${site.url}${site.urlPrefix ? `/${site.urlPrefix}` : ""}`;
118
+ return {
119
+ title: site.title,
120
+ description: site.description ?? void 0,
121
+ openGraph: {
122
+ type: "website",
123
+ title: site.title,
124
+ description: site.description ?? void 0,
125
+ url: siteUrl,
126
+ siteName: site.title,
127
+ ...site.splashImageUrl ? { images: [site.splashImageUrl] } : {}
128
+ },
129
+ twitter: {
130
+ card: site.splashImageUrl ? "summary_large_image" : "summary",
131
+ title: site.title,
132
+ description: site.description ?? void 0,
133
+ ...site.splashImageUrl ? { images: [site.splashImageUrl] } : {}
134
+ }
135
+ };
136
+ }
90
137
  // Annotate the CommonJS export names for ESM import in node:
91
138
  0 && (module.exports = {
139
+ articleMetadata,
92
140
  createScribeSite,
93
- createWellKnownHandler
141
+ createWellKnownHandler,
142
+ siteMetadata
94
143
  });
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Metadata } from 'next';
2
+ import { Article, Site } from '@scribe-atp/core';
2
3
  export { Article, ArticleRef, Site, SiteGroup } from '@scribe-atp/core';
3
4
 
4
5
  declare function createScribeSite(author: string, publicationUrl: string): {
@@ -19,4 +20,7 @@ declare function createScribeSite(author: string, publicationUrl: string): {
19
20
  };
20
21
  declare function createWellKnownHandler(author: string, publicationUrl: string): (request: Request) => Promise<Response>;
21
22
 
22
- export { createScribeSite, createWellKnownHandler };
23
+ declare function articleMetadata(article: Article, site: Site): Metadata;
24
+ declare function siteMetadata(site: Site): Metadata;
25
+
26
+ export { articleMetadata, createScribeSite, createWellKnownHandler, siteMetadata };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Metadata } from 'next';
2
+ import { Article, Site } from '@scribe-atp/core';
2
3
  export { Article, ArticleRef, Site, SiteGroup } from '@scribe-atp/core';
3
4
 
4
5
  declare function createScribeSite(author: string, publicationUrl: string): {
@@ -19,4 +20,7 @@ declare function createScribeSite(author: string, publicationUrl: string): {
19
20
  };
20
21
  declare function createWellKnownHandler(author: string, publicationUrl: string): (request: Request) => Promise<Response>;
21
22
 
22
- export { createScribeSite, createWellKnownHandler };
23
+ declare function articleMetadata(article: Article, site: Site): Metadata;
24
+ declare function siteMetadata(site: Site): Metadata;
25
+
26
+ export { articleMetadata, createScribeSite, createWellKnownHandler, siteMetadata };
package/dist/index.js CHANGED
@@ -60,7 +60,54 @@ function createWellKnownHandler(author, publicationUrl) {
60
60
  return new Response(uri, { headers: { "Content-Type": "text/plain" } });
61
61
  };
62
62
  }
63
+
64
+ // src/meta.ts
65
+ import { buildCanonicalUrl } from "@scribe-atp/core";
66
+ function articleMetadata(article, site) {
67
+ const canonicalUrl = buildCanonicalUrl(article, site);
68
+ return {
69
+ title: `${article.title} \u2014 ${site.title}`,
70
+ description: article.description ?? void 0,
71
+ openGraph: {
72
+ type: "article",
73
+ title: article.title,
74
+ description: article.description ?? void 0,
75
+ url: canonicalUrl,
76
+ siteName: site.title,
77
+ ...article.splashImageUrl ? { images: [article.splashImageUrl] } : {}
78
+ },
79
+ twitter: {
80
+ card: article.splashImageUrl ? "summary_large_image" : "summary",
81
+ title: article.title,
82
+ description: article.description ?? void 0,
83
+ ...article.splashImageUrl ? { images: [article.splashImageUrl] } : {}
84
+ }
85
+ };
86
+ }
87
+ function siteMetadata(site) {
88
+ const siteUrl = `https://${site.url}${site.urlPrefix ? `/${site.urlPrefix}` : ""}`;
89
+ return {
90
+ title: site.title,
91
+ description: site.description ?? void 0,
92
+ openGraph: {
93
+ type: "website",
94
+ title: site.title,
95
+ description: site.description ?? void 0,
96
+ url: siteUrl,
97
+ siteName: site.title,
98
+ ...site.splashImageUrl ? { images: [site.splashImageUrl] } : {}
99
+ },
100
+ twitter: {
101
+ card: site.splashImageUrl ? "summary_large_image" : "summary",
102
+ title: site.title,
103
+ description: site.description ?? void 0,
104
+ ...site.splashImageUrl ? { images: [site.splashImageUrl] } : {}
105
+ }
106
+ };
107
+ }
63
108
  export {
109
+ articleMetadata,
64
110
  createScribeSite,
65
- createWellKnownHandler
111
+ createWellKnownHandler,
112
+ siteMetadata
66
113
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scribe-atp/next",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Next.js App Router adapter for reading Scribe CMS content from the AT Protocol.",
5
5
  "license": "MIT",
6
6
  "engines": {