strapi-layout-plugin 1.0.3 → 1.0.5

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-layout-plugin",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Strapi layout engine plugin for Sitecore-like routing",
5
5
  "strapi": {
6
6
  "name": "strapi-layout-plugin",
package/server/index.js CHANGED
@@ -3,11 +3,11 @@
3
3
  const controllers = require('./controllers');
4
4
  const routes = require('./routes');
5
5
  const contentTypes = require('./content-types');
6
- const components = require('./components');
6
+ const bootstrap = require('./bootstrap');
7
7
 
8
8
  module.exports = {
9
9
  controllers,
10
10
  routes,
11
11
  contentTypes,
12
- components,
12
+ bootstrap,
13
13
  };
@@ -1,6 +1,46 @@
1
1
  'use strict';
2
2
 
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
3
6
  module.exports = ({ strapi }) => {
7
+ // --- Auto-seed components before Strapi loads models ---
8
+ try {
9
+ const pluginComponentsDir = path.join(__dirname, 'components');
10
+ const appComponentsDir = path.join(strapi.dirs.app.src, 'components');
11
+
12
+ const veloxDir = path.join(appComponentsDir, 'velox');
13
+ const sharedDir = path.join(appComponentsDir, 'shared');
14
+
15
+ if (!fs.existsSync(appComponentsDir)) fs.mkdirSync(appComponentsDir, { recursive: true });
16
+ if (!fs.existsSync(veloxDir)) fs.mkdirSync(veloxDir, { recursive: true });
17
+ if (!fs.existsSync(sharedDir)) fs.mkdirSync(sharedDir, { recursive: true });
18
+
19
+ const filesToCopy = [
20
+ { src: path.join(pluginComponentsDir, 'velox', 'header.json'), dest: path.join(veloxDir, 'header.json') },
21
+ { src: path.join(pluginComponentsDir, 'velox', 'footer.json'), dest: path.join(veloxDir, 'footer.json') },
22
+ { src: path.join(pluginComponentsDir, 'velox', 'link.json'), dest: path.join(veloxDir, 'link.json') },
23
+ { src: path.join(pluginComponentsDir, 'velox', 'social-link.json'), dest: path.join(veloxDir, 'social-link.json') },
24
+ { src: path.join(pluginComponentsDir, 'velox', 'footer-column.json'), dest: path.join(veloxDir, 'footer-column.json') },
25
+ { src: path.join(pluginComponentsDir, 'shared', 'seo.json'), dest: path.join(sharedDir, 'seo.json') }
26
+ ];
27
+
28
+ let copied = false;
29
+ filesToCopy.forEach(({ src, dest }) => {
30
+ if (!fs.existsSync(dest) && fs.existsSync(src)) {
31
+ fs.copyFileSync(src, dest);
32
+ copied = true;
33
+ }
34
+ });
35
+
36
+ if (copied) {
37
+ strapi.log.info('[strapi-layout-plugin] Seeded layout components into src/components during register phase.');
38
+ }
39
+ } catch (error) {
40
+ strapi.log.error('[strapi-layout-plugin] Failed to auto-seed components:', error);
41
+ }
42
+ // -------------------------------------------------------
43
+
4
44
  const graphqlPlugin = strapi.plugin('graphql');
5
45
 
6
46
  if (!graphqlPlugin) {