@videinfra/static-website-builder 1.16.2 → 1.17.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [1.17.0] - 2026-01-15
8
+ ### Added
9
+ - Added sitemap task
10
+
11
+ ## [1.16.3] - 2025-10-29
12
+ ### Updated
13
+ - Added `embed` to TWIG dependency tracking
14
+
7
15
  ## [1.16.2] - 2025-10-29
8
16
  ### Updated
9
17
  - Changed `sass` to sync for better performance
@@ -0,0 +1,12 @@
1
+ {% from 'macros/icon.twig' import icon %}
2
+ {% extends 'layouts/base.twig' %}
3
+
4
+ {% block head %}
5
+ <head>
6
+ <meta name="robots" content="noindex" />
7
+ </head>
8
+ {% endblock %}
9
+
10
+ {% block body %}
11
+ <h1>{{ hello }} {{ world }}!</h1>
12
+ {% endblock %}
@@ -1 +1 @@
1
- <html><body>{% block body %}{% endblock %}</body></html>
1
+ <html>{% block head %}{% endblock %}<body>{% block body %}{% endblock %}</body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videinfra/static-website-builder",
3
- "version": "1.16.2",
3
+ "version": "1.17.0",
4
4
  "description": "Customizable static site project builder",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -26,9 +26,9 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@babel/core": "^7.21.8",
29
- "@babel/preset-env": "^7.21.5",
30
29
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
31
30
  "@babel/plugin-proposal-optional-chaining": "^7.21.0",
31
+ "@babel/preset-env": "^7.21.5",
32
32
  "@csstools/postcss-nested-calc": "^3.0.0",
33
33
  "autoprefixer": "^10.4.14",
34
34
  "babel-loader": "^8.3.0",
@@ -49,6 +49,7 @@
49
49
  "gulp-plumber": "^1.2.1",
50
50
  "gulp-postcss": "^9.0.1",
51
51
  "gulp-sass": "^5.1.0",
52
+ "gulp-sitemap": "^8.0.0",
52
53
  "gulp-sizereport": "^1.2.1",
53
54
  "gulp-sourcemaps": "^3.0.0",
54
55
  "gulp-svgmin": "^4.1.0",
package/plugins/twig.js CHANGED
@@ -11,6 +11,7 @@ exports.html = {
11
11
  'shared/**/*',
12
12
  'partials/**/*',
13
13
  'macros/**/*',
14
+ 'embeds/**/*',
14
15
  'layouts/**/*',
15
16
  ],
16
17
 
@@ -18,7 +19,7 @@ exports.html = {
18
19
  dependents: {
19
20
  '.twig': {
20
21
  parserSteps: [
21
- /\{%\s+(?:from|extends|include)\s+['"]([^'"]+)/gm,
22
+ /\{%\s+(?:from|extends|include|embed)\s+['"]([^'"]+)/gm,
22
23
  ],
23
24
  prefixes: [],
24
25
  postfixes: [],
@@ -0,0 +1,49 @@
1
+ exports.sitemap = {
2
+ // Add twig to the extensions
3
+ extensions: ['html'],
4
+
5
+ // Glob list of files, which to ignore
6
+ // see https://gulpjs.com/docs/en/getting-started/explaining-globs/
7
+ ignore: [],
8
+
9
+ // Gulp sitemap specific settings
10
+ sitemap: {
11
+ // Skip noindex pages
12
+ noindex: true,
13
+
14
+ // Change frequency
15
+ changefreq: 'daily',
16
+
17
+ // Custom priority function
18
+ priority: function(siteUrl, loc, entry) {
19
+ return loc === siteUrl ? 1 : 0.9;
20
+ },
21
+ },
22
+
23
+ // Production only settings, overwrites default settings
24
+ production: {},
25
+
26
+ // Development only settings, overwrites default settings
27
+ development: {},
28
+ };
29
+
30
+ exports.tasks = {
31
+ sitemap: [
32
+ require('./task'),
33
+ ]
34
+ };
35
+
36
+ exports.preprocess = {
37
+ sitemap: [
38
+ require('./preprocess-config'),
39
+ ]
40
+ };
41
+
42
+ /**
43
+ * Paths relative to the global src and dest folders
44
+ */
45
+ exports.paths = {
46
+ sitemap: {
47
+ 'dest': '',
48
+ }
49
+ };
@@ -0,0 +1,18 @@
1
+ const getEnvData = require('../env/get-env');
2
+
3
+ /**
4
+ * Modify configuration
5
+ *
6
+ * @param {object} config Sitemap configuration
7
+ * @param {object} fullConfig Full configuration
8
+ * @returns {object} Transformed sitemap configuration
9
+ */
10
+ module.exports = function preprocessSitemapConfig (config = {}, fullConfig) {
11
+ const envData = getEnvData();
12
+
13
+ // Set host
14
+ config.sitemap = config.sitemap || {};
15
+ config.sitemap.siteUrl = envData.env.host;
16
+
17
+ return config;
18
+ }
@@ -0,0 +1,52 @@
1
+ const gulp = require('gulp');
2
+ const gulpif = require('gulp-if');
3
+ const memoize = require('nano-memoize');
4
+ const ignore = require('gulp-ignore');
5
+ const gulpSitemap = require('gulp-sitemap');
6
+
7
+ const getPaths = require('./../../lib/get-path');
8
+ const getConfig = require('./../../lib/get-config');
9
+ const globs = require('./../../lib/globs-helper');
10
+
11
+ const taskStart = require('../../lib/gulp/task-start');
12
+ const taskEnd = require('../../lib/gulp/task-end');
13
+ const taskBeforeDest = require('../../lib/gulp/task-before-dest');
14
+
15
+
16
+ const getGlobPaths = memoize(function () {
17
+ const sourcePaths = getPaths.getDestPath('html');
18
+ const extensions = getConfig.getTaskConfig('sitemap', 'extensions');
19
+
20
+ return globs.generate([
21
+ globs.paths(sourcePaths).filesWithExtensions(extensions), // HTML files
22
+ ]);
23
+ });
24
+
25
+ const getGlobIgnorePaths = memoize(function () {
26
+ const ignore = getConfig.getTaskConfig('sitemap', 'ignore');
27
+
28
+ return globs.generate([
29
+ globs.paths(ignore), // Exclude files and folders from being rendered
30
+ ]);
31
+ });
32
+
33
+ function sitemap () {
34
+ return function sitemap () {
35
+ return gulp.src(getGlobPaths())
36
+ .pipe(taskStart())
37
+
38
+ // Prevent file from being rendered if it's in the ignore list
39
+ .pipe(gulpif(!!getGlobIgnorePaths().length, ignore.exclude(getGlobIgnorePaths(), {})))
40
+
41
+ // Preprocess sitemap
42
+ .pipe(gulpSitemap(getConfig.getTaskConfig('sitemap').sitemap))
43
+
44
+ .pipe(taskBeforeDest())
45
+ .pipe(gulp.dest(getPaths.getDestPath('sitemap')))
46
+
47
+ // Reload on change
48
+ .pipe(taskEnd());
49
+ };
50
+ }
51
+
52
+ exports.afterBuild = sitemap();
@@ -0,0 +1,11 @@
1
+ const path = require('path');
2
+ const publicPath = path.resolve(__dirname, 'build', 'public');
3
+ const fs = require('fs')
4
+ const fsPromises = fs.promises;
5
+
6
+ test('Sitemap generated, but doesn\'t include 404 page', () => {
7
+ return fsPromises.readFile(path.resolve(publicPath, 'sitemap.xml'), {'encoding': 'utf8'}).then((html) => {
8
+ expect(html.includes('<loc>https://test-local.tld/404.html</loc>')).toBe(false);
9
+ });
10
+ });
11
+
@@ -93,7 +93,7 @@ module.exports = function (options) {
93
93
  if (options.async) {
94
94
  template.renderAsync(data)
95
95
  .then(function (output) {
96
- file.contents = Buffer.from(output);
96
+ file.contents = new Buffer(output);
97
97
  file.path = data._target.path;
98
98
  cb(null, file);
99
99
  })
@@ -110,7 +110,7 @@ module.exports = function (options) {
110
110
  });
111
111
  } else {
112
112
  try {
113
- file.contents = Buffer.from(template.render(data));
113
+ file.contents = new Buffer(template.render(data));
114
114
  }catch(e){
115
115
  if (options.errorLogToConsole) {
116
116
  log(PLUGIN_NAME + ' ' + e);