@backmatter/next 0.0.13 → 0.0.15
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/package.json +2 -2
- package/src/create-backmatter.ts +5 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backmatter/next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Experimental Next.js adapter for Backmatter. APIs will break. Not ready for production.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"test": "bun test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backmatter/core": "^0.0.
|
|
41
|
+
"@backmatter/core": "^0.0.14",
|
|
42
42
|
"@mdx-js/mdx": "^3.1.1",
|
|
43
43
|
"remark-gfm": "^4.0.1"
|
|
44
44
|
},
|
package/src/create-backmatter.ts
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
// packages/next/src/create-backmatter.ts
|
|
2
2
|
// Next hosts cache API fetches with tags so `content.committed` can
|
|
3
3
|
// `revalidateTag("backmatter")`. Core/CLI keep `cache: "no-store"`.
|
|
4
|
-
//
|
|
5
|
-
|
|
4
|
+
// `"use cache"` lives in generated `.backmatter/index.ts` so this client
|
|
5
|
+
// stays uncached — a second `"use cache"` here would hide the tagged layer
|
|
6
|
+
// from `revalidateTag`. Schema sync is opt-in (`sync: true` from `.backmatter/sync`).
|
|
7
|
+
import type { ModelDef } from "@backmatter/core";
|
|
6
8
|
import {
|
|
7
9
|
createBackmatter as createCore,
|
|
8
10
|
type CreateBackmatterOptions,
|
|
9
11
|
type BackmatterClient,
|
|
10
12
|
} from "@backmatter/core/node/create-backmatter";
|
|
11
|
-
import { getCachedDoc, getCachedDocs, registerCachedDocGet, registerCachedListDocs } from "./cached-doc";
|
|
12
13
|
|
|
13
14
|
export function createBackmatter<const Models extends readonly ModelDef[]>(
|
|
14
15
|
options: CreateBackmatterOptions<Models>,
|
|
15
16
|
): BackmatterClient<Models> {
|
|
16
|
-
|
|
17
|
-
registerCachedDocGet(core.getDoc);
|
|
18
|
-
registerCachedListDocs(core.listDocs);
|
|
19
|
-
const getDoc: BackmatterClient<Models>["getDoc"] = (locale, type, slug) =>
|
|
20
|
-
getCachedDoc(locale, type, slug);
|
|
21
|
-
const listDocs: BackmatterClient<Models>["listDocs"] = (filter) =>
|
|
22
|
-
getCachedDocs(filter?.type, filter?.locale);
|
|
23
|
-
return {
|
|
24
|
-
...core,
|
|
25
|
-
getDoc,
|
|
26
|
-
listDocs,
|
|
27
|
-
query: createQuery(options.models, { getDoc, listDocs }),
|
|
28
|
-
};
|
|
17
|
+
return createCore({ ...options, taggedApiFetch: true, sync: options.sync ?? false });
|
|
29
18
|
}
|