From d4f97cde0da313dc63721fd7fe9c5da0077684eb Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Fri, 11 Jun 2021 11:37:40 +0800 Subject: [PATCH] Support Gitter Sidecar (#289) --- _config.yml | 22 +++++++++++-------- layout/_partials/sidebar/site-overview.njk | 15 +++++++------ layout/_third-party/chat/chatra.njk | 8 +++---- layout/_third-party/chat/gitter.njk | 3 +++ layout/_third-party/chat/tidio.njk | 4 +--- layout/_third-party/index.njk | 9 ++++++-- .../_common/components/post/post-reward.styl | 12 +--------- .../outline/sidebar/sidebar-button.styl | 16 ++------------ source/css/_mixins.styl | 13 +++++++++++ source/css/_schemes/Pisces/_sidebar.styl | 7 ++---- source/js/third-party/chat/gitter.js | 5 +++++ 11 files changed, 58 insertions(+), 56 deletions(-) create mode 100644 layout/_third-party/chat/gitter.njk create mode 100644 source/js/third-party/chat/gitter.js diff --git a/_config.yml b/_config.yml index b4f07dc..9733952 100644 --- a/_config.yml +++ b/_config.yml @@ -180,15 +180,6 @@ toc: # Maximum heading depth of generated toc. max_depth: 6 -# A button to open designated chat widget in sidebar. -# Firstly, you need enable the chat service you want to activate its sidebar button. -chat: - enable: false - #service: chatra - #service: tidio - icon: fa fa-comment # Icon name in Font Awesome, set false to disable icon. - text: Chat # Button text, change it as you wish. - # --------------------------------------------------------------- # Footer Settings @@ -755,6 +746,13 @@ local_search: # See: https://theme-next.js.org/docs/third-party-services/chat-services # --------------------------------------------------------------- +# A button to open designated chat widget in sidebar. +# Firstly, you need to enable and configure the chat service. +chat: + enable: false + icon: fa fa-comment # Icon name in Font Awesome, set false to disable icon. + text: Chat # Button text, change it as you wish. + # Chatra Support # For more information: https://chatra.com # Dashboard: https://app.chatra.io/settings/general @@ -771,6 +769,12 @@ tidio: enable: false key: # Public Key, get it from dashboard. See: https://www.tidio.com/panel/settings/developer +# Gitter Support +# For more information: https://gitter.im +gitter: + enable: false + room: + # --------------------------------------------------------------- # Tags Settings diff --git a/layout/_partials/sidebar/site-overview.njk b/layout/_partials/sidebar/site-overview.njk index 08b008e..41e472c 100644 --- a/layout/_partials/sidebar/site-overview.njk +++ b/layout/_partials/sidebar/site-overview.njk @@ -60,17 +60,18 @@ {%- endif %} -{%- if theme.chat.enable and theme.chat.service !== '' %} +{%- if theme.chat.enable and (theme.chatra.enable or theme.tidio.enable or theme.gitter.enable) %} {%- endif %} diff --git a/layout/_third-party/chat/chatra.njk b/layout/_third-party/chat/chatra.njk index 1c824c2..c0ebd12 100644 --- a/layout/_third-party/chat/chatra.njk +++ b/layout/_third-party/chat/chatra.njk @@ -1,5 +1,3 @@ -{%- if theme.chatra.enable %} - {{ next_data('chatra', theme.chatra) }} - {{ next_js('third-party/chat/chatra.js') }} - -{%- endif %} +{{ next_data('chatra', theme.chatra) }} +{{ next_js('third-party/chat/chatra.js') }} + diff --git a/layout/_third-party/chat/gitter.njk b/layout/_third-party/chat/gitter.njk new file mode 100644 index 0000000..6eae153 --- /dev/null +++ b/layout/_third-party/chat/gitter.njk @@ -0,0 +1,3 @@ +{{ next_data('gitter', theme.gitter) }} +{{ next_js('third-party/chat/gitter.js') }} + diff --git a/layout/_third-party/chat/tidio.njk b/layout/_third-party/chat/tidio.njk index a0fcc56..3ba22a5 100644 --- a/layout/_third-party/chat/tidio.njk +++ b/layout/_third-party/chat/tidio.njk @@ -1,3 +1 @@ -{%- if theme.tidio.enable %} - -{%- endif %} + diff --git a/layout/_third-party/index.njk b/layout/_third-party/index.njk index 2739dc1..ee6f5a2 100644 --- a/layout/_third-party/index.njk +++ b/layout/_third-party/index.njk @@ -6,8 +6,13 @@ {%- include 'search/localsearch.njk' -%} {%- endif %} -{%- include 'chat/chatra.njk' -%} -{%- include 'chat/tidio.njk' -%} +{%- if theme.chatra.enable %} + {%- include 'chat/chatra.njk' -%} +{%- elif theme.tidio.enable %} + {%- include 'chat/tidio.njk' -%} +{%- elif theme.gitter.enable %} + {%- include 'chat/gitter.njk' -%} +{%- endif %} {%- include 'tags/pdf.njk' -%} {%- include 'tags/mermaid.njk' -%} diff --git a/source/css/_common/components/post/post-reward.styl b/source/css/_common/components/post/post-reward.styl index bd5b8ff..1afe23d 100644 --- a/source/css/_common/components/post/post-reward.styl +++ b/source/css/_common/components/post/post-reward.styl @@ -4,22 +4,12 @@ text-align: center; button { - background: transparent; + button($sidebar-highlight); border: 2px solid $sidebar-highlight; border-radius: 2px; - color: $sidebar-highlight; - cursor: pointer; - line-height: 2; outline: 0; - padding: 0 15px; transition: all $transition-ease; vertical-align: text-top; - - &:hover { - background: $sidebar-highlight; - border: 2px solid transparent; - color: white; - } } } diff --git a/source/css/_common/outline/sidebar/sidebar-button.styl b/source/css/_common/outline/sidebar/sidebar-button.styl index 62c1119..9f6d90e 100644 --- a/source/css/_common/outline/sidebar/sidebar-button.styl +++ b/source/css/_common/outline/sidebar/sidebar-button.styl @@ -3,25 +3,13 @@ margin-top: 15px; } - a { + button { + button($orange); border: 1px solid $orange; border-radius: 4px; - color: $orange; - display: inline-block; - padding: 0 15px; .fa, .fab, .far, .fas { margin-right: 5px; } - - &:hover { - background: $orange; - border: 1px solid $orange; - color: white; - - .fa, .fab, .far, .fas { - color: white; - } - } } } diff --git a/source/css/_mixins.styl b/source/css/_mixins.styl index 229d5b5..71f513c 100644 --- a/source/css/_mixins.styl +++ b/source/css/_mixins.styl @@ -234,3 +234,16 @@ site-nav-hide-by-default() { height: var(--scroll-height); } } + +button($color) { + background: transparent; + color: $color; + cursor: pointer; + line-height: 2; + padding: 0 15px; + + &:hover { + background: $color; + color: white; + } +} diff --git a/source/css/_schemes/Pisces/_sidebar.styl b/source/css/_schemes/Pisces/_sidebar.styl index ae8875a..385850a 100644 --- a/source/css/_schemes/Pisces/_sidebar.styl +++ b/source/css/_schemes/Pisces/_sidebar.styl @@ -35,19 +35,16 @@ border-bottom: 1px dotted $grey-light; border-top: 1px dotted $grey-light; - a { + button { border: 0; color: $orange; display: block; + width: 100%; &:hover { background: none; border: 0; color: darken($orange, 20%); - - .fa, .fab, .far, .fas { - color: darken($orange, 20%); - } } } } diff --git a/source/js/third-party/chat/gitter.js b/source/js/third-party/chat/gitter.js new file mode 100644 index 0000000..2b26d05 --- /dev/null +++ b/source/js/third-party/chat/gitter.js @@ -0,0 +1,5 @@ +/* global CONFIG */ + +((window.gitter = {}).chat = {}).options = { + room: CONFIG.gitter.room +};