@anthusai/papyrus 1.0.0-next.15 → 1.0.0-next.17

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.
@@ -1,4 +1,5 @@
1
1
  import { notFound, redirect } from "next/navigation";
2
+ import { siteServesNextReaderRoutes } from "../../../../lib/reader-static-params";
2
3
  import { getSiteRenderer } from "../../../../lib/site-renderer";
3
4
  import type { PresentationTarget } from "../../../../renderers/pretext";
4
5
  import { loadCachedEditionContent } from "../../../../lib/cached-content-repository";
@@ -22,6 +23,7 @@ export async function EditionRoutePage({
22
23
  lockedPresentation,
23
24
  target = { kind: "edition" },
24
25
  }: EditionRoutePageProps) {
26
+ if (!siteServesNextReaderRoutes()) notFound();
25
27
  const route = parseEditionDateRoute({ year, month, day });
26
28
  if (!route) notFound();
27
29
  if (!route.isCanonical) redirect(route.canonicalPath);
@@ -1,7 +1,7 @@
1
1
  import { notFound } from "next/navigation";
2
2
  import { getSiteRenderer } from "../../../lib/site-renderer";
3
3
  import { getCachedArticle } from "../../../lib/cached-content-repository";
4
- import { generateArticleStaticParams } from "../../../lib/reader-static-params";
4
+ import { generateArticleStaticParams, siteServesNextReaderRoutes } from "../../../lib/reader-static-params";
5
5
  import { SITE_BRAND } from "../../../lib/site-brand";
6
6
 
7
7
  // Keep in sync with READER_REVALIDATE_SECONDS in lib/reader-route-config.ts
@@ -16,6 +16,7 @@ type ArticlePageProps = {
16
16
  };
17
17
 
18
18
  export async function generateMetadata({ params }: ArticlePageProps) {
19
+ if (!siteServesNextReaderRoutes()) return {};
19
20
  const { slug } = await params;
20
21
  const article = await getCachedArticle(slug);
21
22
  if (!article) return {};
@@ -26,6 +27,7 @@ export async function generateMetadata({ params }: ArticlePageProps) {
26
27
  }
27
28
 
28
29
  export default async function ArticlePage({ params }: ArticlePageProps) {
30
+ if (!siteServesNextReaderRoutes()) notFound();
29
31
  const { slug } = await params;
30
32
  const article = await getCachedArticle(slug);
31
33
  if (!article) notFound();
@@ -262,7 +262,10 @@ export class AmplifyAppShellStack extends Stack {
262
262
  const readerDomain = new amplify.CfnDomain(this, "ReaderDomain", {
263
263
  appId: readerApp.attrAppId,
264
264
  domainName: reader.domainName,
265
- subDomainSettings: [{ branchName: readerBranchName, prefix: "" }],
265
+ subDomainSettings: [
266
+ { branchName: readerBranchName, prefix: "" },
267
+ ...(reader.includeWww ? [{ branchName: readerBranchName, prefix: "www" }] : []),
268
+ ],
266
269
  });
267
270
  readerDomain.addResourceDependency(readerBranch);
268
271
  }
@@ -312,7 +312,10 @@ export class AmplifyAppShellStack extends Stack {
312
312
  const readerDomain = new amplify.CfnDomain(this, "ReaderDomain", {
313
313
  appId: readerApp.attrAppId,
314
314
  domainName: reader.domainName,
315
- subDomainSettings: [{ branchName: readerBranchName, prefix: "" }],
315
+ subDomainSettings: [
316
+ { branchName: readerBranchName, prefix: "" },
317
+ ...(reader.includeWww ? [{ branchName: readerBranchName, prefix: "www" }] : []),
318
+ ],
316
319
  });
317
320
  readerDomain.addResourceDependency(readerBranch);
318
321
  }
@@ -121,10 +121,17 @@ export function parseSiteConfig(raw) {
121
121
  if (frontend !== "markus-static")
122
122
  fail("reader", `is only allowed when frontend is "markus-static"`);
123
123
  const readerRecord = requireObject(record.reader, "reader");
124
- rejectUnknownKeys(readerRecord, ["appName", "domainName", "branchName", "buildCommand", "baseDirectory", "environment"], "reader");
124
+ rejectUnknownKeys(readerRecord, ["appName", "domainName", "includeWww", "branchName", "buildCommand", "baseDirectory", "environment"], "reader");
125
+ if (readerRecord.includeWww !== undefined && typeof readerRecord.includeWww !== "boolean") {
126
+ fail("reader.includeWww", `must be a boolean, got ${JSON.stringify(readerRecord.includeWww)}`);
127
+ }
128
+ if (readerRecord.includeWww !== undefined && readerRecord.domainName === undefined) {
129
+ fail("reader.includeWww", "requires reader.domainName");
130
+ }
125
131
  reader = {
126
132
  appName: optionalString(readerRecord.appName, "reader.appName", APP_NAME_PATTERN),
127
133
  domainName: optionalString(readerRecord.domainName, "reader.domainName", HOST_NAME_PATTERN, "host name"),
134
+ includeWww: readerRecord.includeWww,
128
135
  branchName: optionalString(readerRecord.branchName, "reader.branchName", BRANCH_NAME_PATTERN),
129
136
  buildCommand: requireString(readerRecord.buildCommand, "reader.buildCommand"),
130
137
  baseDirectory: requireString(readerRecord.baseDirectory, "reader.baseDirectory"),
@@ -17,6 +17,7 @@ export type AmplifyAppShellSiteConfig = {
17
17
  reader?: {
18
18
  appName?: string;
19
19
  domainName?: string;
20
+ includeWww?: boolean;
20
21
  branchName?: string;
21
22
  buildCommand: string;
22
23
  baseDirectory: string;
@@ -175,10 +176,17 @@ export function parseSiteConfig(raw: unknown): AmplifyAppShellSiteConfig {
175
176
  if (record.reader !== undefined) {
176
177
  if (frontend !== "markus-static") fail("reader", `is only allowed when frontend is "markus-static"`);
177
178
  const readerRecord = requireObject(record.reader, "reader");
178
- rejectUnknownKeys(readerRecord, ["appName", "domainName", "branchName", "buildCommand", "baseDirectory", "environment"], "reader");
179
+ rejectUnknownKeys(readerRecord, ["appName", "domainName", "includeWww", "branchName", "buildCommand", "baseDirectory", "environment"], "reader");
180
+ if (readerRecord.includeWww !== undefined && typeof readerRecord.includeWww !== "boolean") {
181
+ fail("reader.includeWww", `must be a boolean, got ${JSON.stringify(readerRecord.includeWww)}`);
182
+ }
183
+ if (readerRecord.includeWww !== undefined && readerRecord.domainName === undefined) {
184
+ fail("reader.includeWww", "requires reader.domainName");
185
+ }
179
186
  reader = {
180
187
  appName: optionalString(readerRecord.appName, "reader.appName", APP_NAME_PATTERN),
181
188
  domainName: optionalString(readerRecord.domainName, "reader.domainName", HOST_NAME_PATTERN, "host name"),
189
+ includeWww: readerRecord.includeWww as boolean | undefined,
182
190
  branchName: optionalString(readerRecord.branchName, "reader.branchName", BRANCH_NAME_PATTERN),
183
191
  buildCommand: requireString(readerRecord.buildCommand, "reader.buildCommand"),
184
192
  baseDirectory: requireString(readerRecord.baseDirectory, "reader.baseDirectory"),
@@ -1,4 +1,10 @@
1
1
  import { graphqlContentRepository } from "./graphql-content-repository";
2
+ import { SITE_BRAND } from "./site-brand";
3
+ import type { RendererConfig } from "./renderer-config";
4
+
5
+ export function siteServesNextReaderRoutes(rendererKind: RendererConfig["kind"] = SITE_BRAND.renderer.kind): boolean {
6
+ return rendererKind !== "markus";
7
+ }
2
8
 
3
9
  const MONTH_NAMES = [
4
10
  "january",
@@ -23,6 +29,7 @@ type EditionDateStaticParam = {
23
29
 
24
30
  export async function generateEditionDateStaticParams(): Promise<EditionDateStaticParam[]> {
25
31
  if (process.env.NODE_ENV === "development") return [];
32
+ if (!siteServesNextReaderRoutes()) return [];
26
33
 
27
34
  const { editions } = await graphqlContentRepository.listPublishedEditions({ limit: 100 });
28
35
  const params: EditionDateStaticParam[] = [];
@@ -35,6 +42,7 @@ export async function generateEditionDateStaticParams(): Promise<EditionDateStat
35
42
 
36
43
  export async function generateArticleStaticParams(): Promise<Array<{ slug: string }>> {
37
44
  if (process.env.NODE_ENV === "development") return [];
45
+ if (!siteServesNextReaderRoutes()) return [];
38
46
 
39
47
  const slugs = await graphqlContentRepository.listArticleSlugs();
40
48
  return slugs.map((slug) => ({ slug }));
package/package.json CHANGED
@@ -277,7 +277,7 @@
277
277
  "optional": true
278
278
  }
279
279
  },
280
- "version": "1.0.0-next.15",
280
+ "version": "1.0.0-next.17",
281
281
  "dependencies": {
282
282
  "@aws-amplify/adapter-nextjs": "^1.7.3",
283
283
  "@aws-sdk/client-cognito-identity-provider": "3.1045.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-next.15",
2
+ "version": "1.0.0-next.17",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",