hexo-swpp 3.1.0 → 3.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.
Files changed (2) hide show
  1. package/dist/index.js +6 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ const logger = require('hexo-log').default();
33
33
  // noinspection JSUnusedGlobalSymbols
34
34
  function start(hexo) {
35
35
  const { config } = hexo;
36
- if (!(config['swpp']?.enable || hexo.theme.config['swpp']?.enable))
36
+ if (!(config['swpp']?.enable || config.theme_config['swpp']?.enable))
37
37
  return;
38
38
  const themeName = config.theme;
39
39
  swpp_backends_1.default.event.addRulesMapEvent(rules => {
@@ -141,7 +141,11 @@ function buildServiceWorker(hexo) {
141
141
  // noinspection HtmlUnknownTarget
142
142
  hexo.extend.injector.register('body_begin', () => `<script src="/sw-dom.js"></script>`);
143
143
  hexo.extend.generator.register('build_dom_js', () => {
144
- const template = fs.readFileSync(path_1.default.resolve('./', 'node_modules/swpp-backends/dist/resources/sw-dom.js'), 'utf-8').replaceAll(`// \${onSuccess}`, `(${pluginConfig.dom.onsuccess.toString()})()`);
144
+ const onsuccess = pluginConfig.dom.onsuccess;
145
+ let template = fs.readFileSync(path_1.default.resolve('./', 'node_modules/swpp-backends/dist/resources/sw-dom.js'), 'utf-8');
146
+ // @ts-ignore
147
+ if (onsuccess)
148
+ template = template.replaceAll(`// \${onSuccess}`, `(${pluginConfig.dom.onsuccess.toString()})()`);
145
149
  return {
146
150
  path: 'sw-dom.js',
147
151
  data: template
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-swpp",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "files": [