refactor(schema): specs to schema

pull/588/head
ppoffice 2019-12-24 18:05:37 -05:00
parent 44b3603384
commit bb8d05bbed
61 changed files with 769 additions and 68 deletions

View File

@ -40,6 +40,7 @@
"ignore": [ "ignore": [
"class", "class",
"onclick", "onclick",
"onload",
"onsubmit" "onsubmit"
] ]
} }

View File

@ -53,6 +53,12 @@ module.exports = function(hexo) {
if (_package === 'clipboard') { if (_package === 'clipboard') {
_package = 'clipboard.js'; _package = 'clipboard.js';
} }
if (_package === 'disqusjs') {
provider = 'jsdelivr';
}
if (_package === 'katex') {
_package = 'KaTeX.js';
}
} }
if (provider !== null && provider in cdn_providers) { if (provider !== null && provider in cdn_providers) {
provider = cdn_providers[provider]; provider = cdn_providers[provider];

View File

@ -8,7 +8,7 @@
"type": "string", "type": "string",
"const": "changyan" "const": "changyan"
}, },
"appid": { "app_id": {
"type": "string", "type": "string",
"description": "Changyan app ID" "description": "Changyan app ID"
}, },
@ -19,7 +19,7 @@
}, },
"required": [ "required": [
"type", "type",
"appid", "app_id",
"conf" "conf"
] ]
} }

View File

@ -12,7 +12,7 @@
"type": "string", "type": "string",
"description": "Disqus shortname" "description": "Disqus shortname"
}, },
"apiKey": { "api_key": {
"description": "Disqus application API key", "description": "Disqus application API key",
"anyOf": [ "anyOf": [
{ {
@ -36,7 +36,7 @@
"type": "string", "type": "string",
"description": "Disqus moderator username" "description": "Disqus moderator username"
}, },
"adminLabel": { "admin_label": {
"type": "string", "type": "string",
"description": "Disqus moderator badge text", "description": "Disqus moderator badge text",
"default": false "default": false
@ -50,6 +50,6 @@
"required": [ "required": [
"type", "type",
"shortname", "shortname",
"apiKey" "api_key"
] ]
} }

View File

@ -8,11 +8,11 @@
"type": "string", "type": "string",
"const": "gitalk" "const": "gitalk"
}, },
"clientId": { "client_id": {
"type": "string", "type": "string",
"description": "GitHub application client ID" "description": "GitHub application client ID"
}, },
"clientSecret": { "client_secret": {
"type": "string", "type": "string",
"description": "GitHub application client secret" "description": "GitHub application client secret"
}, },
@ -31,22 +31,22 @@
"type": "string" "type": "string"
} }
}, },
"perPage": { "per_page": {
"type": "number", "type": "number",
"description": "Pagination size, with maximum 100", "description": "Pagination size, with maximum 100",
"default": 10 "default": 10
}, },
"distractionFreeMode": { "distraction_free_mode": {
"type": "boolean", "type": "boolean",
"description": "Facebook-like distraction free mode", "description": "Facebook-like distraction free mode",
"default": false "default": false
}, },
"pagerDirection": { "pager_direction": {
"type": "string", "type": "string",
"description": "Comment sorting direction, available values are `last` and `first`", "description": "Comment sorting direction, available values are `last` and `first`",
"default": "last" "default": "last"
}, },
"createIssueManually": { "create_issue_manually": {
"type": "boolean", "type": "boolean",
"description": "Create GitHub issues manually for each page", "description": "Create GitHub issues manually for each page",
"default": false "default": false
@ -55,11 +55,11 @@
"type": "string", "type": "string",
"description": "GitHub oauth request reverse proxy for CORS" "description": "GitHub oauth request reverse proxy for CORS"
}, },
"flipMoveOptions": { "flip_move_options": {
"type": "object", "type": "object",
"description": "Comment list animation" "description": "Comment list animation"
}, },
"enableHotKey": { "enable_hotkey": {
"type": "boolean", "type": "boolean",
"description": "Enable hot key (cmd|ctrl + enter) submit comment", "description": "Enable hot key (cmd|ctrl + enter) submit comment",
"default": true "default": true
@ -67,8 +67,8 @@
}, },
"required": [ "required": [
"type", "type",
"clientId", "client_id",
"clientSecret", "client_secret",
"repo", "repo",
"owner", "owner",
"admin" "admin"

View File

@ -16,11 +16,11 @@
"type": "string", "type": "string",
"description": "The repository to store your comments. Make sure you're repo's owner" "description": "The repository to store your comments. Make sure you're repo's owner"
}, },
"clientId": { "client_id": {
"type": "string", "type": "string",
"description": "GitHub client ID" "description": "GitHub client ID"
}, },
"clientSecret": { "client_secret": {
"type": "string", "type": "string",
"description": "GitHub client secret" "description": "GitHub client secret"
}, },
@ -29,12 +29,12 @@
"description": "An optional Gitment theme object", "description": "An optional Gitment theme object",
"default": "gitment.defaultTheme" "default": "gitment.defaultTheme"
}, },
"perPage": { "per_page": {
"type": "number", "type": "number",
"description": "An optional number to which comments will be paginated", "description": "An optional number to which comments will be paginated",
"default": 20 "default": 20
}, },
"maxCommentHeight": { "max_comment_height": {
"type": "number", "type": "number",
"description": "An optional number to limit comments' max height, over which comments will be folded", "description": "An optional number to limit comments' max height, over which comments will be folded",
"default": 250 "default": 250
@ -44,7 +44,7 @@
"type", "type",
"owner", "owner",
"repo", "repo",
"clientId", "client_id",
"clientSecret" "client_secret"
] ]
} }

View File

@ -8,13 +8,13 @@
"type": "string", "type": "string",
"const": "livere" "const": "livere"
}, },
"url": { "uid": {
"type": "string", "type": "string",
"description": "LiveRe comment service UID" "description": "LiveRe comment service UID"
} }
}, },
"required": [ "required": [
"type", "type",
"url" "uid"
] ]
} }

View File

@ -8,11 +8,11 @@
"type": "string", "type": "string",
"const": "valine" "const": "valine"
}, },
"appId": { "app_id": {
"type": "string", "type": "string",
"description": "Application <APP_ID> from Leancloud" "description": "Application <APP_ID> from Leancloud"
}, },
"appKey": { "app_key": {
"type": "string", "type": "string",
"description": "Application <APP_KEY> from Leancloud" "description": "Application <APP_KEY> from Leancloud"
}, },
@ -46,7 +46,7 @@
], ],
"default": "mm" "default": "mm"
}, },
"avatarForce": { "avatar_force": {
"type": "boolean", "type": "boolean",
"description": "Pull the latest avatar upon page visit", "description": "Pull the latest avatar upon page visit",
"default": false "default": false
@ -63,7 +63,7 @@
"link" "link"
] ]
}, },
"pageSize": { "page_size": {
"type": "integer", "type": "integer",
"description": "Number of comments per page", "description": "Number of comments per page",
"default": 10 "default": 10
@ -78,7 +78,7 @@
"description": "Enable code highlighting", "description": "Enable code highlighting",
"default": true "default": true
}, },
"recordIP": { "record_ip": {
"type": "boolean", "type": "boolean",
"description": "Record reviewer IP address", "description": "Record reviewer IP address",
"default": false "default": false
@ -86,7 +86,7 @@
}, },
"required": [ "required": [
"type", "type",
"appId", "app_id",
"appKey" "app_key"
] ]
} }

View File

@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/donate/alipay.json",
"description": "Alipay donate button configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "alipay"
},
"qrcode": {
"type": "string",
"description": "Alipay qrcode image URL"
}
},
"required": [
"type",
"qrcode"
]
}

View File

@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/donate/buymeacoffee.json",
"description": "\"Buy me a coffee\" donate button configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "patreon"
},
"url": {
"type": "string",
"description": "URL to the \"Buy me a coffee\" page"
}
},
"required": [
"type",
"url"
]
}

View File

@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/donate/patreon.json",
"description": "Patreon donate button configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "patreon"
},
"url": {
"type": "string",
"description": "URL to the Patreon page"
}
},
"required": [
"type",
"url"
]
}

View File

@ -0,0 +1,25 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/donate/paypal.json",
"description": "Paypal donate button configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "paypal"
},
"business": {
"type": "string",
"description": "Paypal business ID or email address"
},
"currency_code": {
"type": "string",
"description": "Currency code"
}
},
"required": [
"type",
"business",
"currencyCode"
]
}

View File

@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/donate/wechat.json",
"description": "Wechat donate button configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "wechat"
},
"qrcode": {
"type": "string",
"description": "Wechat qrcode image URL"
}
},
"required": [
"type",
"qrcode"
]
}

View File

@ -0,0 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/misc/meta.json",
"description": "Additional HTML meta tags in an array",
"type": "array",
"items": {
"type": "string",
"description": "Meta tag specified in <attribute>=<value> style\nE.g., name=theme-color;content=#123456 => <meta name=\"theme-color\" content=\"#123456\">"
}
}

View File

@ -0,0 +1,63 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/misc/open_graph.json",
"description": "Open Graph metadata\nhttps://hexo.io/docs/helpers.html#open-graph",
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Page title (og:title)"
},
"type": {
"type": "string",
"description": "Page type (og:type)",
"default": "blog"
},
"url": {
"type": "string",
"description": "Page URL (og:url)"
},
"image": {
"type": [
"string",
"array"
],
"description": "Page cover (og:image)",
"items": {
"type": "string"
}
},
"site_name": {
"type": "string",
"description": "Site name (og:site_name)"
},
"description": {
"type": "string",
"description": "Page description (og:description)"
},
"twitter_card": {
"type": "string",
"description": "Twitter card type (twitter:card)"
},
"twitter_id": {
"type": "string",
"description": "Twitter ID (twitter:creator)"
},
"twitter_site": {
"type": "string",
"description": "Twitter ID (twitter:creator)"
},
"google_plus": {
"type": "string",
"description": "Google+ profile link (deprecated)"
},
"fb_admins": {
"type": "string",
"description": "Facebook admin ID"
},
"fb_app_id": {
"type": "string",
"description": "Facebook App ID"
}
}
}

View File

@ -0,0 +1,40 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/misc/poly_links.json",
"description": "A polymorphic link",
"type": "object",
"patternProperties": {
".+": {
"type": [
"string",
"object"
],
"description": "URL or path of the link, with/without the icon element class name",
"properties": {
"url": {
"type": "string",
"description": "URL or path of the link"
},
"icon": {
"type": "string",
"description": "Icon element class name"
}
},
"required": [
"url",
"icon"
]
}
},
"examples": [
{
"My GitHub Page": "https://github.com/ppoffice"
},
{
"My GitHub Page": {
"url": "https://github.com/ppoffice",
"icon": "fab fa-github"
}
}
]
}

View File

@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/animejs.json",
"description": "Enable page startup animations",
"type": "boolean",
"default": true
}

View File

@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/back_to_top.json",
"description": "Show the \"back to top\" button",
"type": "boolean",
"default": true
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/baidu_analytics.json",
"description": "Baidu Analytics plugin settings\nhttps://tongji.baidu.com",
"type": "object",
"properties": {
"tracking_id": {
"type": "object",
"description": "Baidu Analytics tracking ID"
}
},
"required": [
"tracking_id"
]
}

View File

@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/busuanzi.json",
"description": "BuSuanZi site/page view counter\nhttps://busuanzi.ibruce.info",
"type": "boolean",
"default": false
}

View File

@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/gallery.json",
"description": "Enable the lightGallery and Justified Gallery plugins\nhttps://ppoffice.github.io/hexo-theme-icarus/Plugins/General/gallery-plugin/",
"type": "boolean",
"default": true
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/google_analytics.json",
"description": "Google Analytics plugin settings\nhttps://analytics.google.com",
"type": "object",
"properties": {
"tracking_id": {
"type": "object",
"description": "Google Analytics tracking ID"
}
},
"required": [
"tracking_id"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/hotjar.json",
"description": "Hotjar user feedback plugin\nhttps://www.hotjar.com/",
"type": "object",
"properties": {
"site_id": {
"type": [
"string",
"number"
],
"description": "Hotjar site id"
}
}
}

View File

@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/katex.json",
"description": "Enable the KaTeX math typesetting supprot\nhttps://katex.org/",
"type": "boolean",
"default": false
}

View File

@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/mathjax.json",
"description": "Enable the MathJax math typesetting support\nhttps://www.mathjax.org/",
"type": "boolean",
"default": false
}

View File

@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/outdated_browser.json",
"description": "Enable the Outdated Browser plugin\nhttp://outdatedbrowser.com/",
"type": "boolean",
"default": true
}

View File

@ -0,0 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/plugin/progressbar.json",
"description": "Show a progress bar at top of the page on page loading",
"type": "boolean",
"default": true
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/search/baidu.json",
"description": "Enable Baidu search",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "baidu"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/search/google_cse.json",
"description": "Enable Google CSE\nhttps://cse.google.com/cse/create/new",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "google_cse"
},
"cx": {
"type": "string",
"description": "Google CSE cx value"
}
},
"required": [
"type",
"cx"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/search/insight.json",
"description": "Enable Insight search\nhttps://ppoffice.github.io/hexo-theme-icarus/Plugins/Search/insight-search-plugin/",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "insight"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/share/addthis.json",
"description": "Enable AddThis share buttons\nhttps://www.addthis.com/",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "addthis"
},
"install_url": {
"type": "string",
"description": "URL to the AddThis share plugin script"
}
},
"required": [
"type",
"install_url"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/share/addtoany.json",
"description": "Enable AddToAny share buttons\nhttps://www.addtoany.com/",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "addtoany"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/share/bdshare.json",
"description": "Enable Baidu share buttons",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "bdshare"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/share/sharejs.json",
"description": "Enable Share.js share buttons\nhttps://github.com/overtrue/share.js/",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "sharejs"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/share/sharethis.json",
"description": "Enable ShareThis share buttons\nhttps://sharethis.com/",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "sharethis"
},
"install_url": {
"type": "string",
"description": "URL to the ShareThis share plugin script"
}
},
"required": [
"type",
"install_url"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/archives.json",
"description": "Archives widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "archives"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/categories.json",
"description": "Categories widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "categories"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,25 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/links.json",
"description": "Recommendation links widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "links"
},
"links": {
"type": "object",
"description": "Names and URLs of the sites",
"patternProperties": {
".+": {
"type": "string",
"description": "URL of the site"
}
}
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,43 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/profile.json",
"description": "Profile widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "profile"
},
"author": {
"type": "string",
"description": "Author name"
},
"author_title": {
"type": "string",
"description": "Author title"
},
"location": {
"type": "string",
"description": "Author's current location"
},
"avatar": {
"type": "string",
"description": "URL or path to the avatar image"
},
"gravatar": {
"type": "string",
"description": "Email address for the Gravatar"
},
"follow_link": {
"type": "string",
"description": "URL or path for the follow button"
},
"social_links": {
"$ref": "/misc/poly_links.json",
"description": "Links to be shown on the bottom of the profile widget"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/recent_posts.json",
"description": "Recent posts widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "recent_posts"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,24 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/subscribe_email.json",
"description": "Google FeedBurner email subscription widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "subscribe_email"
},
"description": {
"type": "string",
"description": "Hint text under the email input"
},
"feedburner_id": {
"type": "string",
"description": "Feedburner ID"
}
},
"required": [
"type",
"feedburner_id"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/tags.json",
"description": "Tags widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "tags"
}
},
"required": [
"type"
]
}

View File

@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/toc.json",
"description": "Table of contents widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "toc"
}
},
"required": [
"type"
]
}

View File

@ -34,6 +34,7 @@ donate:
wechat: 'Wechat' wechat: 'Wechat'
paypal: 'Paypal' paypal: 'Paypal'
patreon: 'Patreon' patreon: 'Patreon'
buymeacoffee: 'Buy me a coffee'
plugin: plugin:
backtotop: 'Back to Top' backtotop: 'Back to Top'
visit: '%s visits' visit: '%s visits'

View File

@ -29,6 +29,7 @@ donate:
title: '喜欢这篇文章?打赏一下作者吧' title: '喜欢这篇文章?打赏一下作者吧'
alipay: '支付宝' alipay: '支付宝'
wechat: '微信' wechat: '微信'
buymeacoffee: '送我杯咖啡'
plugin: plugin:
backtotop: '回到顶端' backtotop: '回到顶端'
visit: '%s次访问' visit: '%s次访问'

View File

@ -6,7 +6,7 @@ class ChangeYan extends Component {
const { appId, conf, path } = this.props; const { appId, conf, path } = this.props;
if (!appId || !conf) { if (!appId || !conf) {
return <div class="notification is-danger"> return <div class="notification is-danger">
You forgot to set the <code>appid</code> or <code>conf</code> for Changyan. You forgot to set the <code>app_id</code> or <code>conf</code> for Changyan.
Please set it in <code>_config.yml</code>. Please set it in <code>_config.yml</code>.
</div>; </div>;
} }
@ -23,7 +23,7 @@ module.exports = cacheComponent(ChangeYan, 'comment.changyan', props => {
const { comment, page } = props; const { comment, page } = props;
return { return {
appId: comment.appid, appId: comment.app_id,
conf: comment.conf, conf: comment.conf,
path: page.path path: page.path
}; };

View File

@ -20,7 +20,7 @@ class DisqusJs extends Component {
} = this.props; } = this.props;
if (!shortname) { if (!shortname) {
return <div class="notification is-danger"> return <div class="notification is-danger">
You forgot to set the <code>shortname</code> or <code>apiKey</code> for Disqus. You forgot to set the <code>shortname</code> or <code>api_key</code> for Disqus.
Please set it in <code>_config.yml</code>. Please set it in <code>_config.yml</code>.
</div>; </div>;
} }
@ -53,10 +53,10 @@ module.exports = cacheComponent(DisqusJs, 'comment.disqusjs', props => {
return { return {
path: page.path, path: page.path,
shortname: comment.shortname, shortname: comment.shortname,
apiKey: comment.apiKey, apiKey: comment.api_key,
api: comment.api, api: comment.api,
admin: comment.admin, admin: comment.admin,
adminLabel: comment.adminLabel, adminLabel: comment.admin_label,
nesting: comment.nesting, nesting: comment.nesting,
disqusId: page.disqusId, disqusId: page.disqusId,
permalink: page.permalink, permalink: page.permalink,

View File

@ -64,15 +64,15 @@ module.exports = cacheComponent(Gitalk, 'comment.gitalk', props => {
repo: comment.repo, repo: comment.repo,
owner: comment.owner, owner: comment.owner,
admin: comment.admin, admin: comment.admin,
clientId: comment.clientId, clientId: comment.client_id,
clientSecret: comment.clientSecret, clientSecret: comment.client_secret,
createIssueManually: comment.createIssueManually, createIssueManually: comment.create_issue_manually,
distractionFreeMode: comment.distractionFreeMode, distractionFreeMode: comment.distraction_free_mode,
pagerDirection: comment.pagerDirection, pagerDirection: comment.pager_direction,
perPage: comment.perPage, perPage: comment.per_page,
proxy: comment.proxy, proxy: comment.proxy,
flipMoveOptions: comment.flipMoveOptions, flipMoveOptions: comment.flip_move_options,
enableHotKey: comment.enableHotKey, enableHotKey: comment.enable_hotkey,
cssUrl: helper.cdn('gitalk', '1.4.1', 'dist/gitalk.css'), cssUrl: helper.cdn('gitalk', '1.4.1', 'dist/gitalk.css'),
jsUrl: helper.cdn('gitalk', '1.4.1', 'dist/gitalk.min.js') jsUrl: helper.cdn('gitalk', '1.4.1', 'dist/gitalk.min.js')
}; };

View File

@ -50,9 +50,9 @@ module.exports = cacheComponent(Gitment, 'comment.gitment', props => {
id, id,
repo: comment.repo, repo: comment.repo,
owner: comment.owner, owner: comment.owner,
clientId: comment.clientId, clientId: comment.client_id,
clientSecret: comment.clientSecret, clientSecret: comment.client_secret,
perPage: comment.perPage, perPage: comment.per_page,
maxCommentHeight: comment.maxCommentHeight maxCommentHeight: comment.max_comment_height
}; };
}); });

View File

@ -15,7 +15,8 @@ class Valine extends Component {
pageSize = 10, pageSize = 10,
visitor = false, visitor = false,
highlight = true, highlight = true,
recordIP = false recordIp = false,
jsUrl
} = this.props; } = this.props;
if (!appId || !appKey) { if (!appId || !appKey) {
return <div class="notification is-danger"> return <div class="notification is-danger">
@ -36,19 +37,19 @@ class Valine extends Component {
pageSize: ${pageSize}, pageSize: ${pageSize},
visitor: ${visitor}, visitor: ${visitor},
highlight: ${highlight}, highlight: ${highlight},
recordIP: ${recordIP} recordIP: ${recordIp}
});`; });`;
return <Fragment> return <Fragment>
<div id="valine-thread" class="content"></div> <div id="valine-thread" class="content"></div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script> <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='//unpkg.com/valine/dist/Valine.min.js'></script> <script src={jsUrl}></script>
<script dangerouslySetInnerHTML={{ __html: js }}></script> <script dangerouslySetInnerHTML={{ __html: js }}></script>
</Fragment>; </Fragment>;
} }
} }
module.exports = cacheComponent(Valine, 'comment.valine', props => { module.exports = cacheComponent(Valine, 'comment.valine', props => {
const { comment } = props; const { comment, helper } = props;
return { return {
appId: comment.app_id, appId: comment.app_id,
@ -57,11 +58,12 @@ module.exports = cacheComponent(Valine, 'comment.valine', props => {
verify: comment.verify, verify: comment.verify,
placeholder: comment.placeholder, placeholder: comment.placeholder,
avatar: comment.avatar, avatar: comment.avatar,
avatarForce: comment.avatarForce, avatarForce: comment.avatar_force,
meta: comment.meta, meta: comment.meta,
pageSize: comment.pageSize, pageSize: comment.page_size,
visitor: comment.visitor, visitor: comment.visitor,
highlight: comment.highlight, highlight: comment.highlight,
recordIP: comment.recordIP recordIp: comment.record_ip,
jsUrl: helper.cdn('valine', '1.3.10', 'dist/Valine.min.js')
}; };
}); });

View File

@ -33,7 +33,7 @@ module.exports = class extends Component {
</span>} </span>}
</div> : null} </div> : null}
{/* Metadata */} {/* Metadata */}
<div class={`card-content article${'direction' in page ? ' ' + page.direction : ''}`}> <div class={`card-content article${'direction' in page ? ' ' + page.direction : ''}`} role="article">
{page.layout !== 'page' ? <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto"> {page.layout !== 'page' ? <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
<div class="level-left"> <div class="level-left">
{/* Date */} {/* Date */}

View File

@ -79,18 +79,20 @@ module.exports = class extends Component {
<title>{getPageTitle(page, config.title, helper)}</title> <title>{getPageTitle(page, config.title, helper)}</title>
{open_graph ? <OpenGraph {open_graph ? <OpenGraph
type={is_post(page) ? 'article' : 'website'} type={open_graph.type || (is_post(page) ? 'article' : 'website')}
title={page.title || config.title} title={open_graph.title || page.title || config.title}
date={page.date} date={page.date}
updated={page.updated} updated={page.updated}
author={config.author} author={config.author}
description={page.description || page.excerpt || page.content || config.description} description={open_graph.description || page.description || page.excerpt || page.content || config.description}
keywords={page.keywords || (page.tags && page.tags.length ? page.tags : undefined) || config.keywords} keywords={page.keywords || (page.tags && page.tags.length ? page.tags : undefined) || config.keywords}
url={url} url={open_graph.url || url}
images={page.photos || images} images={open_graph.image || page.photos || images}
siteName={config.title} siteName={open_graph.site_name || config.title}
language={language} language={language}
twitterId={open_graph.twitter} twitterId={open_graph.twitter_id}
twitterCard={open_graph.twitter_card}
twitterSite={open_graph.twitter_site}
googlePlus={open_graph.google_plus} googlePlus={open_graph.google_plus}
facebookAdmins={open_graph.fb_admins} facebookAdmins={open_graph.fb_admins}
facebookAppId={open_graph.fb_app_id} /> : null} facebookAppId={open_graph.fb_app_id} /> : null}

View File

@ -0,0 +1,34 @@
const { Component } = require('inferno');
const { cacheComponent } = require('../util/cache');
class BuyMeACoffee extends Component {
render() {
const { title, url, url_for } = this.props;
if (!url) {
return <div class="notification is-danger">
You forgot to set the <code>url</code> for &quot;Buy me a coffee&quot;.
Please set it in <code>_config.yml</code>.
</div>;
}
return <a class="button donate" href={url_for(url)} style={{
'background-color': 'rgba(255,128,62,.87)',
'border-color': 'transparent',
'color': 'white'
}} target="_blank" rel="noopener">
<span class="icon is-small">
<i class="fas fa-coffee"></i>
</span>
<span>{title}</span>
</a>;
}
}
module.exports = cacheComponent(BuyMeACoffee, 'donate.buymeacoffee', props => {
const { donate, helper } = props;
return {
url: donate.url,
title: helper.__('donate.' + donate.type),
url_for: helper.url_for
};
});

View File

@ -6,7 +6,7 @@ class Patreon extends Component {
const { title, url, url_for } = this.props; const { title, url, url_for } = this.props;
if (!url) { if (!url) {
return <div class="notification is-danger"> return <div class="notification is-danger">
You forgot to set the <code>url</code> Patreon. You forgot to set the <code>url</code> for Patreon.
Please set it in <code>_config.yml</code>. Please set it in <code>_config.yml</code>.
</div>; </div>;
} }

View File

@ -3,7 +3,7 @@ const { cacheComponent } = require('../util/cache');
class Busuanzi extends Component { class Busuanzi extends Component {
render() { render() {
return <script src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async={true}></script>; return <script src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" defer={true}></script>;
} }
} }

33
layout/plugin/katex.jsx Normal file
View File

@ -0,0 +1,33 @@
const { Component, Fragment } = require('inferno');
const { cacheComponent } = require('../util/cache');
class KaTeX extends Component {
render() {
const { cssUrl, jsUrl, autoRenderUrl } = this.props;
const js = `document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll('[role="article"] > .content').forEach(function(element) {
renderMathInElement(element);
});
});`;
return <Fragment>
<link rel="stylesheet" href={cssUrl} />
<script src={jsUrl} defer={true}></script>
<script src={autoRenderUrl} defer={true}></script>
<script dangerouslySetInnerHTML={{ __html: js }}></script>
</Fragment>;
}
}
module.exports = cacheComponent(KaTeX, 'plugin.katex', props => {
const { head, helper } = props;
if (head) {
return null;
}
return {
jsUrl: helper.cdn('katex', '0.11.1', 'dist/katex.min.js'),
cssUrl: helper.cdn('katex', '0.11.1', 'dist/katex.min.css'),
autoRenderUrl: helper.cdn('katex', '0.11.1', 'dist/contrib/auto-render.min.js')
};
});

View File

@ -26,7 +26,7 @@ class Mathjax extends Component {
});`; });`;
return <Fragment> return <Fragment>
<script src={jsUrl} async={true}></script> <script src={jsUrl} defer={true}></script>
<script dangerouslySetInnerHTML={{ __html: js }}></script> <script dangerouslySetInnerHTML={{ __html: js }}></script>
</Fragment>; </Fragment>;
} }

View File

@ -12,7 +12,7 @@ class AddThis extends Component {
} }
return <Fragment> return <Fragment>
<div class="addthis_inline_share_toolbox"></div> <div class="addthis_inline_share_toolbox"></div>
<script src={installUrl} async={true}></script> <script src={installUrl} defer={true}></script>
</Fragment>; </Fragment>;
} }
} }

View File

@ -12,7 +12,7 @@ class AddToAny extends Component {
<a class="a2a_button_whatsapp"></a> <a class="a2a_button_whatsapp"></a>
<a class="a2a_button_reddit"></a> <a class="a2a_button_reddit"></a>
</div> </div>
<script src="https://static.addtoany.com/menu/page.js" async={true}></script> <script src="https://static.addtoany.com/menu/page.js" defer={true}></script>
</Fragment>; </Fragment>;
} }
} }

View File

@ -12,7 +12,7 @@ class ShareThis extends Component {
} }
return <Fragment> return <Fragment>
<div class="sharethis-inline-share-buttons"></div> <div class="sharethis-inline-share-buttons"></div>
<script src={installUrl} async={true}></script> <script src={installUrl} defer={true}></script>
</Fragment>; </Fragment>;
} }
} }