From a5d8df2de6c9bfea0daeb3b11472f7a42b20ee18 Mon Sep 17 00:00:00 2001 From: removeif Date: Fri, 22 May 2020 17:18:33 +0800 Subject: [PATCH] add notice widget --- _config.yml | 7 ++++++ include/schema/common/widgets.json | 3 +++ include/schema/widget/notice.json | 31 +++++++++++++++++++++++++ languages/en.yml | 1 + languages/zh-CN.yml | 1 + layout/widget/notice.jsx | 36 ++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 include/schema/widget/notice.json create mode 100644 layout/widget/notice.jsx diff --git a/_config.yml b/_config.yml index 62f8fd7..cfdaa02 100644 --- a/_config.yml +++ b/_config.yml @@ -265,6 +265,13 @@ widgets: # client_id: '' # # AdSense AD unit ID # slot_id: '' + - + # position: right + # type: notice + # contents: + # 1: 2019.8.15 主题开源 + # 2: 2020.5.20 添加公告widget + # 3: 2020.5.21 公告测试 # Plugin configurations plugins: # Enable page startup animations diff --git a/include/schema/common/widgets.json b/include/schema/common/widgets.json index 2f2d996..c606f22 100644 --- a/include/schema/common/widgets.json +++ b/include/schema/common/widgets.json @@ -45,6 +45,9 @@ }, { "$ref": "/widget/adsense.json" + }, + { + "$ref": "/widget/notice.json" } ], "required": [ diff --git a/include/schema/widget/notice.json b/include/schema/widget/notice.json new file mode 100644 index 0000000..a42eba5 --- /dev/null +++ b/include/schema/widget/notice.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "/widget/notice.json", + "description": "Notice links widget configurations", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "notice" + }, + "contents": { + "type": "object", + "description": "notic contents", + "patternProperties": { + ".+": { + "type": "string", + "description": "URL of the site" + } + }, + "examples": [ + { + "1": "2019.05.23 建站" + } + ], + "nullable": true + } + }, + "required": [ + "type" + ] +} \ No newline at end of file diff --git a/languages/en.yml b/languages/en.yml index 0479d3f..2c9cbc4 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -30,6 +30,7 @@ widget: hot_recommend_tip: 'Loading...Wait a Minute!' hitokoto_from: 'From' hitokoto_provider: 'Provider' + notice: 'Notice' article: more: 'Read More' diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index d641817..53f9855 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -30,6 +30,7 @@ widget: hot_recommend_tip: '加载中,请稍等...' hitokoto_from: '来源' hitokoto_provider: '提供者' + notice: '通知' article: more: '阅读更多' comments: '评论' diff --git a/layout/widget/notice.jsx b/layout/widget/notice.jsx new file mode 100644 index 0000000..555d52f --- /dev/null +++ b/layout/widget/notice.jsx @@ -0,0 +1,36 @@ +const { URL } = require('url'); +const { Component } = require('inferno'); +const { cacheComponent } = require('../util/cache'); + +class Links extends Component { + render() { + const { title, contents } = this.props; + return
+
+ +
+
; + } +} + +module.exports = cacheComponent(Links, 'widget.links', props => { + const { helper, widget } = props; + if (!Object.keys(widget.contents).length) { + return null; + } + return { + title: helper.__('widget.notice'), + contents: widget.contents + }; +});