@djangocfg/nextjs 2.1.537 → 2.1.539

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 (2) hide show
  1. package/README.md +22 -24
  2. package/package.json +9 -9
package/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
 
24
24
  ## Features
25
25
 
26
- - **Page Metadata + OG Images** — one factory for complete page metadata; static or dynamically-rendered OG images via Django's `django_ogimage` (`@djangocfg/nextjs/og-image`)
26
+ - **Page Metadata + OG Images** — one factory for complete page metadata: titles, canonical + hreflang, OpenGraph, Twitter, icons (`@djangocfg/nextjs/og-image`)
27
27
  - **i18n** — full next-intl integration with routing, middleware, and components
28
28
  - **PWA** — zero-config service worker and manifest
29
29
  - **Base Next.js Config** — reusable `createBaseNextConfig()` factory for monorepos
@@ -391,8 +391,7 @@ export const GET = createHealthHandler({
391
391
 
392
392
  One factory per app builds complete page `Metadata` (title, openGraph, twitter,
393
393
  canonical + hreflang, icons). The OG image is chosen by a single `og` field —
394
- static brand image by default, dynamic title-rendered card on demand. No Edge
395
- Runtime, no `@vercel/og`:
394
+ the static brand image by default, or an exact URL:
396
395
 
397
396
  ```tsx
398
397
  // app/_core/metadata.ts — bind once
@@ -407,11 +406,13 @@ export const createMetadata = makeMetadataFactory({
407
406
 
408
407
  // landing page → static brand image (default)
409
408
  export const metadata = createMetadata({ title: 'Pricing', path: '/pricing' })
410
- // content page → render the title onto the card
411
- export const metadata = createMetadata({ title: post.title, path, og: 'dynamic' })
409
+ // content page with its own image
410
+ export const metadata = createMetadata({ title: p.name, path, og: { image: p.image } })
412
411
  ```
413
412
 
414
- The dynamic URL is resolved automatically from `NEXT_PUBLIC_MEDIA_URL` → `NEXT_PUBLIC_API_URL` → `NEXT_PUBLIC_SITE_URL`. Django renders and caches the PNG — no Edge Runtime or `@vercel/og` required.
413
+ For a card rendered per page, add an `opengraph-image` route — Next.js finds it
414
+ by filename and its output overrides whatever the factory set, so the factory
415
+ has no "dynamic" case of its own.
415
416
 
416
417
  ### Navigation Utilities
417
418
 
@@ -461,7 +462,7 @@ import { RedirectPage } from '@djangocfg/layouts/components/RedirectPage';
461
462
  | `@djangocfg/nextjs/pwa/worker` | Service worker creation helpers |
462
463
  | `@djangocfg/nextjs/sitemap` | Sitemap generation with i18n hreflang support |
463
464
  | `@djangocfg/nextjs/health` | Health check handlers |
464
- | `@djangocfg/nextjs/og-image` | Page metadata factory + static/dynamic OG images for Django's `django_ogimage` |
465
+ | `@djangocfg/nextjs/og-image` | Page metadata factory — titles, canonical + hreflang, OpenGraph, Twitter, icons |
465
466
  | `@djangocfg/nextjs/navigation` | Route definitions, menu generation, navigation helpers |
466
467
 
467
468
  ## API Reference
@@ -623,17 +624,16 @@ createHealthHandler({
623
624
 
624
625
  ### Page Metadata + OG Image
625
626
 
626
- `@djangocfg/nextjs/og-image` builds complete page metadata and OG images for
627
- Django's `django_ogimage` renderer. No Edge Runtime, no `@vercel/og`, no JSX
628
- templates — Django renders and caches the PNG.
627
+ `@djangocfg/nextjs/og-image` builds complete page metadata: title templating,
628
+ canonical + hreflang alternates, OpenGraph, Twitter cards and icons.
629
629
 
630
630
  See [`src/og-image/README.md`](./src/og-image/README.md) for full docs (the `og`
631
- axis, `SiteMetaConfig`/`PageMeta` fields, URL resolution, deployment examples).
631
+ axis, `SiteMetaConfig`/`PageMeta` fields).
632
632
 
633
633
  #### `makeMetadataFactory(config)` — recommended
634
634
 
635
635
  Binds a `SiteMetaConfig` once; returns a per-page factory. The OG image is set by
636
- the single `og` field: `'static'` (default) · `'dynamic'` · `{ render }` · `{ image, alt? }`.
636
+ the single `og` field: `'static'` (default) · `{ image, alt? }`.
637
637
 
638
638
  ```tsx
639
639
  import { makeMetadataFactory } from '@djangocfg/nextjs/og-image'
@@ -643,23 +643,21 @@ export const createMetadata = makeMetadataFactory({
643
643
  ogImage: '/static/ogimage.png', locales: LOCALES,
644
644
  })
645
645
 
646
- export const metadata = createMetadata({ title: 'About', path: '/about' }) // static
647
- export const metadata = createMetadata({ title: post.title, path, og: 'dynamic' }) // rendered title
646
+ export const metadata = createMetadata({ title: 'About', path: '/about' }) // brand image
647
+ export const metadata = createMetadata({ title: p.name, og: { image: p.image } })
648
648
  ```
649
649
 
650
- #### Low-level (escape hatches)
650
+ #### Per-page rendered cards
651
651
 
652
- `withOgImage(metadata, params)` merges a dynamic OG image into existing metadata;
653
- `createOgMetadata(params)` returns the `{ openGraph, twitter }` fragment;
654
- `buildOgUrl(params)` returns the raw URL string; `resolveOgImage(spec, …)` is the
655
- `OgSpec` decision point. Most pages use `createMetadata` and never touch these.
652
+ Use Next.js's `opengraph-image` file convention. It is discovered by filename
653
+ and overrides metadata, so this package needs no support for it — and offering
654
+ a second route to the same tag would only create a conflict.
656
655
 
657
- ```tsx
658
- import { buildOgUrl } from '@djangocfg/nextjs/og-image'
659
- const url = buildOgUrl({ title: 'Hello', preset: 'DARK_BLUE' })
660
- ```
656
+ #### Low-level (escape hatches)
661
657
 
662
- **URL resolution** (`NEXT_PUBLIC_MEDIA_URL` → `NEXT_PUBLIC_API_URL` → `NEXT_PUBLIC_SITE_URL` → relative).
658
+ `resolveOgImage(spec, staticUrl, fallbackTitle)` is the `OgSpec` decision point;
659
+ `extractTitle(metadata)` reads a plain title out of Next.js's title shapes. Most
660
+ pages use `createMetadata` and never touch these.
663
661
 
664
662
  ### Navigation
665
663
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/nextjs",
3
- "version": "2.1.537",
3
+ "version": "2.1.539",
4
4
  "description": "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -149,9 +149,9 @@
149
149
  "ai-docs": "tsx src/ai/cli.ts"
150
150
  },
151
151
  "peerDependencies": {
152
- "@djangocfg/devtools": "^2.1.537",
153
- "@djangocfg/i18n": "^2.1.537",
154
- "@djangocfg/ui-core": "^2.1.537",
152
+ "@djangocfg/devtools": "^2.1.539",
153
+ "@djangocfg/i18n": "^2.1.539",
154
+ "@djangocfg/ui-core": "^2.1.539",
155
155
  "next": "^16.2.2"
156
156
  },
157
157
  "peerDependenciesMeta": {
@@ -170,11 +170,11 @@
170
170
  "semver": "^7.8.5"
171
171
  },
172
172
  "devDependencies": {
173
- "@djangocfg/devtools": "^2.1.537",
174
- "@djangocfg/i18n": "^2.1.537",
175
- "@djangocfg/layouts": "^2.1.537",
176
- "@djangocfg/typescript-config": "^2.1.537",
177
- "@djangocfg/ui-core": "^2.1.537",
173
+ "@djangocfg/devtools": "^2.1.539",
174
+ "@djangocfg/i18n": "^2.1.539",
175
+ "@djangocfg/layouts": "^2.1.539",
176
+ "@djangocfg/typescript-config": "^2.1.539",
177
+ "@djangocfg/ui-core": "^2.1.539",
178
178
  "@types/node": "^25.9.5",
179
179
  "@types/react": "19.2.15",
180
180
  "@types/react-dom": "19.2.3",