Skip to content

Commit

Permalink
feat(layout): add elementary PWA support
Browse files Browse the repository at this point in the history
  • Loading branch information
ppoffice committed Oct 4, 2020
1 parent 8b3e744 commit c40214d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions include/schema/common/head.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"default": "/img/favicon.svg",
"nullable": true
},
"manifest": {
"$ref": "/misc/manifest.json"
},
"open_graph": {
"$ref": "/misc/open_graph.json"
},
Expand Down
9 changes: 9 additions & 0 deletions layout/common/head.jsx
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -40,6 +41,7 @@ module.exports = class extends Component {
} = config;
const {
meta = [],
manifest = {},
open_graph = {},
structured_data = {},
canonical_url = page.permalink,
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

1 comment on commit c40214d

@ppoffice
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.