Add Drupal headless stack with Next.js frontend
- Add Next.js frontend service (nextjs) with Dockerfile and source - Update docker-compose.yml: image names, Drupal 11.3.3, nextjs service - Add docker-compose.override.yml.disabled for dev hot-reload - Add install-headless-modules.sh for OAuth/JSON:API module setup - Add README.md with full setup and configuration guide - Update nginx/Dockerfile and nginx.conf.template for cms. subdomain - Update drupal/Dockerfile PHP-FPM build args - Gitignore **/.vscode/ to prevent IDE workspace files from being tracked
This commit is contained in:
parent
71a8dac389
commit
f8b8f53d54
85 changed files with 7802 additions and 17 deletions
0
drupal/nextjs/lib/config.ts
Normal file
0
drupal/nextjs/lib/config.ts
Normal file
20
drupal/nextjs/lib/drupal.ts
Normal file
20
drupal/nextjs/lib/drupal.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { NextDrupal } from "next-drupal"
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_DRUPAL_BASE_URL!
|
||||
|
||||
const auth =
|
||||
process.env.DRUPAL_CLIENT_ID && process.env.DRUPAL_CLIENT_SECRET
|
||||
? {
|
||||
clientId: process.env.DRUPAL_CLIENT_ID,
|
||||
clientSecret: process.env.DRUPAL_CLIENT_SECRET,
|
||||
...(process.env.DRUPAL_OAUTH_SCOPE && {
|
||||
scope: process.env.DRUPAL_OAUTH_SCOPE,
|
||||
}),
|
||||
}
|
||||
: undefined
|
||||
|
||||
export const drupal = new NextDrupal(baseUrl, {
|
||||
auth,
|
||||
withAuth: !!auth,
|
||||
debug: process.env.NODE_ENV === "development",
|
||||
})
|
||||
71
drupal/nextjs/lib/types.ts
Normal file
71
drupal/nextjs/lib/types.ts
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import type { JsonApiResource } from "next-drupal"
|
||||
|
||||
// Drupal JSON:API resource types.
|
||||
|
||||
export interface DrupalNode extends JsonApiResource {
|
||||
title: string
|
||||
status: boolean
|
||||
created: string
|
||||
changed: string
|
||||
path: {
|
||||
alias: string
|
||||
pid: number
|
||||
langcode: string
|
||||
}
|
||||
body?: {
|
||||
value: string
|
||||
format: string
|
||||
processed: string
|
||||
summary: string
|
||||
}
|
||||
field_image?: DrupalMedia
|
||||
uid?: {
|
||||
id: string
|
||||
display_name: string
|
||||
}
|
||||
metatag?: DrupalMetatag[]
|
||||
}
|
||||
|
||||
export interface DrupalMedia extends JsonApiResource {
|
||||
name: string
|
||||
field_media_image?: DrupalFile
|
||||
}
|
||||
|
||||
export interface DrupalFile extends JsonApiResource {
|
||||
uri: {
|
||||
value: string
|
||||
url: string
|
||||
}
|
||||
resourceIdObjMeta?: {
|
||||
alt: string
|
||||
title: string
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
}
|
||||
|
||||
export interface DrupalMetatag {
|
||||
tag: string
|
||||
attributes: Record<string, string>
|
||||
}
|
||||
|
||||
export interface DrupalMenuLinkContent {
|
||||
id: string
|
||||
title: string
|
||||
url: string
|
||||
parent: string
|
||||
weight: number
|
||||
expanded: boolean
|
||||
enabled: boolean
|
||||
items?: DrupalMenuLinkContent[]
|
||||
}
|
||||
|
||||
export interface DrupalServiceNode extends DrupalNode {
|
||||
/** Service type from Drupal (modelling, development, deployment, etc.). JSON:API exposes as field__service__type. */
|
||||
field__service__type?: string
|
||||
}
|
||||
|
||||
export interface DrupalAboutNode extends DrupalNode {
|
||||
/** JSON:API resource type: node--about. */
|
||||
field_email?: string
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue