@videinfra/static-website-builder 1.16.3 → 1.17.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/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.1] - 2026-01-23
8
+ ### Added
9
+ - Sitemap generation in watch mode too
10
+
11
+ ## [1.17.0] - 2026-01-15
12
+ ### Added
13
+ - Added sitemap task
14
+
7
15
  ## [1.16.3] - 2025-10-29
8
16
  ### Updated
9
17
  - Added `embed` to TWIG dependency tracking
@@ -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>
@@ -5,6 +5,15 @@ const { series, parallel } = require('gulp');
5
5
  const { DEFAULT_TASKS, BUILD_TASKS } = require('./task-order');
6
6
  const resolveDynamicTask = require('./gulp/resolve-dynamic-task');
7
7
 
8
+ /**
9
+ * Sort tasks by .order property
10
+ *
11
+ * @param {array} tasks Tasks
12
+ * @returns {array} Sorted tasks
13
+ */
14
+ function sortTasks (tasks) {
15
+ return tasks.sort((a, b) => (a.order || 0) - (b.order || 0));
16
+ }
8
17
 
9
18
  /**
10
19
  * Organize and order tasks
@@ -46,8 +55,8 @@ function generateTaskList (taskConfig) {
46
55
  }
47
56
  }
48
57
 
49
- taskList.default = filter(taskList.default, taskGroup => taskGroup.length);
50
- taskList.build = filter(taskList.build, taskGroup => taskGroup.length);
58
+ taskList.default = filter(taskList.default, taskGroup => taskGroup.length).sort(sortTasks);
59
+ taskList.build = filter(taskList.build, taskGroup => taskGroup.length).sort(sortTasks);
51
60
 
52
61
  return taskList;
53
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videinfra/static-website-builder",
3
- "version": "1.16.3",
3
+ "version": "1.17.1",
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
 
@@ -4,3 +4,6 @@ const getConfig = require('./../../lib/get-config');
4
4
  exports.watch = function browserSync (callback) {
5
5
  bs.init(getConfig.getTaskConfig('browserSync'));
6
6
  };
7
+
8
+ // Execute as first task
9
+ exports.watch.order = -2;
@@ -86,6 +86,5 @@ function htmlWatch () {
86
86
  return taskWatch(getWatchGlobPaths(), html({ build: false }));
87
87
  }
88
88
 
89
-
90
89
  exports.build = html({ build: true });
91
90
  exports.watch = htmlWatch;
@@ -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,59 @@
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
+ const taskWatch = require('../../lib/gulp/task-watch');
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 gulp.src(getGlobPaths())
35
+ .pipe(taskStart())
36
+
37
+ // Prevent file from being rendered if it's in the ignore list
38
+ .pipe(gulpif(!!getGlobIgnorePaths().length, ignore.exclude(getGlobIgnorePaths(), {})))
39
+
40
+ // Preprocess sitemap
41
+ .pipe(gulpSitemap(getConfig.getTaskConfig('sitemap').sitemap))
42
+
43
+ .pipe(taskBeforeDest())
44
+ .pipe(gulp.dest(getPaths.getDestPath('sitemap')))
45
+
46
+ // Reload on change
47
+ .pipe(taskEnd());
48
+ }
49
+
50
+ function sitemapWatch () {
51
+ // Watch and execute immediatelly so that sitemap is generated on first run
52
+ return taskWatch(getGlobPaths(), sitemap) && sitemap();
53
+ }
54
+
55
+ exports.afterBuild = sitemap;
56
+ exports.watch = sitemapWatch;
57
+
58
+ // Execute after HTML task
59
+ exports.watch.order = 1;
@@ -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);