strapi-layout-plugin 1.0.14 → 1.0.16

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 ADDED
@@ -0,0 +1,76 @@
1
+ # Strapi Layout Plugin (JD Layout System)
2
+
3
+ The **Strapi Layout Plugin** is a custom Headless CMS extension designed to provide dynamic, layout-based routing and a component orchestration API out-of-the-box. Paired with the `react-layout-sdk`, it acts as a headless Layout Service—similar to enterprise systems like Sitecore.
4
+
5
+ ## Installation
6
+
7
+ Install the plugin inside your Strapi project:
8
+
9
+ ```bash
10
+ npm install strapi-layout-plugin
11
+ ```
12
+
13
+ ## Setup & Initialization
14
+
15
+ After installing the plugin, ensure you have enabled it in your Strapi `config/plugins.js` or `config/plugins.ts` file:
16
+
17
+ ```javascript
18
+ module.exports = {
19
+ // ...
20
+ 'layout': {
21
+ enabled: true,
22
+ resolve: './node_modules/strapi-layout-plugin' // Optional depending on Strapi version mapping
23
+ },
24
+ // ...
25
+ }
26
+ ```
27
+
28
+ Once you restart your Strapi backend, the plugin will automatically scaffold:
29
+ 1. **Core Components**: Automatically injects base components (`core.header`, `core.footer`, `core.link`, etc.) into your Strapi components folder.
30
+ 2. **Page Collection Type**: Generates a generic `Page` content type to act as the route tree for your layout.
31
+ 3. **Global Layout Single Type**: Generates a `Global Layout` content type to control persistent layout features across your app.
32
+
33
+ ## API Reference
34
+
35
+ The plugin exposes a public layout retrieval endpoint:
36
+
37
+ ### `GET /api/layout/:slug`
38
+
39
+ Fetches the structured JSON layout data representing the matched route, fully populated with dynamic zones (`header`, `main`, and `footer`).
40
+
41
+ **Response Structure (JD Layout Schema):**
42
+ ```json
43
+ {
44
+ "strapi": {
45
+ "context": {
46
+ "pageEditing": false,
47
+ "site": {
48
+ "name": "JD"
49
+ },
50
+ "language": "en"
51
+ },
52
+ "route": {
53
+ "name": "home",
54
+ "displayName": "Home Page",
55
+ "placeholders": {
56
+ "header": [
57
+ {
58
+ "__component": "core.header",
59
+ "title": "Welcome"
60
+ }
61
+ ],
62
+ "main": [],
63
+ "footer": []
64
+ }
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Next Steps
71
+
72
+ To consume this data effortlessly on the frontend, install the companion package in your React / Next.js application:
73
+
74
+ ```bash
75
+ npm install react-layout-sdk
76
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-layout-plugin",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Strapi layout engine plugin for Sitecore-like routing",
5
5
  "strapi": {
6
6
  "name": "strapi-layout-plugin",
@@ -18,7 +18,7 @@
18
18
  "attributes": {
19
19
  "siteName": {
20
20
  "type": "string",
21
- "default": "Velox"
21
+ "default": "JD"
22
22
  },
23
23
  "defaultSeo": {
24
24
  "type": "component",
@@ -264,10 +264,19 @@ module.exports = ({ strapi }) => ({
264
264
  }
265
265
  });
266
266
 
267
- const siteName = globalLayout?.siteName || "Velox";
267
+ const siteName = globalLayout?.siteName || "JD";
268
268
  const language = page.locale || requestedLocale;
269
269
  const { sections } = page;
270
270
 
271
+ const {
272
+ id: _id, sections: _sections, section: _s1, blocks: _b1, seo: _seo,
273
+ createdAt: _ca, updatedAt: _ua, publishedAt: _pa, createdBy: _cb, updatedBy: _ub,
274
+ locale: _loc, title: _t, name: _name, slug: _s2, fields: existingFields,
275
+ ...flatFields
276
+ } = page;
277
+
278
+ const finalFields = existingFields || flatFields || {};
279
+
271
280
  ctx.body = {
272
281
  strapi: {
273
282
  context: {
@@ -279,6 +288,8 @@ module.exports = ({ strapi }) => ({
279
288
  route: {
280
289
  name: slug,
281
290
  displayName: page.title,
291
+ fields: finalFields,
292
+ seo: page.seo || globalLayout?.defaultSeo || null,
282
293
  placeholders: {
283
294
  header: globalLayout?.header || [],
284
295
  main: sections || [],