lavas-project / hexo-pwa Goto Github PK
View Code? Open in Web Editor NEWHexo PWA plugin
License: MIT License
Hexo PWA plugin
License: MIT License
Hi;
I know it's probably more a question for sw team but, just in case you know how and/or you already have a trick for me
Do you know how I could exclude ressource/script ?
because I have a quota exceeded error when I use your plugins with disqus
so I would like to understand how to exlude disqus js
I also found this
如题。
具体表现为每次刷新访客数(UV)都+1;
经过测试安卓系统复现,ios系统无此问题。
问题地址:https://lruihao.cn/docs/
Plugin is dumping out above error please have a look at it
The root cause is that
@mystic-cg
Locals.cache
should only be considered as an Internal private API. After c6e6e6b#diff-8706ed85bcc456bc4bd99698f3cb949dR7 theLocals.cache
is nowLocals.cache.cache
.According to Hexo API's documents, there is already a method called
Locals.toObject()
. The developer should always using public API for consistency. Please open an issue athexo-pwa
and asking them for usingLocals.toObject()
instead ofLocals.cache
.Related issue: tea3/hexo-related-popular-posts#23
After upgrading 4.2.0, it caused that generating html with hexo-pwa is failed #4044
hexojs/hexo#4044
manifest.json and sw.js are not being generated.
Use hexo clean
found a bug:
$ hexo clean
FATAL YAMLException: unknown tag !<tag:yaml.org,2002:js/regexp> (153:44)
150 | ...
151 | ... TimeoutSeconds: 5
152 | ...
153 | ... rn: !!js/regexp /hm.baidu.com/
------------------------------------------^
154 | ... egy: networkOnly
155 | ... rn: !!js/regexp /.*\.(js|css|jpg|jpeg|png|gif)$/
at generateError (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:183:10)
at throwError (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:187:9)
at composeNode (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1521:7)
at readBlockMapping (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1164:11)
at composeNode (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1441:12)
at readBlockSequence (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1008:5)
at composeNode (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1440:12)
at readBlockMapping (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1164:11)
at composeNode (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1441:12)
at readBlockMapping (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1164:11)
at composeNode (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1441:12)
at readBlockMapping (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1164:11)
at composeNode (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1441:12)
at readDocument (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1625:3)
at loadDocuments (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1688:5)
at Object.load (D:\hexo\myblog\node_modules\js-yaml\lib\loader.js:1714:19)
at Hexo.yamlHelper (D:\hexo\myblog\node_modules\hexo\lib\plugins\renderer\yaml.js:7:15)
at Hexo.tryCatcher (D:\hexo\myblog\node_modules\bluebird\js\release\util.js:16:23)
at Hexo.<anonymous> (D:\hexo\myblog\node_modules\bluebird\js\release\method.js:15:34)
at D:\hexo\myblog\node_modules\hexo\lib\hexo\render.js:81:22
at tryCatcher (D:\hexo\myblog\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\hexo\myblog\node_modules\bluebird\js\release\promise.js:547:31) {
reason: 'unknown tag !<tag:yaml.org,2002:js/regexp>',
mark: {
name: null,
buffer: '# Hexo Configuration\n' +
'## Docs: https://hexo.io/docs/configuration.html\n' +
'## Source: https://github.com/hexojs/hexo/\n' +
'\n' +
'# Site\n' +
"title: QuestionMark001's Blog\n" +
"subtitle: 'Be thankful and be gentle.'\n" +
"description: 'QuestionMark001的个人博客'\n" +
'keywords: 个人博客,Linux,GitHub,C,python,Go,C#,C++,Java,HTML5,NodeJs,Hexo,VueJs\n' +
'author: QuestionMark001-向阳菌\n' +
'language: zh-CN\n' +
"timezone: ''\n" +
'\n' +
'# URL\n' +
"## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'\n" +
'url: https://questionmark001.github.io\n' +
'permalink: :year/:month/:day/:title/\n' +
'permalink_defaults:\n' +
'pretty_urls:\n' +
" trailing_index: true # Set to false to remove trailing 'index.html' from permalinks\n" +
" trailing_html: true # Set to false to remove trailing '.html' from permalinks\n" +
'\n' +
'# Directory\n' +
'source_dir: source\n' +
'public_dir: public\n' +
'tag_dir: tags\n' +
'archive_dir: archives\n' +
'category_dir: categories\n' +
'code_dir: downloads/code\n' +
'i18n_dir: :lang\n' +
'skip_render:\n' +
' - "wechat/*"\n' +
'\n' +
'# Writing\n' +
'new_post_name: :title.md # File name of new posts\n' +
'default_layout: post\n' +
'titlecase: false # Transform title into titlecase\n' +
'external_link:\n' +
' enable: true # Open external links in new tab\n' +
' field: site # Apply to the whole site\n' +
" exclude: ''\n" +
'filename_case: 0\n' +
'render_drafts: false\n' +
'post_asset_folder: false\n' +
'relative_link: false\n' +
'future: true\n' +
'highlight:\n' +
' enable: true\n' +
' line_number: true\n' +
' auto_detect: false\n' +
" tab_replace: ''\n" +
' wrap: true\n' +
' hljs: false\n' +
'prismjs:\n' +
' enable: false\n' +
' preprocess: true\n' +
' line_number: true\n' +
" tab_replace: ''\n" +
'\n' +
'# Home page setting\n' +
"# path: Root path for your blogs index page. (default = '')\n" +
'# per_page: Posts displayed per page. (0 = disable pagination)\n' +
'# order_by: Posts order. (Order by date descending by default)\n' +
'index_generator:\n' +
" path: ''\n" +
' per_page: 10\n' +
' order_by: -date\n' +
'\n' +
'# Category & Tag\n' +
'default_category: uncategorized\n' +
'category_map:\n' +
'tag_map:\n' +
'\n' +
'# Metadata elements\n' +
'## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta\n' +
'meta_generator: true\n' +
'\n' +
'# Date / Time format\n' +
'## Hexo uses Moment.js to parse and display date\n' +
'## You can customize the date format as defined in\n' +
'## http://momentjs.com/docs/#/displaying/format/\n' +
'date_format: YYYY-MM-DD\n' +
'time_format: HH:mm:ss\n' +
"## updated_option supports 'mtime', 'date', 'empty'\n" +
"updated_option: 'mtime'\n" +
'\n' +
'# Pagination\n' +
'## Set per_page to 0 to disable pagination\n' +
'per_page: 10\n' +
'pagination_dir: page\n' +
'\n' +
'# Include / Exclude file(s)\n' +
"## include:/exclude: options only apply to the 'source/' folder\n" +
'include:\n' +
'exclude:\n' +
'ignore:\n' +
'\n' +
'# Extensions\n' +
'## Plugins: https://hexo.io/plugins/\n' +
'## Themes: https://hexo.io/themes/\n' +
'theme: stun\n' +
'\n' +
'# Deployment\n' +
'## Docs: https://hexo.io/docs/one-command-deployment\n' +
'deploy:\n' +
" type: 'git'\n" +
' repository: [email protected]:QuestionMark001/QuestionMark001.github.io.git\n' +
' branch: main\n' +
'\n' +
'# Feed\n' +
'feed:\n' +
' enable: true\n' +
' type: atom\n' +
' path: atom.xml\n' +
' limit: 20\n' +
' hub:\n' +
' content:\n' +
' content_limit: 140\n' +
" content_limit_delim: ' '\n" +
' order_by: -date\n' +
' icon: icon.png\n' +
' autodiscovery: true\n' +
' template:\n' +
'\n' +
'# Pwa\n' +
'pwa:\n' +
' manifest:\n' +
' path: /manifest.json\n' +
' body:\n' +
` "name": "QuestionMark001's Blog"\n` +
' "short_name": "QuestionMark001"\n' +
' "theme_color": "rgba(203,7,83,0.86)"\n' +
' "background_color": "#ffffff"\n' +
' "display": "standalone"\n' +
' "Scope": "/"\n' +
' "start_url": "/"\n' +
' icons:\n' +
' - src: /android-chrome-192x192.png\n' +
' sizes: 192x192\n' +
' type: image/png\n' +
' - src: /android-chrome-512x512.png\n' +
' sizes: 512x512\n' +
' type: image/png\n' +
' serviceWorker:\n' +
' path: /sw.js\n' +
' preload:\n' +
' urls:\n' +
' - /\n' +
' posts: 5\n' +
' opts:\n' +
' networkTimeoutSeconds: 5\n' +
' routes:\n' +
' - pattern: !!js/regexp /hm.baidu.com/\n' +
' strategy: networkOnly\n' +
' - pattern: !!js/regexp /.*\\.(js|css|jpg|jpeg|png|gif)$/\n' +
' strategy: cacheFirst\n' +
' - pattern: !!js/regexp /\\//\n' +
' strategy: networkFirst\n' +
' priority: 5\n',
position: 3579,
line: 152,
column: 43,
snippet: ' 150 | ... \n' +
' 151 | ... TimeoutSeconds: 5\n' +
' 152 | ... \n' +
' 153 | ... rn: !!js/regexp /hm.baidu.com/\n' +
'------------------------------------------^\n' +
' 154 | ... egy: networkOnly\n' +
' 155 | ... rn: !!js/regexp /.*\\.(js|css|jpg|jpeg|png|gif)$/'
}
}
He works great, but the only problem is that the console has been outputting such errors, do you know why?
/sw.js?t=1515437173661:14 Uncaught (in promise) TypeError: Request scheme 'chrome-extension' is unsupported at /sw.js?t=1515437173661:14 at <anonymous>
pwa插件生成的sw.js和manifest文件,通过一个选项设置其中两个文件的src前缀,这样我就可以cdn引用,谢谢
我设置了manifest.json
{
"name": "Jerryc",
"short_name": "JerryC",
"theme_color": "#3f51b5",
"background_color": "#3f51b5",
"display": "fullscreen",
"Scope": "/",
"start_url": "/",
"icons": [
{
"src": "img/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "img/icons/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "img/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "img/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "img/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "img/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "img/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "img/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"splash_pages": null
}
_CONFIG 也设置了
pwa:
manifest:
path: /manifest.json
body:
# name: Jerryc
# short_name: Jerryc
# icons:
# - src: img/icons/icon-192x192.png
# sizes: 192x192
# type: image/png
serviceWorker:
path: /sw.js
preload:
urls:
- /
posts: 5
opts:
networkTimeoutSeconds: 5
routes:
- pattern: !!js/regexp /hm.baidu.com/
strategy: networkOnly
- pattern: !!js/regexp /.*\.(js|css|jpg|jpeg|png|gif)$/
strategy: cacheFirst
- pattern: !!js/regexp /\//
strategy: networkFirst
priority: 5
但是不起作用。
我是不是漏了什么步骤
Jerryc.me
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.