umberto 6.1.1 → 6.1.2

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
@@ -1,6 +1,13 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## [6.1.2](https://github.com/cksource/umberto/compare/v6.1.1...v6.1.2) (2025-04-23)
5
+
6
+ ### Bug fixes
7
+
8
+ * Umberto attempts to load the theme's favicons in case a project does not define its own, rather than generating links to non-existent resources. Closes [#1256](https://github.com/cksource/umberto/issues/1256). ([commit](https://github.com/cksource/umberto/commit/a6de17b195a67e78010773f420e54fa16b154378))
9
+
10
+
4
11
  ## [6.1.1](https://github.com/cksource/umberto/compare/v6.1.0...v6.1.1) (2025-04-17)
5
12
 
6
13
  ### Bug fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umberto",
3
- "version": "6.1.1",
3
+ "version": "6.1.2",
4
4
  "description": "CKSource Documentation builder",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md.
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ const hasOwnFavicons = require( '../../utils/has-own-favicons' );
9
+
10
+ hexo.extend.filter.register( 'before_post_render', data => {
11
+ return hasOwnFavicons( data, hexo );
12
+ } );
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md.
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ const upath = require( 'upath' );
9
+ const fs = require( 'fs' );
10
+
11
+ /**
12
+ * Checks if the project has its own favicons. If so, they will be used when rendering meta tags (`<link rel="icon">`).
13
+ *
14
+ * Otherwise, the default favicons will be used.
15
+ *
16
+ * @param {object} page
17
+ * @param {string} page.projectName
18
+ * @param {boolean} page.hasOwnAssets
19
+ * @param {object} hexo
20
+ * @param {Object.<string, ProjectGlobalConfig>} hexo.projectGlobals
21
+ * @returns {*}
22
+ */
23
+ module.exports = function hasOwnFavicons( page, hexo ) {
24
+ const projectConfig = hexo.projectGlobals[ page.projectName ];
25
+
26
+ let hasOwnAssets = false;
27
+
28
+ if ( projectConfig ) {
29
+ const { config } = hexo.projectGlobals[ page.projectName ];
30
+
31
+ if ( config ) {
32
+ hasOwnAssets = fs.existsSync(
33
+ upath.join( config.projectRootPath, 'docs', 'assets', 'img', 'favicons', '96x96.png' )
34
+ );
35
+ }
36
+ }
37
+
38
+ page.hasOwnAssets = hasOwnAssets;
39
+
40
+ return page;
41
+ };
42
+
43
+ /**
44
+ * @typedef {object} ProjectGlobalConfig
45
+ * @property {string} projectRootPath
46
+ * @property {object} config
47
+ * @property {string} config.projectRootPath
48
+ */
@@ -43,10 +43,13 @@ if page.BASE_PATH && page.BASE_PATH !== '.' && !page.BASE_PATH.includes( 'latest
43
43
  link( rel = 'canonical' href = page.canonicalUrlBeginning + page.path.replace( page.BASE_PATH, projectLocals.latestBasePath ) )
44
44
 
45
45
  if page.BASE_PATH
46
- link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( page.BASE_PATH, 'assets/img/favicons/16x16.png' ) ) sizes="16x16" )
47
- link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( page.BASE_PATH, 'assets/img/favicons/32x32.png' ) ) sizes="32x32" )
48
- link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( page.BASE_PATH, 'assets/img/favicons/96x96.png' ) ) sizes="96x96" )
49
- link( rel="apple-touch-icon" type="image/png" href=relative_url( page.path, pathJoin( page.BASE_PATH, 'assets/img/favicons/200x200.png' ) ) )
46
+ //- When a project does not define its own assets, let's use the default ones (from a theme).
47
+ //- See: #1256.
48
+ - const basePath = !page.hasOwnAssets ? '' : page.BASE_PATH;
49
+ link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( basePath, 'assets/img/favicons/16x16.png' ) ) sizes="16x16" )
50
+ link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( basePath, 'assets/img/favicons/32x32.png' ) ) sizes="32x32" )
51
+ link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( basePath, 'assets/img/favicons/96x96.png' ) ) sizes="96x96" )
52
+ link( rel="apple-touch-icon" type="image/png" href=relative_url( page.path, pathJoin( basePath, 'assets/img/favicons/200x200.png' ) ) )
50
53
 
51
54
  if ( docSearchConfig && docSearchConfig.isEnabled && !disableSearch && (!projectLocals || !projectLocals.disableSearch) )
52
55
  link( rel = 'stylesheet', href = docSearchConfig.css )
@@ -43,10 +43,13 @@ if page.BASE_PATH && page.BASE_PATH !== '.' && !page.BASE_PATH.includes( 'latest
43
43
  link( rel = 'canonical' href = page.canonicalUrlBeginning + page.path.replace( page.BASE_PATH, projectLocals.latestBasePath ) )
44
44
 
45
45
  if page.BASE_PATH
46
- link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( page.BASE_PATH, 'assets/img/favicons/16x16.png' ) ) sizes="16x16" )
47
- link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( page.BASE_PATH, 'assets/img/favicons/32x32.png' ) ) sizes="32x32" )
48
- link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( page.BASE_PATH, 'assets/img/favicons/96x96.png' ) ) sizes="96x96" )
49
- link( rel="apple-touch-icon" type="image/png" href=relative_url( page.path, pathJoin( page.BASE_PATH, 'assets/img/favicons/200x200.png' ) ) )
46
+ //- When a project does not define its own assets, let's use the default ones (from a theme).
47
+ //- See: #1256.
48
+ - const basePath = !page.hasOwnAssets ? '' : page.BASE_PATH;
49
+ link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( basePath, 'assets/img/favicons/16x16.png' ) ) sizes="16x16" )
50
+ link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( basePath, 'assets/img/favicons/32x32.png' ) ) sizes="32x32" )
51
+ link( rel="icon" type="image/png" href=relative_url( page.path, pathJoin( basePath, 'assets/img/favicons/96x96.png' ) ) sizes="96x96" )
52
+ link( rel="apple-touch-icon" type="image/png" href=relative_url( page.path, pathJoin( basePath, 'assets/img/favicons/200x200.png' ) ) )
50
53
 
51
54
  if ( docSearchConfig && docSearchConfig.isEnabled && !disableSearch && (!projectLocals || !projectLocals.disableSearch) )
52
55
  link( rel = 'stylesheet', href = docSearchConfig.css )