@nubbin/next 0.1.0-rc.0 → 0.1.0-rc.5

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.
Files changed (3) hide show
  1. package/README.md +30 -0
  2. package/dist/index.js +2 -2
  3. package/package.json +18 -2
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @nubbin/next
2
+
3
+ The Next.js binding for Nubbin. Reading a page is one pointer read and one artifact read;
4
+ publishing is a pointer move and a single-route invalidation. Neither is a deploy.
5
+
6
+ ```bash
7
+ npm install @nubbin/next@rc
8
+ ```
9
+
10
+ ```ts
11
+ import { resolveArtifact, staticRouteParams, publishRoute } from "@nubbin/next";
12
+
13
+ export const generateStaticParams = () => staticRouteParams(store);
14
+
15
+ export default async function Page({ params }) {
16
+ const artifact = await resolveArtifact(store, (await params).slug);
17
+ if (!artifact) notFound(); // an unpublished route has no pointer
18
+ // …render it
19
+ }
20
+
21
+ await publishRoute(store, "/promotions/summer", hash); // pointer, then revalidatePath
22
+ ```
23
+
24
+ `publishRoute` moves the pointer *before* invalidating. The other order re-caches the outgoing
25
+ page in the gap, and the publish appears to have silently not happened. A store rejection
26
+ propagates without invalidating, so a failed publish never purges a working page.
27
+
28
+ **Release candidate.** Requires Next 16 or newer.
29
+
30
+ <https://effekt.github.io/nubbin/>. MIT.
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ function holeFetchOptions(spec) {
7
7
  }
8
8
 
9
9
  // src/publishRoute.ts
10
- import { revalidatePath } from "next/cache";
10
+ import { revalidatePath } from "next/cache.js";
11
11
  async function publishRoute(store, route, hash) {
12
12
  await store.publish(route, hash);
13
13
  revalidatePath(route);
@@ -37,7 +37,7 @@ async function staticRouteParams(store) {
37
37
  }
38
38
 
39
39
  // src/unpublishRoute.ts
40
- import { revalidatePath as revalidatePath2 } from "next/cache";
40
+ import { revalidatePath as revalidatePath2 } from "next/cache.js";
41
41
  async function unpublishRoute(store, route) {
42
42
  await store.unpublish(route);
43
43
  revalidatePath2(route);
package/package.json CHANGED
@@ -1,6 +1,22 @@
1
1
  {
2
2
  "name": "@nubbin/next",
3
- "version": "0.1.0-rc.0",
3
+ "version": "0.1.0-rc.5",
4
+ "description": "The Next.js binding for Nubbin: resolve a published artifact for a route, prebuild the ones that exist, and publish or unpublish a single route.",
5
+ "keywords": [
6
+ "nubbin",
7
+ "nextjs",
8
+ "page-builder",
9
+ "cms",
10
+ "isr"
11
+ ],
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/effekt/nubbin.git",
16
+ "directory": "packages/next"
17
+ },
18
+ "homepage": "https://effekt.github.io/nubbin/",
19
+ "bugs": "https://github.com/effekt/nubbin/issues",
4
20
  "type": "module",
5
21
  "sideEffects": false,
6
22
  "exports": {
@@ -16,7 +32,7 @@
16
32
  "access": "public"
17
33
  },
18
34
  "dependencies": {
19
- "@nubbin/core": "0.1.0-rc.0"
35
+ "@nubbin/core": "0.1.0-rc.5"
20
36
  },
21
37
  "peerDependencies": {
22
38
  "next": ">=16.0.0"