@djangocfg/nextjs 2.1.438 → 2.1.439

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/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
 
24
24
  ## Features
25
25
 
26
- - **OG Images** — typed URL builder for Django's `django_ogimage` renderer (`@djangocfg/nextjs/og-image`)
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`)
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
@@ -387,23 +387,31 @@ export const GET = createHealthHandler({
387
387
  });
388
388
  ```
389
389
 
390
- ### OG Image Generation
390
+ ### Page Metadata + OG Images
391
391
 
392
- Builds typed URLs pointing to Django's `django_ogimage` renderer no Edge Runtime, no `@vercel/og`:
392
+ One factory per app builds complete page `Metadata` (title, openGraph, twitter,
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`:
393
396
 
394
397
  ```tsx
395
- // app/page.tsx
396
- import { withOgImage } from '@djangocfg/nextjs/og-image'
397
-
398
- export async function generateMetadata(): Promise<Metadata> {
399
- return withOgImage(
400
- { title: 'My Page', description: 'Description' },
401
- { preset: 'DARK_BLUE', layout: 'HERO' }
402
- )
403
- }
398
+ // app/_core/metadata.ts — bind once
399
+ import { makeMetadataFactory } from '@djangocfg/nextjs/og-image'
400
+ export const createMetadata = makeMetadataFactory({
401
+ name: settings.app.name,
402
+ description: settings.app.description,
403
+ siteUrl: settings.app.siteUrl,
404
+ ogImage: settings.app.media.ogimage,
405
+ locales: LOCALES,
406
+ })
407
+
408
+ // landing page → static brand image (default)
409
+ 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' })
404
412
  ```
405
413
 
406
- The 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.
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.
407
415
 
408
416
  ### Navigation Utilities
409
417
 
@@ -453,7 +461,7 @@ import { RedirectPage } from '@djangocfg/layouts/components/RedirectPage';
453
461
  | `@djangocfg/nextjs/pwa/worker` | Service worker creation helpers |
454
462
  | `@djangocfg/nextjs/sitemap` | Sitemap generation with i18n hreflang support |
455
463
  | `@djangocfg/nextjs/health` | Health check handlers |
456
- | `@djangocfg/nextjs/og-image` | OG image URL builder for Django's `django_ogimage` renderer |
464
+ | `@djangocfg/nextjs/og-image` | Page metadata factory + static/dynamic OG images for Django's `django_ogimage` |
457
465
  | `@djangocfg/nextjs/navigation` | Route definitions, menu generation, navigation helpers |
458
466
 
459
467
  ## API Reference
@@ -613,47 +621,41 @@ createHealthHandler({
613
621
  })
614
622
  ```
615
623
 
616
- ### OG Image
624
+ ### Page Metadata + OG Image
617
625
 
618
- `@djangocfg/nextjs/og-image` builds typed URLs pointing to Django's `django_ogimage` renderer.
619
- No Edge Runtime, no `@vercel/og`, no JSX templates — Django renders and caches the PNG.
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.
620
629
 
621
- See [`src/og-image/README.md`](./src/og-image/README.md) for full docs including URL resolution logic and deployment examples.
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).
622
632
 
623
- #### `withOgImage(metadata, params)`
633
+ #### `makeMetadataFactory(config)` — recommended
624
634
 
625
- Merges OG image into an existing `Metadata` object. Auto-extracts `title` if not in params.
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? }`.
626
637
 
627
638
  ```tsx
628
- import { withOgImage } from '@djangocfg/nextjs/og-image'
629
-
630
- export async function generateMetadata(): Promise<Metadata> {
631
- return withOgImage(
632
- { title: 'My Page', description: 'Description' },
633
- { preset: 'DARK_BLUE', layout: 'HERO' }
634
- )
635
- }
636
- ```
637
-
638
- #### `createOgMetadata(params)`
639
+ import { makeMetadataFactory } from '@djangocfg/nextjs/og-image'
639
640
 
640
- Returns a `Metadata` fragment with `openGraph.images` + `twitter.images`.
641
-
642
- ```tsx
643
- import { createOgMetadata } from '@djangocfg/nextjs/og-image'
641
+ export const createMetadata = makeMetadataFactory({
642
+ name: 'CMDOP', description: '…', siteUrl: 'https://cmdop.com',
643
+ ogImage: '/static/ogimage.png', locales: LOCALES,
644
+ })
644
645
 
645
- export async function generateMetadata() {
646
- return createOgMetadata({ title: 'Page', preset: 'DARK_BLUE' })
647
- }
646
+ export const metadata = createMetadata({ title: 'About', path: '/about' }) // static
647
+ export const metadata = createMetadata({ title: post.title, path, og: 'dynamic' }) // rendered title
648
648
  ```
649
649
 
650
- #### `buildOgUrl(params)`
650
+ #### Low-level (escape hatches)
651
651
 
652
- Returns the raw URL string. Useful when you need the URL outside of metadata.
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.
653
656
 
654
657
  ```tsx
655
658
  import { buildOgUrl } from '@djangocfg/nextjs/og-image'
656
-
657
659
  const url = buildOgUrl({ title: 'Hello', preset: 'DARK_BLUE' })
658
660
  ```
659
661
 
@@ -14,7 +14,7 @@ var require_package = __commonJS({
14
14
  "package.json"(exports, module) {
15
15
  module.exports = {
16
16
  name: "@djangocfg/nextjs",
17
- version: "2.1.438",
17
+ version: "2.1.439",
18
18
  description: "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
19
19
  keywords: [
20
20
  "nextjs",