@backmatter/next 0.0.60 → 0.0.61

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/config.cjs CHANGED
@@ -464,16 +464,19 @@ function renderCachedCmsClient(typeArgs) {
464
464
  return [
465
465
  "const raw = createBackmatter({ ...config, models, sync: false });",
466
466
  "",
467
+ "// Next types cacheLife against this host's profile names; the config may name any of them.",
468
+ "const contentCacheLife = cacheLife as (profile: CacheLifeProfile) => void;",
469
+ "",
467
470
  "async function cachedGetDoc(type: string, slug: string) {",
468
471
  ' "use cache";',
469
- " cacheLife(cacheLifeProfile(config));",
472
+ " contentCacheLife(cacheLifeProfile(config));",
470
473
  " cacheTag(...contentCacheTags(type, slug));",
471
474
  " return raw.getDoc(type, slug);",
472
475
  "}",
473
476
  "",
474
477
  "async function cachedListDocs(filter?: { type?: string }) {",
475
478
  ' "use cache";',
476
- " cacheLife(cacheLifeProfile(config));",
479
+ " contentCacheLife(cacheLifeProfile(config));",
477
480
  " cacheTag(...listCacheTags(filter?.type));",
478
481
  " return raw.listDocs(filter);",
479
482
  "}",
@@ -505,7 +508,7 @@ function renderModelsBarrel(input) {
505
508
  const typeArgs = blocks.length > 0 ? "<typeof models, Blocks>" : "";
506
509
  const lines = [GENERATED_HEADER, `import { createBackmatter } from "${input.sdk}";`];
507
510
  if (nextHost) {
508
- lines.push('import { cacheLifeProfile, contentCacheTags, createQuery, listCacheTags } from "@backmatter/core";');
511
+ lines.push('import { cacheLifeProfile, contentCacheTags, createQuery, listCacheTags, type CacheLifeProfile } from "@backmatter/core";');
509
512
  lines.push('import { currentPreviewContent } from "@backmatter/next/preview-content";');
510
513
  lines.push('import { cacheLife, cacheTag } from "next/cache";');
511
514
  }
package/dist/loader.cjs CHANGED
@@ -457,16 +457,19 @@ function renderCachedCmsClient(typeArgs) {
457
457
  return [
458
458
  "const raw = createBackmatter({ ...config, models, sync: false });",
459
459
  "",
460
+ "// Next types cacheLife against this host's profile names; the config may name any of them.",
461
+ "const contentCacheLife = cacheLife as (profile: CacheLifeProfile) => void;",
462
+ "",
460
463
  "async function cachedGetDoc(type: string, slug: string) {",
461
464
  ' "use cache";',
462
- " cacheLife(cacheLifeProfile(config));",
465
+ " contentCacheLife(cacheLifeProfile(config));",
463
466
  " cacheTag(...contentCacheTags(type, slug));",
464
467
  " return raw.getDoc(type, slug);",
465
468
  "}",
466
469
  "",
467
470
  "async function cachedListDocs(filter?: { type?: string }) {",
468
471
  ' "use cache";',
469
- " cacheLife(cacheLifeProfile(config));",
472
+ " contentCacheLife(cacheLifeProfile(config));",
470
473
  " cacheTag(...listCacheTags(filter?.type));",
471
474
  " return raw.listDocs(filter);",
472
475
  "}",
@@ -498,7 +501,7 @@ function renderModelsBarrel(input) {
498
501
  const typeArgs = blocks.length > 0 ? "<typeof models, Blocks>" : "";
499
502
  const lines = [GENERATED_HEADER, `import { createBackmatter } from "${input.sdk}";`];
500
503
  if (nextHost) {
501
- lines.push('import { cacheLifeProfile, contentCacheTags, createQuery, listCacheTags } from "@backmatter/core";');
504
+ lines.push('import { cacheLifeProfile, contentCacheTags, createQuery, listCacheTags, type CacheLifeProfile } from "@backmatter/core";');
502
505
  lines.push('import { currentPreviewContent } from "@backmatter/next/preview-content";');
503
506
  lines.push('import { cacheLife, cacheTag } from "next/cache";');
504
507
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backmatter/next",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "description": "Experimental Next.js adapter for Backmatter. APIs will break. Not ready for production.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -47,10 +47,10 @@
47
47
  "test": "bun test"
48
48
  },
49
49
  "dependencies": {
50
- "@backmatter/core": "^0.0.47",
50
+ "@backmatter/core": "^0.0.48",
51
51
  "@mdx-js/mdx": "^3.1.1",
52
52
  "remark-gfm": "^4.0.1",
53
- "@backmatter/studio": "^0.0.37"
53
+ "@backmatter/studio": "^0.0.38"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "next": ">=16.3.0",
@@ -58,9 +58,10 @@ export function PreviewBody({
58
58
  }) {
59
59
  const [body, setBody] = useState<string | null>(null);
60
60
  const [, setFrontmatter] = useState(doc.frontmatter);
61
+ const { type, slug } = doc;
61
62
 
62
63
  useEffect(() => {
63
- const source = new EventSource(streamUrl(doc));
64
+ const source = new EventSource(streamUrl({ type, slug }));
64
65
  const onMessage = (ev: MessageEvent) => {
65
66
  try {
66
67
  const data = JSON.parse(String(ev.data)) as PreviewChangeEvent;
@@ -75,7 +76,7 @@ export function PreviewBody({
75
76
  source.removeEventListener("change", onMessage as EventListener);
76
77
  source.close();
77
78
  };
78
- }, [doc.type, doc.slug]);
79
+ }, [type, slug]);
79
80
 
80
81
  if (body === null) return children ?? <MdxBody source={doc.body} components={components} />;
81
82
  return <MdxBody source={body} components={components} />;
@@ -33,9 +33,11 @@ export function subscribeSiteDoc(listener: (doc: SiteDocRef) => void): () => voi
33
33
 
34
34
  /** Rendered by the CMS page so the bar hears the document for the current route. */
35
35
  export function SiteDocBridge({ doc }: { doc: SiteDocRef }) {
36
+ // Each server render passes a new object; only the fields name the document.
37
+ const { type, slug, workspaceId } = doc;
36
38
  useEffect(() => {
37
- publishSiteDoc(doc);
38
- }, [doc.type, doc.slug, doc.workspaceId]);
39
+ publishSiteDoc({ type, slug, workspaceId });
40
+ }, [type, slug, workspaceId]);
39
41
 
40
42
  return (
41
43
  <span