create-berna-stencil 2.4.0 → 2.4.1

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/.eleventy.js CHANGED
@@ -43,6 +43,7 @@ module.exports = function (eleventyConfig) {
43
43
  eleventyConfig.addPassthroughCopy("src/frontend/.htaccess");
44
44
  eleventyConfig.addPassthroughCopy("src/frontend/web.config");
45
45
  eleventyConfig.addPassthroughCopy("src/frontend/assets");
46
+ eleventyConfig.addPassthroughCopy("src/frontend/data");
46
47
  eleventyConfig.addPassthroughCopy("src/frontend/robots.txt");
47
48
 
48
49
  eleventyConfig.addPassthroughCopy({
package/README.md CHANGED
@@ -12,7 +12,7 @@ Building a website from scratch involves a lot of moving parts: templating engin
12
12
  - 📁 **Scalable structure** — a clean, opinionated project layout that grows with your needs
13
13
  - 🌍 **Open source** — free to use, free to modify, free to share
14
14
 
15
- ![Version](https://img.shields.io/badge/version-2.4.0-blue)
15
+ ![Version](https://img.shields.io/badge/version-2.4.1-blue)
16
16
  ![License](https://img.shields.io/badge/license-Apache--2.0-blue)
17
17
  ![Eleventy](https://img.shields.io/badge/11ty-v3.1.2-black)
18
18
 
@@ -5,21 +5,15 @@ const INCLUDES_PATH = 'src/frontend/components/layouts/includes.njk';
5
5
 
6
6
  // --- Helpers ---
7
7
 
8
- // Returns the file content as a string, or null if the file doesn't exist
9
8
  function readIncludes() {
10
9
  if (!fileSystem.existsSync(INCLUDES_PATH)) return null;
11
10
  return fileSystem.readFileSync(INCLUDES_PATH, 'utf8');
12
11
  }
13
12
 
14
- // Writes updated content back to the includes file
15
13
  function writeIncludes(content) {
16
14
  fileSystem.writeFileSync(INCLUDES_PATH, content);
17
15
  }
18
16
 
19
- // Builds the regex that matches the elif block for a given camelCase page name.
20
- // Defined once here to avoid duplication and the stateful /g flag bug:
21
- // using /g with .test() advances lastIndex, making a subsequent .replace() start
22
- // from the wrong position. A fresh non-/g regex avoids this entirely.
23
17
  function buildElifRegex(camelName) {
24
18
  return new RegExp(
25
19
  `[ \\t]*\\{%\\s*elif\\s+title\\s*==\\s*"${camelName}"\\s*%\\}[\\s\\S]*?(?=[ \\t]*\\{%\\s*(?:elif|else|endif))`,
@@ -28,14 +22,12 @@ function buildElifRegex(camelName) {
28
22
 
29
23
  // --- Public API ---
30
24
 
31
- // Inserts a new elif block before {% else %} for the given page
32
25
  function addLayout(pageName) {
33
26
  const content = readIncludes();
34
27
  if (!content) return;
35
28
 
36
29
  const camelName = toCamelCase(pageName);
37
30
 
38
- // Skip if the block already exists
39
31
  if (content.includes(`{% elif title == "${camelName}" %}`)) return;
40
32
 
41
33
  const newElif =
@@ -47,7 +39,6 @@ function addLayout(pageName) {
47
39
  console.log(`[UPDATED] Layout block added for "${camelName}".`);
48
40
  }
49
41
 
50
- // Removes the elif block for the given page, then collapses extra blank lines
51
42
  function removeLayout(pageName) {
52
43
  const content = readIncludes();
53
44
  if (!content) return;
@@ -60,7 +51,6 @@ function removeLayout(pageName) {
60
51
  return;
61
52
  }
62
53
 
63
- // Build a fresh regex instance for replace to avoid stale lastIndex
64
54
  const updated = content
65
55
  .replace(buildElifRegex(camelName), '')
66
56
  .replace(/\n\s*\n\s*\n/g, '\n\n');
@@ -69,10 +59,23 @@ function removeLayout(pageName) {
69
59
  console.log(`[CLEANED] Layout block removed for "${camelName}".`);
70
60
  }
71
61
 
72
- // Renames a layout block by removing the old one and inserting a new one
73
62
  function renameLayout(oldName, newName) {
74
- removeLayout(oldName);
75
- addLayout(newName);
63
+ const content = readIncludes();
64
+ if (!content) return;
65
+
66
+ const oldCamel = toCamelCase(oldName);
67
+ const newCamel = toCamelCase(newName);
68
+
69
+ const oldLine = `{% elif title == "${oldCamel}" %}`;
70
+ const newLine = `{% elif title == "${newCamel}" %}`;
71
+
72
+ if (!content.includes(oldLine)) {
73
+ console.log(`[DEBUG] Layout block for "${oldCamel}" not found. Skipped.`);
74
+ return;
75
+ }
76
+
77
+ writeIncludes(content.replace(oldLine, newLine));
78
+ console.log(`[RENAMED] Layout block renamed from "${oldCamel}" to "${newCamel}".`);
76
79
  }
77
80
 
78
81
  module.exports = { addLayout, removeLayout, renameLayout };
@@ -1,13 +1,5 @@
1
- //===========================
2
- // JAVASCRIPT MODULES IMPORTS
3
- //===========================
4
-
5
1
  // import { initExampleModule } from '../modules/exampleModule.js';
6
2
 
7
- //==========================
8
- // PAGE CUSTOM JAVASCRIPT
9
- //==========================
10
-
11
3
  document.addEventListener("DOMContentLoaded", () => {
12
4
  // initExampleModule();
13
5
  });
@@ -1,13 +1,5 @@
1
- //===========================
2
- // TYPESCRIPT MODULES IMPORTS
3
- //===========================
4
-
5
1
  // import { initExampleModule } from '../modules/exampleModule';
6
2
 
7
- //==========================
8
- // PAGE CUSTOM TYPESCRIPT
9
- //==========================
10
-
11
3
  document.addEventListener("DOMContentLoaded", (): void => {
12
4
  // initExampleModule();
13
5
  });
package/bin/create.js CHANGED
@@ -120,7 +120,7 @@ src/backend/config.php
120
120
 
121
121
  const PROJECT_PACKAGE = {
122
122
  name: path.basename(targetDir),
123
- version: '2.4.0',
123
+ version: '2.4.1',
124
124
  private: true,
125
125
  outputDir: 'out',
126
126
  "scripts": {
@@ -11,19 +11,13 @@ Import only what the page needs.
11
11
  ### examplePage.js <small>(`src/frontend/js/pages/`)</small>
12
12
 
13
13
  ```js
14
- //===========================
15
- // JAVASCRIPT MODULES IMPORTS
16
- //===========================
17
-
18
14
  // import { initExampleModule } from '../modules/exampleModule.js';
19
15
 
20
- //==========================
21
- // PAGE CUSTOM JAVASCRIPT
22
- //==========================
23
-
24
16
  document.addEventListener("DOMContentLoaded", () => {
25
17
  // initExampleModule();
26
18
  });
19
+
20
+ // Page logic here
27
21
  ```
28
22
 
29
23
  ## Modules
@@ -39,12 +33,8 @@ Use ESM syntax — esbuild handles the bundling:
39
33
  ### exampleModule.js <small>(`src/frontend/js/modules/`)</small>
40
34
 
41
35
  ```js
42
- //==========================
43
- // EXAMPLE MODULE
44
- //==========================
45
-
46
36
  export function exampleModule() {
47
- // Example module logic
37
+ // Module logic here
48
38
  }
49
39
  ```
50
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-berna-stencil",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Eleventy boilerplate with per-page SCSS/JS pipeline, esbuild bundling, multi-framework CSS support and a built-in page management CLI",
5
5
  "keywords": [],
6
6
  "author": "Michele Garofalo",
@@ -1,7 +1,3 @@
1
- //==========================
2
- // EXAMPLE MODULE
3
- //==========================
4
-
5
1
  export function initExampleModule() {
6
- // Example module logic
2
+ // Module logic here
7
3
  }
@@ -1,13 +1,7 @@
1
- //===========================
2
- // JAVASCRIPT MODULES IMPORTS
3
- //===========================
4
-
5
1
  // import { initExampleModule } from '../modules/exampleModule.js';
6
2
 
7
- //==========================
8
- // PAGE CUSTOM JAVASCRIPT
9
- //==========================
10
-
11
3
  document.addEventListener("DOMContentLoaded", () => {
12
4
  // initExampleModule();
13
- });
5
+ });
6
+
7
+ // Page logic here
@@ -1,13 +1,7 @@
1
- //===========================
2
- // JAVASCRIPT MODULES IMPORTS
3
- //===========================
4
-
5
1
  // import { initExampleModule } from '../modules/exampleModule.js';
6
2
 
7
- //==========================
8
- // PAGE CUSTOM JAVASCRIPT
9
- //==========================
10
-
11
3
  document.addEventListener("DOMContentLoaded", () => {
12
4
  // initExampleModule();
13
- });
5
+ });
6
+
7
+ // Page logic here
@@ -36,9 +36,9 @@
36
36
  }
37
37
 
38
38
  body {
39
- min-height: 100svh;
40
39
  display: flex;
41
40
  flex-direction: column;
41
+ min-height: 100svh;
42
42
  }
43
43
 
44
44
  main {
@@ -8,9 +8,6 @@
8
8
  header {
9
9
  height: root.$header-height;
10
10
  width: 100%;
11
- display: flex;
12
- justify-content: center;
13
- align-items: center;
14
11
  padding: root.$header-padding-y root.$header-padding-x;
15
12
  background-color: root.$primary;
16
13
  background-color: #2e7253;
@@ -1,3 +1,3 @@
1
1
  export function initExampleModule(): void {
2
- // Example module logic
2
+ // Module logic here
3
3
  }
@@ -1,13 +1,7 @@
1
- //===========================
2
- // TYPESCRIPT MODULES IMPORTS
3
- //===========================
4
-
5
1
  // import { initExampleModule } from '../modules/exampleModule';
6
2
 
7
- //==========================
8
- // PAGE CUSTOM TYPESCRIPT
9
- //==========================
10
-
11
3
  document.addEventListener("DOMContentLoaded", (): void => {
12
4
  // initExampleModule();
13
- });
5
+ });
6
+
7
+ // Page logic here
@@ -1,13 +1,7 @@
1
- //===========================
2
- // TYPESCRIPT MODULES IMPORTS
3
- //===========================
4
-
5
1
  // import { initExampleModule } from '../modules/exampleModule';
6
2
 
7
- //==========================
8
- // PAGE CUSTOM TYPESCRIPT
9
- //==========================
10
-
11
3
  document.addEventListener("DOMContentLoaded", (): void => {
12
4
  // initExampleModule();
13
- });
5
+ });
6
+
7
+ // Page logic here