@anthusai/papyrus 1.0.0-next.14 → 1.0.0-next.16

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();
@@ -245,6 +245,7 @@ export class AmplifyAppShellStack extends Stack {
245
245
  platform: "WEB",
246
246
  iamServiceRole: readerServiceRole.roleArn,
247
247
  buildSpec: readerBuildSpec(config),
248
+ customRules: [{ source: "/<*>", target: "/404.html", status: "404-200" }],
248
249
  });
249
250
  const readerBranch = new amplify.CfnBranch(this, "ReaderBranch", {
250
251
  appId: readerApp.attrAppId,
@@ -293,6 +293,7 @@ export class AmplifyAppShellStack extends Stack {
293
293
  platform: "WEB",
294
294
  iamServiceRole: readerServiceRole.roleArn,
295
295
  buildSpec: readerBuildSpec(config),
296
+ customRules: [{ source: "/<*>", target: "/404.html", status: "404-200" }],
296
297
  });
297
298
 
298
299
  const readerBranch = new amplify.CfnBranch(this, "ReaderBranch", {
@@ -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.14",
280
+ "version": "1.0.0-next.16",
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.14",
2
+ "version": "1.0.0-next.16",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",