@djangocfg/nextjs 2.1.225 → 2.1.227
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 +49 -80
- package/dist/config/index.mjs +6 -17
- package/dist/config/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -6
- package/dist/index.mjs +9 -865
- package/dist/index.mjs.map +1 -1
- package/dist/og-image/index.d.mts +40 -100
- package/dist/og-image/index.mjs +46 -823
- package/dist/og-image/index.mjs.map +1 -1
- package/package.json +14 -25
- package/src/index.ts +0 -3
- package/src/og-image/README.md +142 -53
- package/src/og-image/index.ts +3 -27
- package/src/og-image/metadata.ts +67 -0
- package/src/og-image/types.ts +28 -44
- package/src/og-image/url.ts +58 -0
- package/dist/og-image/components/index.d.mts +0 -59
- package/dist/og-image/components/index.mjs +0 -338
- package/dist/og-image/components/index.mjs.map +0 -1
- package/dist/og-image/utils/index.d.mts +0 -308
- package/dist/og-image/utils/index.mjs +0 -327
- package/dist/og-image/utils/index.mjs.map +0 -1
- package/src/og-image/components/DefaultTemplate.tsx +0 -369
- package/src/og-image/components/index.ts +0 -9
- package/src/og-image/route.tsx +0 -312
- package/src/og-image/utils/fonts.ts +0 -150
- package/src/og-image/utils/index.ts +0 -28
- package/src/og-image/utils/metadata.ts +0 -269
- package/src/og-image/utils/url.ts +0 -386
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @djangocfg/nextjs
|
|
2
2
|
|
|
3
|
-
> Server-side Next.js utilities:
|
|
3
|
+
> Server-side Next.js utilities: OG images, sitemap, health checks, i18n, PWA, navigation, and config
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@djangocfg/nextjs)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -11,22 +11,20 @@
|
|
|
11
11
|
|
|
12
12
|
## Overview
|
|
13
13
|
|
|
14
|
-
`@djangocfg/nextjs` provides server-side utilities for Next.js applications
|
|
14
|
+
`@djangocfg/nextjs` provides server-side utilities for Next.js applications built on top of Django-CFG.
|
|
15
15
|
|
|
16
|
-
> **Note:** Client components (legal pages, error pages, redirect components)
|
|
16
|
+
> **Note:** Client components (legal pages, error pages, redirect components) are in `@djangocfg/layouts`.
|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **Base Next.js Config**
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
28
|
-
- **Navigation Utilities** - Route definitions, menu generation, and navigation helpers
|
|
29
|
-
- **TypeScript** - Full type safety throughout
|
|
20
|
+
- **OG Images** — typed URL builder for Django's `django_ogimage` renderer (`@djangocfg/nextjs/og-image`)
|
|
21
|
+
- **i18n** — full next-intl integration with routing, middleware, and components
|
|
22
|
+
- **PWA** — zero-config service worker and manifest
|
|
23
|
+
- **Base Next.js Config** — reusable `createBaseNextConfig()` factory for monorepos
|
|
24
|
+
- **Sitemap** — dynamic XML sitemap with i18n hreflang support
|
|
25
|
+
- **Health Checks** — production-ready health monitoring endpoints
|
|
26
|
+
- **Navigation** — route definitions, menu generation, and active-state helpers
|
|
27
|
+
- **AI Documentation** — search DjangoCFG docs via MCP server and CLI
|
|
30
28
|
|
|
31
29
|
## Installation
|
|
32
30
|
|
|
@@ -358,44 +356,21 @@ export const GET = createHealthHandler({
|
|
|
358
356
|
|
|
359
357
|
### OG Image Generation
|
|
360
358
|
|
|
361
|
-
|
|
359
|
+
Builds typed URLs pointing to Django's `django_ogimage` renderer — no Edge Runtime, no `@vercel/og`:
|
|
362
360
|
|
|
363
361
|
```tsx
|
|
364
|
-
// app/
|
|
365
|
-
import {
|
|
366
|
-
import { OgImageTemplate } from '@/components/OgImageTemplate';
|
|
367
|
-
|
|
368
|
-
export const runtime = 'edge';
|
|
369
|
-
|
|
370
|
-
const handler = createOgImageHandler({
|
|
371
|
-
template: OgImageTemplate,
|
|
372
|
-
defaultProps: {
|
|
373
|
-
siteName: 'My App',
|
|
374
|
-
logo: '/logo.svg',
|
|
375
|
-
},
|
|
376
|
-
fonts: [
|
|
377
|
-
{ family: 'Manrope', weight: 700 },
|
|
378
|
-
{ family: 'Manrope', weight: 500 },
|
|
379
|
-
],
|
|
380
|
-
size: { width: 1200, height: 630 },
|
|
381
|
-
});
|
|
362
|
+
// app/page.tsx
|
|
363
|
+
import { withOgImage } from '@djangocfg/nextjs/og-image'
|
|
382
364
|
|
|
383
|
-
export async function
|
|
384
|
-
return
|
|
365
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
366
|
+
return withOgImage(
|
|
367
|
+
{ title: 'My Page', description: 'Description' },
|
|
368
|
+
{ preset: 'DARK_BLUE', layout: 'HERO' }
|
|
369
|
+
)
|
|
385
370
|
}
|
|
386
371
|
```
|
|
387
372
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
```tsx
|
|
391
|
-
// app/page.tsx
|
|
392
|
-
import { generateAppMetadata } from '@djangocfg/nextjs/og-image/utils';
|
|
393
|
-
|
|
394
|
-
export const metadata = generateAppMetadata({
|
|
395
|
-
title: 'My Page',
|
|
396
|
-
description: 'Page description',
|
|
397
|
-
});
|
|
398
|
-
```
|
|
373
|
+
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.
|
|
399
374
|
|
|
400
375
|
### Navigation Utilities
|
|
401
376
|
|
|
@@ -445,9 +420,7 @@ import { RedirectPage } from '@djangocfg/layouts/components/RedirectPage';
|
|
|
445
420
|
| `@djangocfg/nextjs/pwa/worker` | Service worker creation helpers |
|
|
446
421
|
| `@djangocfg/nextjs/sitemap` | Sitemap generation with i18n hreflang support |
|
|
447
422
|
| `@djangocfg/nextjs/health` | Health check handlers |
|
|
448
|
-
| `@djangocfg/nextjs/og-image` | OG image
|
|
449
|
-
| `@djangocfg/nextjs/og-image/utils` | OG image URL and metadata utilities |
|
|
450
|
-
| `@djangocfg/nextjs/og-image/components` | OG image template components |
|
|
423
|
+
| `@djangocfg/nextjs/og-image` | OG image URL builder for Django's `django_ogimage` renderer |
|
|
451
424
|
| `@djangocfg/nextjs/navigation` | Route definitions, menu generation, navigation helpers |
|
|
452
425
|
|
|
453
426
|
## API Reference
|
|
@@ -609,54 +582,50 @@ createHealthHandler({
|
|
|
609
582
|
|
|
610
583
|
### OG Image
|
|
611
584
|
|
|
612
|
-
|
|
585
|
+
`@djangocfg/nextjs/og-image` builds typed URLs pointing to Django's `django_ogimage` renderer.
|
|
586
|
+
No Edge Runtime, no `@vercel/og`, no JSX templates — Django renders and caches the PNG.
|
|
613
587
|
|
|
614
|
-
|
|
588
|
+
See [`src/og-image/README.md`](./src/og-image/README.md) for full docs including URL resolution logic and deployment examples.
|
|
589
|
+
|
|
590
|
+
#### `withOgImage(metadata, params)`
|
|
591
|
+
|
|
592
|
+
Merges OG image into an existing `Metadata` object. Auto-extracts `title` if not in params.
|
|
615
593
|
|
|
616
594
|
```tsx
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
595
|
+
import { withOgImage } from '@djangocfg/nextjs/og-image'
|
|
596
|
+
|
|
597
|
+
export async function generateMetadata(): Promise<Metadata> {
|
|
598
|
+
return withOgImage(
|
|
599
|
+
{ title: 'My Page', description: 'Description' },
|
|
600
|
+
{ preset: 'DARK_BLUE', layout: 'HERO' }
|
|
601
|
+
)
|
|
602
|
+
}
|
|
624
603
|
```
|
|
625
604
|
|
|
626
|
-
#### `
|
|
605
|
+
#### `createOgMetadata(params)`
|
|
627
606
|
|
|
628
|
-
|
|
607
|
+
Returns a `Metadata` fragment with `openGraph.images` + `twitter.images`.
|
|
629
608
|
|
|
630
609
|
```tsx
|
|
631
|
-
|
|
632
|
-
metadata: Metadata, // Base metadata
|
|
633
|
-
ogImageParams?: Partial<OgImageUrlParams>, // Optional explicit params
|
|
634
|
-
options?: {
|
|
635
|
-
ogImageBaseUrl?: string; // Default: '/api/og'
|
|
636
|
-
siteUrl?: string; // Auto-detected if not provided
|
|
637
|
-
defaultParams?: Partial<OgImageUrlParams>; // Default params
|
|
638
|
-
useBase64?: boolean; // Default: true
|
|
639
|
-
}
|
|
640
|
-
)
|
|
641
|
-
```
|
|
610
|
+
import { createOgMetadata } from '@djangocfg/nextjs/og-image'
|
|
642
611
|
|
|
643
|
-
|
|
612
|
+
export async function generateMetadata() {
|
|
613
|
+
return createOgMetadata({ title: 'Page', preset: 'DARK_BLUE' })
|
|
614
|
+
}
|
|
615
|
+
```
|
|
644
616
|
|
|
645
|
-
|
|
617
|
+
#### `buildOgUrl(params)`
|
|
646
618
|
|
|
647
|
-
|
|
619
|
+
Returns the raw URL string. Useful when you need the URL outside of metadata.
|
|
648
620
|
|
|
649
621
|
```tsx
|
|
650
|
-
|
|
651
|
-
import { generateOgImageUrl } from '@djangocfg/layouts/utils/og-image';
|
|
622
|
+
import { buildOgUrl } from '@djangocfg/nextjs/og-image'
|
|
652
623
|
|
|
653
|
-
const url =
|
|
654
|
-
title: 'My Page',
|
|
655
|
-
description: 'Page description',
|
|
656
|
-
siteName: 'My Site',
|
|
657
|
-
});
|
|
624
|
+
const url = buildOgUrl({ title: 'Hello', preset: 'DARK_BLUE' })
|
|
658
625
|
```
|
|
659
626
|
|
|
627
|
+
**URL resolution** (`NEXT_PUBLIC_MEDIA_URL` → `NEXT_PUBLIC_API_URL` → `NEXT_PUBLIC_SITE_URL` → relative).
|
|
628
|
+
|
|
660
629
|
### Navigation
|
|
661
630
|
|
|
662
631
|
#### `defineRoute(path, metadata, config?)`
|
package/dist/config/index.mjs
CHANGED
|
@@ -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.
|
|
17
|
+
version: "2.1.227",
|
|
18
18
|
description: "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
|
|
19
19
|
keywords: [
|
|
20
20
|
"nextjs",
|
|
@@ -58,21 +58,6 @@ var require_package = __commonJS({
|
|
|
58
58
|
import: "./dist/health/index.mjs",
|
|
59
59
|
default: "./dist/health/index.mjs"
|
|
60
60
|
},
|
|
61
|
-
"./og-image": {
|
|
62
|
-
types: "./dist/og-image/index.d.mts",
|
|
63
|
-
import: "./dist/og-image/index.mjs",
|
|
64
|
-
default: "./dist/og-image/index.mjs"
|
|
65
|
-
},
|
|
66
|
-
"./og-image/utils": {
|
|
67
|
-
types: "./dist/og-image/utils/index.d.mts",
|
|
68
|
-
import: "./dist/og-image/utils/index.mjs",
|
|
69
|
-
default: "./dist/og-image/utils/index.mjs"
|
|
70
|
-
},
|
|
71
|
-
"./og-image/components": {
|
|
72
|
-
types: "./dist/og-image/components/index.d.mts",
|
|
73
|
-
import: "./dist/og-image/components/index.mjs",
|
|
74
|
-
default: "./dist/og-image/components/index.mjs"
|
|
75
|
-
},
|
|
76
61
|
"./navigation": {
|
|
77
62
|
types: "./dist/navigation/index.d.mts",
|
|
78
63
|
import: "./dist/navigation/index.mjs",
|
|
@@ -103,6 +88,11 @@ var require_package = __commonJS({
|
|
|
103
88
|
import: "./dist/pwa/worker/index.mjs",
|
|
104
89
|
default: "./dist/pwa/worker/index.mjs"
|
|
105
90
|
},
|
|
91
|
+
"./og-image": {
|
|
92
|
+
types: "./dist/og-image/index.d.mts",
|
|
93
|
+
import: "./dist/og-image/index.mjs",
|
|
94
|
+
default: "./dist/og-image/index.mjs"
|
|
95
|
+
},
|
|
106
96
|
"./monitor": {
|
|
107
97
|
types: "./dist/monitor/index.d.mts",
|
|
108
98
|
import: "./dist/monitor/index.mjs",
|
|
@@ -201,7 +191,6 @@ var require_package = __commonJS({
|
|
|
201
191
|
"@types/react-dom": "^19.1.0",
|
|
202
192
|
"@types/semver": "^7.7.1",
|
|
203
193
|
"@types/webpack": "^5.28.5",
|
|
204
|
-
"@vercel/og": "^0.8.5",
|
|
205
194
|
eslint: "^9.37.0",
|
|
206
195
|
"lucide-react": "^0.545.0",
|
|
207
196
|
tsup: "^8.0.1",
|