strapi-layout-plugin 1.0.10 → 1.0.12
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/package.json
CHANGED
|
@@ -257,7 +257,7 @@ module.exports = ({ strapi }) => ({
|
|
|
257
257
|
return ctx.notFound('Page/Article not found');
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
const globalLayout = await strapi.entityService.findMany('
|
|
260
|
+
const globalLayout = await strapi.entityService.findMany('plugin::strapi-layout-plugin.layout', {
|
|
261
261
|
locale: requestedLocale,
|
|
262
262
|
populate: {
|
|
263
263
|
defaultSeo: { populate: '*' },
|
package/server/register.js
CHANGED
|
@@ -62,6 +62,36 @@ module.exports = ({ strapi }) => {
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
// 3. Scaffold Page API if it doesn't exist
|
|
66
|
+
const apiPageDir = path.join(strapi.dirs.app.src, 'api', 'page');
|
|
67
|
+
const apiPageContentTypesDir = path.join(apiPageDir, 'content-types', 'page');
|
|
68
|
+
const apiPageRoutesDir = path.join(apiPageDir, 'routes');
|
|
69
|
+
const apiPageControllersDir = path.join(apiPageDir, 'controllers');
|
|
70
|
+
const apiPageServicesDir = path.join(apiPageDir, 'services');
|
|
71
|
+
|
|
72
|
+
if (!fs.existsSync(apiPageDir)) {
|
|
73
|
+
fs.mkdirSync(apiPageContentTypesDir, { recursive: true });
|
|
74
|
+
fs.mkdirSync(apiPageRoutesDir, { recursive: true });
|
|
75
|
+
fs.mkdirSync(apiPageControllersDir, { recursive: true });
|
|
76
|
+
fs.mkdirSync(apiPageServicesDir, { recursive: true });
|
|
77
|
+
|
|
78
|
+
const templatesDir = path.join(__dirname, 'templates', 'page');
|
|
79
|
+
|
|
80
|
+
const pageFilesToCopy = [
|
|
81
|
+
{ src: path.join(templatesDir, 'schema.json'), dest: path.join(apiPageContentTypesDir, 'schema.json') },
|
|
82
|
+
{ src: path.join(templatesDir, 'route.js'), dest: path.join(apiPageRoutesDir, 'page.js') },
|
|
83
|
+
{ src: path.join(templatesDir, 'controller.js'), dest: path.join(apiPageControllersDir, 'page.js') },
|
|
84
|
+
{ src: path.join(templatesDir, 'service.js'), dest: path.join(apiPageServicesDir, 'page.js') }
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
pageFilesToCopy.forEach(({ src, dest }) => {
|
|
88
|
+
if (!fs.existsSync(dest) && fs.existsSync(src)) {
|
|
89
|
+
fs.copyFileSync(src, dest);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
strapi.log.info('[strapi-layout-plugin] Scaffolded base page API.');
|
|
93
|
+
}
|
|
94
|
+
|
|
65
95
|
strapi.log.info('[strapi-layout-plugin] Injected and seeded layout components during register phase.');
|
|
66
96
|
} catch (error) {
|
|
67
97
|
strapi.log.error('[strapi-layout-plugin] Failed to auto-seed components:', error);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collectionType",
|
|
3
|
+
"collectionName": "pages",
|
|
4
|
+
"info": {
|
|
5
|
+
"singularName": "page",
|
|
6
|
+
"pluralName": "pages",
|
|
7
|
+
"displayName": "Page",
|
|
8
|
+
"description": "Generic page for Layout Service"
|
|
9
|
+
},
|
|
10
|
+
"options": {
|
|
11
|
+
"draftAndPublish": true
|
|
12
|
+
},
|
|
13
|
+
"pluginOptions": {
|
|
14
|
+
"i18n": {
|
|
15
|
+
"localized": true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"attributes": {
|
|
19
|
+
"slug": {
|
|
20
|
+
"type": "uid",
|
|
21
|
+
"targetField": "title",
|
|
22
|
+
"required": true
|
|
23
|
+
},
|
|
24
|
+
"title": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"required": true
|
|
27
|
+
},
|
|
28
|
+
"seo": {
|
|
29
|
+
"type": "component",
|
|
30
|
+
"component": "shared.seo",
|
|
31
|
+
"repeatable": false
|
|
32
|
+
},
|
|
33
|
+
"template": {
|
|
34
|
+
"type": "enumeration",
|
|
35
|
+
"default": "default",
|
|
36
|
+
"enum": [
|
|
37
|
+
"default",
|
|
38
|
+
"sidebar-left"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"sections": {
|
|
42
|
+
"type": "dynamiczone",
|
|
43
|
+
"pluginOptions": {
|
|
44
|
+
"i18n": {
|
|
45
|
+
"localized": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"components": []
|
|
49
|
+
},
|
|
50
|
+
"relatedContentType": {
|
|
51
|
+
"type": "string"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|