From cbb5bcb99260c82ff897ee5e108777c7fa394556 Mon Sep 17 00:00:00 2001 From: ppoffice Date: Tue, 24 Dec 2019 20:24:34 -0500 Subject: [PATCH] refactor(schema): all specs to schema --- include/schema/common/article.json | 44 ++++++ include/schema/common/comment.json | 35 +++++ include/schema/common/donates.json | 25 +++ include/schema/common/footer.json | 28 ++++ include/schema/common/head.json | 27 ++++ include/schema/common/navbar.json | 39 +++++ include/schema/common/plugins.json | 41 +++++ include/schema/common/providers.json | 23 +++ include/schema/common/search.json | 17 ++ include/schema/common/share.json | 23 +++ include/schema/common/sidebar.json | 30 ++++ include/schema/common/widgets.json | 36 +++++ include/schema/config.json | 68 ++++++++ include/schema/donate/paypal.json | 5 +- include/schema/plugin/outdated_browser.json | 2 +- include/schema/widget/links.json | 8 +- include/schema/widget/profile.json | 51 +++++- include/specs/article.spec.js | 35 ----- include/specs/comment.spec.js | 141 ----------------- include/specs/config.spec.js | 26 --- include/specs/donate.spec.js | 72 --------- include/specs/footer.spec.js | 24 --- include/specs/icon_link.spec.js | 20 --- include/specs/meta.spec.js | 66 -------- include/specs/navbar.spec.js | 31 ---- include/specs/plugins.spec.js | 68 -------- include/specs/providers.spec.js | 21 --- include/specs/search.spec.js | 17 -- include/specs/share.spec.js | 17 -- include/specs/sidebar.spec.js | 20 --- include/specs/widgets.spec.js | 166 -------------------- layout/common/head.jsx | 11 +- 32 files changed, 501 insertions(+), 736 deletions(-) create mode 100644 include/schema/common/article.json create mode 100644 include/schema/common/comment.json create mode 100644 include/schema/common/donates.json create mode 100644 include/schema/common/footer.json create mode 100644 include/schema/common/head.json create mode 100644 include/schema/common/navbar.json create mode 100644 include/schema/common/plugins.json create mode 100644 include/schema/common/providers.json create mode 100644 include/schema/common/search.json create mode 100644 include/schema/common/share.json create mode 100644 include/schema/common/sidebar.json create mode 100644 include/schema/common/widgets.json create mode 100644 include/schema/config.json delete mode 100644 include/specs/article.spec.js delete mode 100644 include/specs/comment.spec.js delete mode 100644 include/specs/config.spec.js delete mode 100644 include/specs/donate.spec.js delete mode 100644 include/specs/footer.spec.js delete mode 100644 include/specs/icon_link.spec.js delete mode 100644 include/specs/meta.spec.js delete mode 100644 include/specs/navbar.spec.js delete mode 100644 include/specs/plugins.spec.js delete mode 100644 include/specs/providers.spec.js delete mode 100644 include/specs/search.spec.js delete mode 100644 include/specs/share.spec.js delete mode 100644 include/specs/sidebar.spec.js delete mode 100644 include/specs/widgets.spec.js diff --git a/include/schema/common/article.json b/include/schema/common/article.json new file mode 100644 index 0000000..9918a57 --- /dev/null +++ b/include/schema/common/article.json @@ -0,0 +1,44 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/article.json", + "description": "Article related configurations", + "type": "object", + "properties": { + "highlight": { + "type": "object", + "description": "Code highlight settings", + "properties": { + "theme": { + "type": "string", + "description": "Code highlight themes\nhttps://github.com/highlightjs/highlight.js/tree/master/src/styles", + "default": "atom-one-light" + }, + "clipboard": { + "type": "string", + "description": "Show copy code button", + "default": true + }, + "fold": { + "type": "string", + "description": "Default folding status of the code blocks. Can be \"\", \"folded\", \"unfolded\"", + "enum": [ + "", + "folded", + "unfolded" + ], + "default": "unfolded" + } + } + }, + "thumbnail": { + "type": "boolean", + "description": "Whether to show thumbnail image for every article", + "default": true + }, + "readtime": { + "type": "boolean", + "description": "Whether to show estimated article reading time", + "default": true + } + } +} \ No newline at end of file diff --git a/include/schema/common/comment.json b/include/schema/common/comment.json new file mode 100644 index 0000000..bed0f9f --- /dev/null +++ b/include/schema/common/comment.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/comment.json", + "description": "Comment plugin configurations", + "type": "object", + "oneOf": [ + { + "$ref": "/comment/changyan.json" + }, + { + "$ref": "/comment/disqus.json" + }, + { + "$ref": "/comment/disqusjs.json" + }, + { + "$ref": "/comment/facebook.json" + }, + { + "$ref": "/comment/gitalk.json" + }, + { + "$ref": "/comment/gitment.json" + }, + { + "$ref": "/comment/isso.json" + }, + { + "$ref": "/comment/livere.json" + }, + { + "$ref": "/comment/valine.json" + } + ] +} \ No newline at end of file diff --git a/include/schema/common/donates.json b/include/schema/common/donates.json new file mode 100644 index 0000000..9ee9c2a --- /dev/null +++ b/include/schema/common/donates.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/donates.json", + "description": "Donate plugin configurations", + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "/donate/alipay.json" + }, + { + "$ref": "/donate/buymeacoffee.json" + }, + { + "$ref": "/donate/patreon.json" + }, + { + "$ref": "/donate/paypal.json" + }, + { + "$ref": "/donate/wechat.json" + } + ] + } +} \ No newline at end of file diff --git a/include/schema/common/footer.json b/include/schema/common/footer.json new file mode 100644 index 0000000..e322bc7 --- /dev/null +++ b/include/schema/common/footer.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/footer.json", + "description": "Page footer configurations", + "type": "object", + "properties": { + "links": { + "$ref": "/misc/poly_links.json", + "description": "Links to be shown on the right of the footer section", + "examples": [ + { + "Creative Commons": { + "icon": "fab fa-creative-commons", + "url": "https://creativecommons.org/" + }, + "Attribution 4.0 International": { + "icon": "fab fa-creative-commons-by", + "url": "https://creativecommons.org/licenses/by/4.0/" + }, + "Download on GitHub": { + "icon": "fab fa-github", + "url": "https://github.com/ppoffice/hexo-theme-icarus" + } + } + ] + } + } +} \ No newline at end of file diff --git a/include/schema/common/head.json b/include/schema/common/head.json new file mode 100644 index 0000000..8bbebce --- /dev/null +++ b/include/schema/common/head.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/footer.json", + "description": "Page metadata configurations", + "type": "object", + "properties": { + "favicon": { + "type": "string", + "description": "URL or path to the website's icon", + "default": "/images/favicon.svg" + }, + "canonical_url": { + "type": "string", + "description": "Canonical URL of the current page" + }, + "open_graph": { + "$ref": "/misc/open_graph.json" + }, + "meta": { + "$ref": "/misc/meta.json" + }, + "rss": { + "type": "string", + "description": "URL or path to the website's RSS atom.xml" + } + } +} \ No newline at end of file diff --git a/include/schema/common/navbar.json b/include/schema/common/navbar.json new file mode 100644 index 0000000..c37430b --- /dev/null +++ b/include/schema/common/navbar.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/footer.json", + "description": "Page top navigation bar configurations", + "type": "object", + "properties": { + "menu": { + "type": "object", + "description": "Naviagtion menu items", + "patternProperties": { + ".+": { + "type": "string", + "description": "URL or path of the menu link" + } + }, + "examples": [ + { + "Home": "/", + "Archives": "/archives", + "Categories": "/categories", + "Tags": "/tags", + "About": "/about" + } + ] + }, + "links": { + "$ref": "/misc/poly_links.json", + "description": "Links to be shown on the right of the navigation bar", + "examples": [ + { + "Download on GitHub": { + "icon": "fab fa-github", + "url": "https://github.com/ppoffice/hexo-theme-icarus" + } + } + ] + } + } +} \ No newline at end of file diff --git a/include/schema/common/plugins.json b/include/schema/common/plugins.json new file mode 100644 index 0000000..2482ae1 --- /dev/null +++ b/include/schema/common/plugins.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/plugins.json", + "description": "Plugin configurations", + "type": "object", + "properties": { + "animejs": { + "$ref": "/plugin/animejs.json" + }, + "back_to_top": { + "$ref": "/plugin/back_to_top.json" + }, + "baidu_analytics": { + "$ref": "/plugin/baidu_analytics.json" + }, + "busuanzi": { + "$ref": "/plugin/busuanzi.json" + }, + "gallery": { + "$ref": "/plugin/gallery.json" + }, + "google_analytics": { + "$ref": "/plugin/google_analytics.json" + }, + "hotjar": { + "$ref": "/plugin/hotjar.json" + }, + "katex": { + "$ref": "/plugin/katex.json" + }, + "mathjax": { + "$ref": "/plugin/mathjax.json" + }, + "outdated_browser": { + "$ref": "/plugin/outdated_browser.json" + }, + "progressbar": { + "$ref": "/plugin/progressbar.json" + } + } +} \ No newline at end of file diff --git a/include/schema/common/providers.json b/include/schema/common/providers.json new file mode 100644 index 0000000..6b3ee76 --- /dev/null +++ b/include/schema/common/providers.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/providers.json", + "description": "CDN provider settings\nhttps://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/speed-up-your-site-with-custom-cdn/", + "type": "object", + "properties": { + "cdn": { + "type": "string", + "description": "Name or URL template of the JavaScript and/or stylesheet CDN provider", + "default": "jsdelivr" + }, + "fontcdn": { + "type": "string", + "description": "Name or URL template of the webfont CDN provider", + "default": "google" + }, + "iconcdn": { + "type": "string", + "description": "Name or URL of the webfont Icon CDN provider", + "default": "fontawesome" + }, + } +} \ No newline at end of file diff --git a/include/schema/common/search.json b/include/schema/common/search.json new file mode 100644 index 0000000..b619b96 --- /dev/null +++ b/include/schema/common/search.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/search.json", + "description": "Search plugin configurations", + "type": "object", + "oneOf": [ + { + "$ref": "/search/baidu.json" + }, + { + "$ref": "/search/google_cse.json" + }, + { + "$ref": "/search/insight.json" + } + ] +} \ No newline at end of file diff --git a/include/schema/common/share.json b/include/schema/common/share.json new file mode 100644 index 0000000..7c4952d --- /dev/null +++ b/include/schema/common/share.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/share.json", + "description": "Share plugin configurations", + "type": "object", + "oneOf": [ + { + "$ref": "/share/addthis.json" + }, + { + "$ref": "/share/addtoany.json" + }, + { + "$ref": "/share/bdshare.json" + }, + { + "$ref": "/share/sharejs.json" + }, + { + "$ref": "/share/sharethis.json" + } + ] +} \ No newline at end of file diff --git a/include/schema/common/sidebar.json b/include/schema/common/sidebar.json new file mode 100644 index 0000000..9cce934 --- /dev/null +++ b/include/schema/common/sidebar.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/sidebar.json", + "description": "Sidebar configurations.\nPlease be noted that a sidebar is only visible when it has at least one widget", + "type": "object", + "properties": { + "left": { + "type": "object", + "description": "Left sidebar configurations", + "properties": { + "sticky": { + "type": "boolean", + "description": "Whether the sidebar sticks to the top when page scrolls", + "default": false + } + } + }, + "right": { + "type": "object", + "description": "Right sidebar configurations", + "properties": { + "sticky": { + "type": "boolean", + "description": "Whether the sidebar sticks to the top when page scrolls", + "default": false + } + } + } + } +} \ No newline at end of file diff --git a/include/schema/common/widgets.json b/include/schema/common/widgets.json new file mode 100644 index 0000000..46638fc --- /dev/null +++ b/include/schema/common/widgets.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/common/widgets.json", + "description": "Sidebar widget configurations", + "type": "array", + "items": { + "type": "object", + "properties": { + "position": { + "type": "string", + "description": "Where should the widget be placed, left sidebar or right sidebar", + "default": "left" + } + }, + "oneOf": [ + { + "$ref": "/widget/alipay.json" + }, + { + "$ref": "/widget/buymeacoffee.json" + }, + { + "$ref": "/widget/patreon.json" + }, + { + "$ref": "/widget/paypal.json" + }, + { + "$ref": "/widget/wechat.json" + } + ], + "required": [ + "position" + ] + } +} \ No newline at end of file diff --git a/include/schema/config.json b/include/schema/config.json new file mode 100644 index 0000000..1f79861 --- /dev/null +++ b/include/schema/config.json @@ -0,0 +1,68 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/config.json", + "description": "The configuration file definition", + "type": "object", + "properties": { + "version": { + "type": "string", + "description": "Version of the configuration file" + }, + "logo": { + "type": [ + "string", + "object" + ], + "description": "Path or URL to the website's logo", + "default": "/images/logo.svg", + "properties": { + "text": { + "type": "string", + "description": "Text to be shown in place of the logo image" + } + }, + "required": [ + "text" + ] + }, + "head": { + "$ref": "/common/head.json" + }, + "navbar": { + "$ref": "/common/navbar.json" + }, + "footer": { + "$ref": "/common/footer.json" + }, + "article": { + "$ref": "/common/article.json" + }, + "search": { + "$ref": "/common/search.json" + }, + "comment": { + "$ref": "/common/comment.json" + }, + "donates": { + "$ref": "/common/donates.json" + }, + "share": { + "$ref": "/common/share.json" + }, + "sidebar": { + "$ref": "/common/sidebar.json" + }, + "widgets": { + "$ref": "/common/widgets.json" + }, + "plugins": { + "$ref": "/common/plugins.json" + }, + "providers": { + "$ref": "/common/providers.json" + } + }, + "required": [ + "version" + ] +} \ No newline at end of file diff --git a/include/schema/donate/paypal.json b/include/schema/donate/paypal.json index 72eda1d..7801c30 100644 --- a/include/schema/donate/paypal.json +++ b/include/schema/donate/paypal.json @@ -14,7 +14,10 @@ }, "currency_code": { "type": "string", - "description": "Currency code" + "description": "Currency code", + "examples": [ + "USD" + ] } }, "required": [ diff --git a/include/schema/plugin/outdated_browser.json b/include/schema/plugin/outdated_browser.json index 35554ea..31efbc4 100644 --- a/include/schema/plugin/outdated_browser.json +++ b/include/schema/plugin/outdated_browser.json @@ -3,5 +3,5 @@ "$id": "/plugin/outdated_browser.json", "description": "Enable the Outdated Browser plugin\nhttp://outdatedbrowser.com/", "type": "boolean", - "default": true + "default": false } \ No newline at end of file diff --git a/include/schema/widget/links.json b/include/schema/widget/links.json index 4d95d0f..f44e946 100644 --- a/include/schema/widget/links.json +++ b/include/schema/widget/links.json @@ -16,7 +16,13 @@ "type": "string", "description": "URL of the site" } - } + }, + "examples": [ + { + "Hexo": "https://hexo.io", + "Bulma": "https://bulma.io" + } + ] } }, "required": [ diff --git a/include/schema/widget/profile.json b/include/schema/widget/profile.json index e0afbdf..4251f92 100644 --- a/include/schema/widget/profile.json +++ b/include/schema/widget/profile.json @@ -10,31 +10,72 @@ }, "author": { "type": "string", - "description": "Author name" + "description": "Author name", + "examples": [ + "Your name" + ] }, "author_title": { "type": "string", - "description": "Author title" + "description": "Author title", + "examples": [ + "Your title" + ] }, "location": { "type": "string", - "description": "Author's current location" + "description": "Author's current location", + "examples": [ + "Your location" + ] }, "avatar": { "type": "string", "description": "URL or path to the avatar image" }, + "avatar_rounded": { + "type": "boolean", + "description": "Whether show the rounded avatar image", + "default": false + }, "gravatar": { "type": "string", "description": "Email address for the Gravatar" }, "follow_link": { "type": "string", - "description": "URL or path for the follow button" + "description": "URL or path for the follow button", + "examples": [ + "https://github.com/ppoffice" + ] }, "social_links": { "$ref": "/misc/poly_links.json", - "description": "Links to be shown on the bottom of the profile widget" + "description": "Links to be shown on the bottom of the profile widget", + "examples": [ + { + "Github": { + "icon": "fab fa-github", + "url": "https://github.com/ppoffice" + }, + "Facebook": { + "icon": "fab fa-facebook", + "url": "https://facebook.com" + }, + "Twitter": { + "icon": "fab fa-twitter", + "url": "https://twitter.com" + }, + "Dribbble": { + "icon": "fab fa-dribbble", + "url": "https://dribbble.com" + }, + "RSS": { + "icon": "fas fa-rss", + "url": "/" + } + } + ] } }, "required": [ diff --git a/include/specs/article.spec.js b/include/specs/article.spec.js deleted file mode 100644 index c579d99..0000000 --- a/include/specs/article.spec.js +++ /dev/null @@ -1,35 +0,0 @@ -const { doc, type, defaultValue } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'Article display settings', - highlight: { - [type]: 'object', - [doc]: 'Code highlight settings', - theme: { - [type]: 'string', - [doc]: 'Code highlight themes\nhttps://github.com/highlightjs/highlight.js/tree/master/src/styles', - [defaultValue]: 'atom-one-light' - }, - clipboard: { - [type]: 'boolean', - [doc]: 'Show code copying button', - [defaultValue]: true - }, - fold: { - [type]: 'string', - [doc]: 'Default folding status of the code blocks. Can be "", "folded", "unfolded"', - [defaultValue]: 'unfolded' - } - }, - thumbnail: { - [type]: 'boolean', - [doc]: 'Whether to show article thumbnail images', - [defaultValue]: true - }, - readtime: { - [type]: 'boolean', - [doc]: 'Whether to show estimate article reading time', - [defaultValue]: true - } -}; \ No newline at end of file diff --git a/include/specs/comment.spec.js b/include/specs/comment.spec.js deleted file mode 100644 index da78521..0000000 --- a/include/specs/comment.spec.js +++ /dev/null @@ -1,141 +0,0 @@ -const { doc, type, defaultValue, required, requires } = require('../common/utils').descriptors; - -const ChangYanSpec = { - appid: { - [type]: 'string', - [doc]: 'Changyan comment app ID', - [required]: true, - [requires]: comment => comment.type === 'changyan' - }, - conf: { - [type]: 'string', - [doc]: 'Changyan comment configuration ID', - [required]: true, - [requires]: comment => comment.type === 'changyan' - } -}; - -const DisqusSpec = { - shortname: { - [type]: 'string', - [doc]: 'Disqus shortname', - [required]: true, - [requires]: comment => comment.type === 'disqus' - } -}; - -const GitmentGitalkSpec = { - owner: { - [type]: 'string', - [doc]: 'GitHub user ID', - [required]: true, - [requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk' - }, - repo: { - [type]: 'string', - [doc]: 'GitHub repo name to store comments', - [required]: true, - [requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk' - }, - client_id: { - [type]: 'string', - [doc]: 'GitHub application client ID', - [required]: true, - [requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk' - }, - client_secret: { - [type]: 'string', - [doc]: 'GitHub application client secret', - [required]: true, - [requires]: comment => comment.type === 'gitment' || comment.type === 'gitalk' - }, - admin: { - [type]: ['string', 'array'], - [doc]: 'GitHub repo owner and collaborators who can can initialize github issues', - [required]: true, - [requires]: comment => comment.type === 'gitalk', - '*': { - [type]: 'string', - [required]: true - } - }, - create_issue_manually: { - [type]: 'boolean', - [doc]: 'Create GitHub issue manually for each page', - [defaultValue]: false, - [requires]: comment => comment.type === 'gitalk' - }, - distraction_free_mode: { - [type]: 'boolean', - [doc]: 'Facebook-like distraction free mode', - [defaultValue]: false, - [requires]: comment => comment.type === 'gitalk' - } -}; - -const IssoSpec = { - url: { - [type]: 'string', - [doc]: 'URL to your Isso comment service', - [required]: true, - [requires]: comment => comment.type === 'isso' - } -}; - -const LiveReSpec = { - uid: { - [type]: 'string', - [doc]: 'LiveRe comment service UID', - [required]: true, - [requires]: comment => comment.type === 'livere' - } -}; - -const ValineSpec = { - app_id: { - [type]: 'string', - [doc]: 'LeanCloud APP ID', - [required]: true, - [requires]: comment => comment.type === 'valine' - }, - app_key: { - [type]: 'string', - [doc]: 'LeanCloud APP key', - [required]: true, - [requires]: comment => comment.type === 'valine' - }, - notify: { - [type]: 'boolean', - [doc]: 'Enable email notification when someone comments', - [defaultValue]: false, - [requires]: comment => comment.type === 'valine' - }, - verify: { - [type]: 'boolean', - [doc]: 'Enable verification code service', - [defaultValue]: false, - [requires]: comment => comment.type === 'valine' - }, - placeholder: { - [type]: 'string', - [doc]: 'Placeholder text in the comment box', - [defaultValue]: 'Say something...', - [requires]: comment => comment.type === 'valine' - } -}; - -module.exports = { - [type]: 'object', - [doc]: 'Comment plugin settings\nhttps://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Comment', - type: { - [type]: 'string', - [doc]: 'Name of the comment plugin', - [defaultValue]: null - }, - ...ChangYanSpec, - ...DisqusSpec, - ...GitmentGitalkSpec, - ...IssoSpec, - ...LiveReSpec, - ...ValineSpec -} \ No newline at end of file diff --git a/include/specs/config.spec.js b/include/specs/config.spec.js deleted file mode 100644 index 57ce280..0000000 --- a/include/specs/config.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -const { version } = require('../../package.json'); -const { type, required, defaultValue, doc } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'Root of the configuration file', - [required]: true, - version: { - [type]: 'string', - [doc]: 'Version of the Icarus theme that is currently used', - [required]: true, - [defaultValue]: version - }, - ...require('./meta.spec'), - navbar: require('./navbar.spec'), - footer: require('./footer.spec'), - article: require('./article.spec'), - search: require('./search.spec'), - comment: require('./comment.spec'), - donate: require('./donate.spec'), - share: require('./share.spec'), - sidebar: require('./sidebar.spec'), - widgets: require('./widgets.spec'), - plugins: require('./plugins.spec'), - providers: require('./providers.spec') -}; \ No newline at end of file diff --git a/include/specs/donate.spec.js b/include/specs/donate.spec.js deleted file mode 100644 index d32a68e..0000000 --- a/include/specs/donate.spec.js +++ /dev/null @@ -1,72 +0,0 @@ -const { doc, type, defaultValue, required, requires, format } = require('../common/utils').descriptors; - -const DEFAULT_DONATE = [ - { - type: 'alipay', - qrcode: '' - }, - { - type: 'wechat', - qrcode: '' - }, - { - type: 'paypal', - business: '', - currency_code: 'USD' - }, - { - type: 'patreon', - url: '' - } -]; - -const QrcodeSpec = { - qrcode: { - [type]: 'string', - [doc]: 'Qrcode image URL', - [required]: true, - [requires]: donate => donate.type === 'alipay' || donate.type === 'wechat' - } -}; - -const PaypalSpec = { - business: { - [type]: 'string', - [doc]: 'Paypal business ID or email address', - [required]: true, - [requires]: donate => donate.type === 'paypal' - }, - currency_code: { - [type]: 'string', - [doc]: 'Currency code', - [required]: true, - [requires]: donate => donate.type === 'paypal' - } -}; - -const PatreonSpec = { - url: { - [type]: 'string', - [doc]: 'URL to the Patreon page', - [required]: true, - [requires]: donate => donate.type === 'patreon' - } -}; - -module.exports = { - [type]: 'array', - [doc]: 'Donation entries\nhttps://ppoffice.github.io/hexo-theme-icarus/categories/Donation/', - [defaultValue]: DEFAULT_DONATE, - '*': { - [type]: 'object', - [doc]: 'Single donation entry settings', - type: { - [type]: 'string', - [doc]: 'Donation entry name', - [required]: true - }, - ...QrcodeSpec, - ...PaypalSpec, - ...PatreonSpec - } -} \ No newline at end of file diff --git a/include/specs/footer.spec.js b/include/specs/footer.spec.js deleted file mode 100644 index 20a8dd6..0000000 --- a/include/specs/footer.spec.js +++ /dev/null @@ -1,24 +0,0 @@ -const { doc, type, defaultValue } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'Footer section link settings', - links: { - ...require('./icon_link.spec'), - [doc]: 'Links to be shown on the right of the footer section', - [defaultValue]: { - 'Creative Commons': { - icon: 'fab fa-creative-commons', - url: 'https://creativecommons.org/' - }, - 'Attribution 4.0 International': { - icon: 'fab fa-creative-commons-by', - url: 'https://creativecommons.org/licenses/by/4.0/' - }, - 'Download on GitHub': { - icon: 'fab fa-github', - url: 'https://github.com/ppoffice/hexo-theme-icarus' - } - } - } -}; \ No newline at end of file diff --git a/include/specs/icon_link.spec.js b/include/specs/icon_link.spec.js deleted file mode 100644 index b3cb39a..0000000 --- a/include/specs/icon_link.spec.js +++ /dev/null @@ -1,20 +0,0 @@ -const { doc, type, required } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'Link icon settings', - '*': { - [type]: ['string', 'object'], - [doc]: 'Path or URL to the menu item, and/or link icon class names', - icon: { - [required]: true, - [type]: 'string', - [doc]: 'Link icon class names' - }, - url: { - [required]: true, - [type]: 'string', - [doc]: 'Path or URL to the menu item' - } - } -}; \ No newline at end of file diff --git a/include/specs/meta.spec.js b/include/specs/meta.spec.js deleted file mode 100644 index 02ed3e2..0000000 --- a/include/specs/meta.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -const { doc, type, defaultValue } = require('../common/utils').descriptors; - -module.exports = { - favicon: { - [type]: 'string', - [doc]: 'Path or URL to the website\'s icon', - [defaultValue]: '/images/favicon.svg', - }, - meta: { - [type]: 'array', - [doc]: 'Additional HTML meta tags in an array.', - [defaultValue]: null, - '*': { - [type]: 'string', - [doc]: 'Meta tag specified in = style.\nE.g., name=theme-color;content=#123456 => ' - } - }, - canonical_url: { - [type]: 'string', - [doc]: 'canonical_url of your site', - [defaultValue]: null - }, - rss: { - [type]: 'string', - [doc]: 'Path or URL to RSS atom.xml', - [defaultValue]: null - }, - logo: { - [type]: ['string', 'object'], - [defaultValue]: '/images/logo.svg', - [doc]: 'Path or URL to the website\'s logo to be shown on the left of the navigation bar or footer', - text: { - [type]: 'string', - [doc]: 'Text to be shown in place of the logo image' - } - }, - open_graph: { - [type]: 'object', - [doc]: 'Open Graph metadata\nhttps://hexo.io/docs/helpers.html#open-graph', - fb_app_id: { - [type]: 'string', - [doc]: 'Facebook App ID', - [defaultValue]: null - }, - fb_admins: { - [type]: 'string', - [doc]: 'Facebook Admin ID', - [defaultValue]: null - }, - twitter_id: { - [type]: 'string', - [doc]: 'Twitter ID', - [defaultValue]: null - }, - twitter_site: { - [type]: 'string', - [doc]: 'Twitter site', - [defaultValue]: null - }, - google_plus: { - [type]: 'string', - [doc]: 'Google+ profile link', - [defaultValue]: null - } - } -}; \ No newline at end of file diff --git a/include/specs/navbar.spec.js b/include/specs/navbar.spec.js deleted file mode 100644 index af193bc..0000000 --- a/include/specs/navbar.spec.js +++ /dev/null @@ -1,31 +0,0 @@ -const { doc, type, defaultValue } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'Navigation bar link settings', - menu: { - [type]: 'object', - [doc]: 'Navigation bar menu links', - [defaultValue]: { - Home: '/', - Archives: '/archives', - Categories: '/categories', - Tags: '/tags', - About: '/about' - }, - '*': { - [type]: 'string', - [doc]: 'Path or URL to the menu item' - } - }, - links: { - ...require('./icon_link.spec'), - [doc]: 'Navigation bar links to be shown on the right', - [defaultValue]: { - 'Download on GitHub': { - icon: 'fab fa-github', - url: 'https://github.com/ppoffice/hexo-theme-icarus' - } - } - } -}; \ No newline at end of file diff --git a/include/specs/plugins.spec.js b/include/specs/plugins.spec.js deleted file mode 100644 index 2838df0..0000000 --- a/include/specs/plugins.spec.js +++ /dev/null @@ -1,68 +0,0 @@ -const { doc, type, defaultValue } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'Other plugin settings', - animejs: { - [type]: 'boolean', - [doc]: 'Enable page animations', - [defaultValue]: true - }, - gallery: { - [type]: 'boolean', - [doc]: 'Enable the lightGallery and Justified Gallery plugins\nhttps://ppoffice.github.io/hexo-theme-icarus/Plugins/General/gallery-plugin/', - [defaultValue]: true - }, - 'outdated-browser': { - [type]: 'boolean', - [doc]: 'Enable the Outdated Browser plugin\nhttp://outdatedbrowser.com/', - [defaultValue]: true - }, - mathjax: { - [type]: 'boolean', - [doc]: 'Enable the MathJax plugin\nhttps://ppoffice.github.io/hexo-theme-icarus/Plugins/General/mathjax-plugin/', - [defaultValue]: true - }, - 'back-to-top': { - [type]: 'boolean', - [doc]: 'Show the back to top button on mobile devices', - [defaultValue]: true - }, - 'google-analytics': { - [type]: ['boolean', 'object'], - [doc]: 'Google Analytics plugin settings\nhttps://ppoffice.github.io/hexo-theme-icarus/Plugins/General/site-analytics-plugin/#Google-Analytics', - tracking_id: { - [type]: 'string', - [doc]: 'Google Analytics tracking id', - [defaultValue]: null - } - }, - 'baidu-analytics': { - [type]: ['boolean', 'object'], - [doc]: 'Baidu Analytics plugin settings\nhttps://ppoffice.github.io/hexo-theme-icarus/Plugins/General/site-analytics-plugin/#Baidu-Analytics', - tracking_id: { - [type]: 'string', - [doc]: 'Baidu Analytics tracking id', - [defaultValue]: null - } - }, - hotjar: { - [type]: ['boolean', 'object'], - [doc]: 'Hotjar user feedback plugin\nhttps://ppoffice.github.io/hexo-theme-icarus/Plugins/General/site-analytics-plugin/#Hotjar', - site_id: { - [type]: ['string', 'number'], - [doc]: 'Hotjar site id', - [defaultValue]: null - } - }, - progressbar: { - [type]: 'boolean', - [doc]: 'Show a loading progress bar at top of the page', - [defaultValue]: true - }, - busuanzi: { - [type]: 'boolean', - [doc]: 'BuSuanZi site/page view counter\nhttps://busuanzi.ibruce.info', - [defaultValue]: false - } -}; \ No newline at end of file diff --git a/include/specs/providers.spec.js b/include/specs/providers.spec.js deleted file mode 100644 index 68e026e..0000000 --- a/include/specs/providers.spec.js +++ /dev/null @@ -1,21 +0,0 @@ -const { doc, type, defaultValue } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'CDN provider settings\nhttps://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/speed-up-your-site-with-custom-cdn/', - cdn: { - [type]: 'string', - [doc]: 'Name or URL of the JavaScript and/or stylesheet CDN provider', - [defaultValue]: 'jsdelivr' - }, - fontcdn: { - [type]: 'string', - [doc]: 'Name or URL of the webfont CDN provider', - [defaultValue]: 'google' - }, - iconcdn: { - [type]: 'string', - [doc]: 'Name or URL of the webfont Icon CDN provider', - [defaultValue]: 'fontawesome' - } -}; \ No newline at end of file diff --git a/include/specs/search.spec.js b/include/specs/search.spec.js deleted file mode 100644 index a6d2abe..0000000 --- a/include/specs/search.spec.js +++ /dev/null @@ -1,17 +0,0 @@ -const { doc, type, defaultValue, required, requires } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'Search plugin settings\nhttps://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Search', - type: { - [type]: 'string', - [doc]: 'Name of the search plugin', - [defaultValue]: 'insight' - }, - cx: { - [type]: 'string', - [doc]: 'Google CSE cx value', - [required]: true, - [requires]: search => search.type === 'google-cse' - } -}; \ No newline at end of file diff --git a/include/specs/share.spec.js b/include/specs/share.spec.js deleted file mode 100644 index 34a143b..0000000 --- a/include/specs/share.spec.js +++ /dev/null @@ -1,17 +0,0 @@ -const { doc, type, defaultValue, required, requires } = require('../common/utils').descriptors; - -module.exports = { - [type]: 'object', - [doc]: 'Share plugin settings\nhttps://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Share', - type: { - [type]: 'string', - [doc]: 'Share plugin name', - [defaultValue]: null - }, - install_url: { - [type]: 'string', - [doc]: 'URL to the share plugin script provided by share plugin service provider', - [required]: true, - [requires]: share => share.type === 'sharethis' || share.type === 'addthis' - } -} \ No newline at end of file diff --git a/include/specs/sidebar.spec.js b/include/specs/sidebar.spec.js deleted file mode 100644 index 74ed518..0000000 --- a/include/specs/sidebar.spec.js +++ /dev/null @@ -1,20 +0,0 @@ -const { doc, type, defaultValue, required, requires, format } = require('../common/utils').descriptors; - -function commonSettings(position) { - return { - [type]: 'object', - [doc]: position + ' sidebar settings', - sticky: { - [type]: 'boolean', - [doc]: 'Whether the ' + position + ' sidebar is sticky when page scrolls\nhttps://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/make-a-sidebar-sticky-when-page-scrolls/', - [defaultValue]: false - } - } -} - -module.exports = { - [type]: 'object', - [doc]: 'Sidebar settings.\nPlease be noted that a sidebar is only visible when it has at least one widget', - left: commonSettings('left'), - right: commonSettings('right') -} \ No newline at end of file diff --git a/include/specs/widgets.spec.js b/include/specs/widgets.spec.js deleted file mode 100644 index 49e496f..0000000 --- a/include/specs/widgets.spec.js +++ /dev/null @@ -1,166 +0,0 @@ -const { doc, type, defaultValue, required, requires, format } = require('../common/utils').descriptors; - -const DEFAULT_WIDGETS = [ - { - type: 'profile', - position: 'left', - author: 'Your name', - author_title: 'Your title', - location: 'Your location', - avatar: null, - gravatar: null, - avatar_rounded: false, - follow_link: 'https://github.com/ppoffice', - social_links: { - Github: { - icon: 'fab fa-github', - url: 'https://github.com/ppoffice' - }, - Facebook: { - icon: 'fab fa-facebook', - url: 'https://facebook.com' - }, - Twitter: { - icon: 'fab fa-twitter', - url: 'https://twitter.com' - }, - Dribbble: { - icon: 'fab fa-dribbble', - url: 'https://dribbble.com' - }, - RSS: { - icon: 'fas fa-rss', - url: '/' - } - } - }, - { - type: 'toc', - position: 'left' - }, - { - type: 'links', - position: 'left', - links: { - Hexo: 'https://hexo.io', - PPOffice: 'https://github.com/ppoffice' - } - }, - { - type: 'category', - position: 'left' - }, - { - type: 'tagcloud', - position: 'left' - }, - { - type: 'recent_posts', - position: 'right' - }, - { - type: 'archive', - position: 'right' - }, - { - type: 'tag', - position: 'right' - } -]; - -const ProfileSpec = { - author: { - [type]: 'string', - [doc]: 'Author name to be shown in the profile widget', - [defaultValue]: 'Your name' - }, - author_title: { - [type]: 'string', - [doc]: 'Title of the author to be shown in the profile widget', - [defaultValue]: 'Your title' - }, - location: { - [type]: 'string', - [doc]: 'Author\'s current location to be shown in the profile widget', - [defaultValue]: 'Your location' - }, - avatar: { - [type]: 'string', - [doc]: 'Path or URL to the avatar to be shown in the profile widget', - [defaultValue]: '/images/avatar.png' - }, - avatar_rounded: { - [type]: 'boolean', - [doc]: 'Whether to show avatar image rounded or square', - [defaultValue]: false - }, - gravatar: { - [type]: 'string', - [doc]: 'Email address for the Gravatar to be shown in the profile widget', - }, - follow_link: { - [type]: 'string', - [doc]: 'Path or URL for the follow button', - }, - social_links: { - ...require('./icon_link.spec'), - [doc]: 'Links to be shown on the bottom of the profile widget', - } -}; - -for (let key in ProfileSpec) { - ProfileSpec[key][requires] = widget => widget.type === 'profile'; -} - -const LinksSpec = { - links: { - [type]: 'object', - [doc]: 'Links to be shown in the links widget', - [requires]: parent => parent.type === 'links', - '*': { - [type]: 'string', - [doc]: 'Path or URL to the link', - [required]: true - } - } -}; - -const SubscrbieEmailSpec = { - feedburner_id: { - [type]: 'string', - [doc]: 'Feedburner ID', - [required]: true, - [requires]: parent => parent.type === 'subscribe_email' - }, - description: { - [type]: 'string', - [doc]: 'Hint text under the subscription input', - [requires]: parent => parent.type === 'subscribe_email' - } -}; - -module.exports = { - [type]: 'array', - [doc]: 'Sidebar widget settings\nhttps://ppoffice.github.io/hexo-theme-icarus/categories/Widgets/', - [defaultValue]: DEFAULT_WIDGETS, - '*': { - [type]: 'object', - [doc]: 'Single widget settings', - type: { - [type]: 'string', - [doc]: 'Widget name', - [required]: true, - [defaultValue]: 'profile' - }, - position: { - [type]: 'string', - [doc]: 'Where should the widget be placed, left or right', - [format]: /^(left|right)$/, - [required]: true, - [defaultValue]: 'left' - }, - ...ProfileSpec, - ...LinksSpec, - ...SubscrbieEmailSpec - } -} \ No newline at end of file diff --git a/layout/common/head.jsx b/layout/common/head.jsx index 315d215..0693347 100644 --- a/layout/common/head.jsx +++ b/layout/common/head.jsx @@ -33,14 +33,17 @@ module.exports = class extends Component { const { url, meta_generator = true, + head = {}, + article, + highlight + } = config; + const { meta = [], open_graph, canonical_url, rss, - favicon, - article, - highlight - } = config; + favicon + } = head; const language = page.lang || page.language || config.language;