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

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/index.d.ts CHANGED
@@ -1,16 +1,35 @@
1
- import { FieldHintData, ArtifactStore, Artifact } from '@nubbin/core';
1
+ import { Artifact, FieldHintData, ArtifactStore } from '@nubbin/core';
2
+ import { Metadata } from 'next';
3
+
4
+ /**
5
+ * Maps a compiled artifact's `meta` onto Next's `Metadata`, so the mapping is owned by the
6
+ * binding rather than re-decided in every consumer's `generateMetadata` — the same reason
7
+ * `holeFetchOptions` owns the hole-lifecycle mapping.
8
+ *
9
+ * `compile` has written `meta` into every artifact since the first one, and until this existed
10
+ * nothing read it: a published page could not set its own title. The shapes differ in one place
11
+ * — a document's `canonical` is a flat field, and Next reads a canonical URL from
12
+ * `alternates.canonical` — so that is the only thing this translates rather than copies.
13
+ *
14
+ * A null artifact returns an empty object rather than a title, because the caller is about to
15
+ * render a 404 and the layout's own metadata is the right answer for it.
16
+ *
17
+ * Optional fields are assigned only when present. `exactOptionalPropertyTypes` is on, and a
18
+ * `description: undefined` sent to Next is an instruction to emit an empty tag rather than an
19
+ * absence.
20
+ */
21
+ declare function artifactMetadata(artifact: Artifact | null): Metadata;
2
22
 
3
23
  /**
4
24
  * Maps a hole's declared lifecycle onto Next's fetch cache, so the mapping is owned by the
5
- * binding rather than re-decided in every consumer's resolver. `no-store` also makes a page
6
- * carrying a request hole dynamic — per-request resolution is exactly what it declared.
25
+ * binding rather than re-decided in every consumer's resolver.
7
26
  *
8
27
  * Takes core's `FieldHintData` directly. An earlier plan derived a local `HoleSpec` from
9
28
  * `ArtifactNode["holes"]` so two packages would not import each other; core exports the type
10
29
  * by name, so both import it from core and neither derivation is needed.
11
30
  */
12
31
  declare function holeFetchOptions(spec: FieldHintData): RequestInit & {
13
- next?: {
32
+ next: {
14
33
  revalidate: number;
15
34
  };
16
35
  };
@@ -43,4 +62,4 @@ declare function staticRouteParams(store: ArtifactStore): Promise<{
43
62
  /** Pointer removed, then that one route invalidated — the next request renders a real 404. */
44
63
  declare function unpublishRoute(store: ArtifactStore, route: string): Promise<void>;
45
64
 
46
- export { holeFetchOptions, publishRoute, resolveArtifact, routeFromSlug, staticRouteParams, unpublishRoute };
65
+ export { artifactMetadata, holeFetchOptions, publishRoute, resolveArtifact, routeFromSlug, staticRouteParams, unpublishRoute };
package/dist/index.js CHANGED
@@ -1,8 +1,18 @@
1
+ // src/artifactMetadata.ts
2
+ function artifactMetadata(artifact) {
3
+ if (artifact === null) {
4
+ return {};
5
+ }
6
+ const { title, description, robots, canonical } = artifact.meta;
7
+ const metadata = { title };
8
+ if (description !== void 0) metadata.description = description;
9
+ if (robots !== void 0) metadata.robots = robots;
10
+ if (canonical !== void 0) metadata.alternates = { canonical };
11
+ return metadata;
12
+ }
13
+
1
14
  // src/holeFetchOptions.ts
2
15
  function holeFetchOptions(spec) {
3
- if (spec === "request") {
4
- return { cache: "no-store" };
5
- }
6
16
  return { next: { revalidate: spec.revalidate } };
7
17
  }
8
18
 
@@ -43,6 +53,7 @@ async function unpublishRoute(store, route) {
43
53
  revalidatePath2(route);
44
54
  }
45
55
  export {
56
+ artifactMetadata,
46
57
  holeFetchOptions,
47
58
  publishRoute,
48
59
  resolveArtifact,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubbin/next",
3
- "version": "0.1.0-rc.5",
3
+ "version": "0.1.0-rc.7",
4
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
5
  "keywords": [
6
6
  "nubbin",
@@ -32,13 +32,13 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@nubbin/core": "0.1.0-rc.5"
35
+ "@nubbin/core": "0.1.0-rc.7"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "next": ">=16.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "next": "16.2.7",
41
+ "next": "16.2.11",
42
42
  "tsup": "8.5.1",
43
43
  "typescript": "6.0.3",
44
44
  "vitest": "4.1.10"