feat(layout): add elementary PWA support

This commit is contained in:
ppoffice 2020-10-03 22:13:31 -04:00
parent 8b3e744878
commit c40214d546
No known key found for this signature in database
GPG Key ID: B33335481CC0D498
4 changed files with 14 additions and 1 deletions

View File

@ -7,6 +7,7 @@ module.exports = hexo => {
require('hexo-component-inferno/lib/hexo/generator/insight')(hexo);
require('hexo-component-inferno/lib/hexo/generator/categories')(hexo);
require('hexo-component-inferno/lib/hexo/generator/category')(hexo);
require('hexo-component-inferno/lib/hexo/generator/manifest')(hexo);
require('hexo-component-inferno/lib/hexo/generator/tags')(hexo);
require('hexo-component-inferno/lib/hexo/helper/cdn')(hexo);
require('hexo-component-inferno/lib/hexo/helper/page')(hexo);

View File

@ -10,6 +10,9 @@
"default": "/img/favicon.svg",
"nullable": true
},
"manifest": {
"$ref": "/misc/manifest.json"
},
"open_graph": {
"$ref": "/misc/open_graph.json"
},

View File

@ -1,5 +1,6 @@
const { Component } = require('inferno');
const MetaTags = require('hexo-component-inferno/lib/view/misc/meta');
const WebApp = require('hexo-component-inferno/lib/view/misc/web_app');
const OpenGraph = require('hexo-component-inferno/lib/view/misc/open_graph');
const StructuredData = require('hexo-component-inferno/lib/view/misc/structured_data');
const Plugins = require('./plugins');
@ -40,6 +41,7 @@ module.exports = class extends Component {
} = config;
const {
meta = [],
manifest = {},
open_graph = {},
structured_data = {},
canonical_url = page.permalink,
@ -112,6 +114,13 @@ module.exports = class extends Component {
<title>{getPageTitle(page, config.title, helper)}</title>
<WebApp.Cacheable
helper={helper}
favicon={favicon}
icons={manifest.icons}
themeColor={manifest.theme_color}
name={manifest.name || config.title} />
{typeof open_graph === 'object' && open_graph !== null ? <OpenGraph
type={open_graph.type || (is_post(page) ? 'article' : 'website')}
title={open_graph.title || page.title || config.title}

View File

@ -35,7 +35,7 @@
},
"dependencies": {
"deepmerge": "^4.2.2",
"hexo-component-inferno": "^0.8.2",
"hexo-component-inferno": "^0.10.0",
"inferno": "^7.3.3",
"inferno-create-element": "^7.3.3",
"moment": "^2.22.2",