create-berna-stencil 2.0.0 → 2.0.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/README.md +1 -1
- package/package.json +1 -1
- package/src/frontend/components/welcome.njk +10 -9
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-berna-stencil",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.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",
|
|
@@ -220,14 +220,15 @@ body {
|
|
|
220
220
|
<p>It is bundled and minified by esbuild and loaded automatically by <code>base.njk</code></p>
|
|
221
221
|
<p>Import only what the page needs.</p>
|
|
222
222
|
<h4>examplePage.js <small>(<code>src/frontend/js/pages/</code>)</small></h4>
|
|
223
|
-
<pre><code>
|
|
224
|
-
|
|
223
|
+
<pre><code>
|
|
224
|
+
import { initLangSwitcher } from '../modules/langSwitcher.js';
|
|
225
|
+
import { showNotification } from '../modules/notification.js';
|
|
225
226
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
228
|
+
initLangSwitcher();
|
|
229
|
+
});
|
|
229
230
|
|
|
230
|
-
|
|
231
|
+
showNotification("Page loaded", "success", 3000);</code></pre>
|
|
231
232
|
<h3>Modules</h3>
|
|
232
233
|
<p>Modules live in <code>src/frontend/js/modules/</code>. Some must be called inside <code>DOMContentLoaded</code> as they interact with the DOM; others create elements dynamically and can be called anywhere.</p>
|
|
233
234
|
<h4>Call inside <code>DOMContentLoaded</code></h4>
|
|
@@ -266,9 +267,9 @@ body {
|
|
|
266
267
|
<p>Create a new <code>.js</code> file in <code>src/frontend/js/modules/</code>. You can organize them into subfolders freely.</p>
|
|
267
268
|
<p>Use ESM syntax — esbuild handles the bundling:</p>
|
|
268
269
|
<pre><code>// _yourModule.js
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
export function yourFunction() {
|
|
271
|
+
// ...
|
|
272
|
+
}</code></pre>
|
|
272
273
|
<p>Then import it in the pages that need it:</p>
|
|
273
274
|
<pre><code>import { yourFunction } from '../modules/yourModule.js';</code></pre>
|
|
274
275
|
<blockquote>⚠️ Files inside <code>_tools/</code> run directly in Node.js without a bundler — use CommonJS (<code>require</code> / <code>module.exports</code>) there, not ESM.</blockquote>
|