Skip to content

Commit

Permalink
feat: add sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Oct 14, 2018
1 parent 1a8556a commit e9bd7c2
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 20 deletions.
7 changes: 7 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ paginate_path: /page:num # don't change this unless for special need
sources: # bootcdn (default), unpkg


## => Sharing
##############################
sharing:
provider: false # false (default), "addtoany"


## => Comments
##############################
comments:
Expand Down Expand Up @@ -176,6 +182,7 @@ defaults:
type: posts
values:
layout: article
sharing: true
license: true
aside:
toc: true
Expand Down
1 change: 1 addition & 0 deletions _data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ default:
show_tags: true
show_author_profile: false
full_width: false
sharing: false
comment: true
license: false
pageview: false
Expand Down
10 changes: 10 additions & 0 deletions _includes/sharing-providers/addtoany.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- AddToAny BEGIN -->
<div class="a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_dd" href="https://www.addtoany.com/share"></a>
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_google_plus"></a>
<a class="a2a_button_linkedin"></a>
</div>
<script async src="https://static.addtoany.com/menu/page.js"></script>
<!-- AddToAny END -->
3 changes: 3 additions & 0 deletions _includes/sharing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- if site.sharing.provider == 'addtoany' -%}
{%- include sharing-providers/addtoany.html -%}
{%- endif -%}
16 changes: 14 additions & 2 deletions _layouts/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,30 @@
type: article
---

{%- include snippets/assign.html target=site.data.variables.default.page.show_author_profile
{%- include snippets/assign.html
target = site.data.variables.default.page.sharing
source0=layout.sharing source1=page.sharing -%}
{%- assign _sharing = __return -%}


{%- include snippets/assign.html
target=site.data.variables.default.page.show_author_profile
source0=layout.show_author_profile source1=page.show_author_profile -%}
{%- assign _show_author_profile = __return -%}

{%- include snippets/assign.html target=site.data.variables.default.page.license
{%- include snippets/assign.html
target=site.data.variables.default.page.license
source0=layout.license source1=page.license -%}
{%- assign _license = __return -%}

<div class="layout--article">

<div class="article__content" itemprop="articleBody">{{ content }}</div>

{%- if _sharing != false -%}
<section class="article__sharing">{%- include sharing.html -%}</section>
{%- endif -%}

<footer class="article__footer">
{%- if page.modify_date -%}
{%- include snippets/locale-to-string.html locale=site.data.locale.ARTICLE_DATE_FORMAT -%}
Expand Down
2 changes: 1 addition & 1 deletion _layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
{%- endif -%}

<div class="js-article-content">{{ content }}</div>
{%- if jekyll.environment != "development" and _comment != false -%}
{%- if _comment != false -%}
<section class="page__comments">{%- include comments.html -%}</section>
{%- endif -%}
</article>
Expand Down
32 changes: 23 additions & 9 deletions _sass/common/classes/_clickable.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mixin clickable($clr, $bg-clr, $hover-clr: default, $hover-bg-clr: default, $active-clr: default, $active-bg-clr: default, $focus-clr: default, $focus-bg-clr: default, $theme: default) {
@mixin clickable($clr, $bg-clr, $hover-clr: default, $hover-bg-clr: default, $active-clr: default, $active-bg-clr: default, $focus-clr: default, $focus-bg-clr: default, $theme: default, $ignore-path: default) {

@if $theme == default {
@if $bg-clr == null and $hover-bg-clr == null {
Expand All @@ -16,6 +16,12 @@
}
}

@if $ignore-path == default {
$ignore-path: false;
} @else {
$ignore-path: true;
}

// hover
@if $hover-clr == default {
@if $hover-bg-clr == null {
Expand Down Expand Up @@ -80,26 +86,32 @@
@if $bg-clr {
background-color: $bg-clr;
}
svg path {
fill: $clr;
@if $ignore-path == false {
svg path {
fill: $clr;
}
}
}
@include hover() {
color: $hover-clr;
@if $hover-bg-clr {
background-color: $hover-bg-clr;
}
svg path {
fill: $hover-clr;
@if $ignore-path == false {
svg path {
fill: $hover-clr;
}
}
}
@include active() {
color: $active-clr;
@if $active-bg-clr {
background-color: $active-bg-clr;
}
svg path {
fill: $active-clr;
@if $ignore-path == false {
svg path {
fill: $active-clr;
}
}
}
@include focus() {
Expand All @@ -108,8 +120,10 @@
background-color: $focus-bg-clr;
box-shadow: 0 0 0 2px rgba($focus-bg-clr, .4);
}
svg path {
fill: $focus-clr;
@if $ignore-path == false {
svg path {
fill: $focus-clr;
}
}
}
}
4 changes: 2 additions & 2 deletions _sass/common/classes/_link.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@mixin link-colors($clr, $hover-clr: default, $active-clr: default, $focus-clr: null, $theme: default) {
@include clickable($clr, null, $hover-clr, null, $active-clr, null, $focus-clr, null, $theme: default);
@mixin link-colors($clr, $hover-clr: default, $active-clr: default, $focus-clr: null, $theme: default, $ignore-path: false) {
@include clickable($clr, null, $hover-clr, null, $active-clr, null, $focus-clr, null, $theme, $ignore-path);
}
4 changes: 3 additions & 1 deletion _sass/layout/_article.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.layout--article {

.article__sharing {
margin: map-get($base, vertical-space-lg) 0;
}
.article__footer {
margin: map-get($base, vertical-space-lg) 0;
font-size: map-get($base, font-size-sm);
Expand Down
6 changes: 3 additions & 3 deletions assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
"animate/fade-in-down",
"animate/fade-in-up",

"components/main",
"components/header",
"components/footer",
"components/article-info",
"components/article-header",
"components/article-content",
"components/article-list",
"components/author-links",
"components/author-profile",
"components/header",
"components/footer",
"components/main",
"components/tags",
"components/search",
"components/plugins",
Expand Down
7 changes: 7 additions & 0 deletions docs/_config.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ paginate_path: /test/page:num # don't change this unless for special need
sources: unpkg # bootcdn (default), unpkg


## => Sharing
##############################
sharing:
provider: addtoany # false (default), "addtoany"


## => Comments
##############################
comments:
Expand Down Expand Up @@ -195,6 +201,7 @@ defaults:
type: posts
values:
layout: article
sharing: true
license: true
category: post
aside:
Expand Down
7 changes: 7 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ paginate_path: /test/page:num # don't change this unless for special need
sources: # bootcdn (default), unpkg


## => Sharing
##############################
sharing:
provider: addtoany # false (default), "addtoany"


## => Comments
##############################
comments:
Expand Down Expand Up @@ -196,6 +202,7 @@ defaults:
type: posts
values:
layout: article
sharing: true
license: true
category: post
aside:
Expand Down
1 change: 1 addition & 0 deletions docs/_data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ default:
show_tags: true
show_author_profile: false
full_width: false
sharing: false
comment: true
license: false
pageview: false
Expand Down
16 changes: 16 additions & 0 deletions docs/_docs/en/2.1-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@ sources: bootcdn # bootcdn (default), unpkg

[^cdn]: [Content delivery network](https://en.wikipedia.org/wiki/Content_delivery_network)

## Sharing

| Name | Sharing Provider |
| --- | --- |
| **addtoany** | [AddToAny](https://www.addtoany.com/) |

### AddToAny

```yaml
comments:
provider: addtoany
```

You NEED set `sharing` variable as `true` in the page’s YAML Front Matter to enable sharing on this page, you can find more information [HRER](https://tianqi.name/jekyll-TeXt-theme/docs/en/layouts#article-layout).
{:.warning}

## Comments

| Name | Comments Provider |
Expand Down
1 change: 1 addition & 0 deletions docs/_docs/en/2.3-layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Base on Page Layout.
| Variable | Option Values | Description |
| --- | --- | --- |
| **modify_date** | `!!str` | The last modified date of this article, the date is modified in the format `YYYY-MM-DD HH:MM:SS +/-TTTT`; hours, minutes, seconds, and timezone offset are optional. just like `date` variable. |
| **sharing** | true, false (default) | Set as `true` to enable Sharing on this article. |
| **show_author_profile** | true, false (default) | Set as `true` to show author profile at the beginning of the article. |
| **license** | true, false (default), CC-BY-4.0, CC-BY-SA-4.0, CC-BY-NC-4.0, CC-BY-ND-4.0 | license of the article. Set true to use `license` variable that set in *_config.yml*, set false to enable it. |

Expand Down
20 changes: 18 additions & 2 deletions docs/_docs/zh/2.1-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,25 @@ sources: bootcdn # bootcdn (default), unpkg

[^cdn]: [Content delivery network](https://en.wikipedia.org/wiki/Content_delivery_network)

## 分享

| 名称 | 分享系统提供方 |
| --- | --- |
| **addtoany** | [AddToAny](https://www.addtoany.com/) |

### AddToAny

```yaml
comments:
provider: addtoany
```

你需要在页面的头信息里设置 `sharing` 属性为 `true` 来开启该页的评论,详情请戳[这里](https://tianqi.name/jekyll-TeXt-theme/docs/zh/layouts#article-%E5%B8%83%E5%B1%80)。
{:.warning}

## 评论

| 名称 | 评论系统评论方 |
| 名称 | 评论系统提供方 |
| --- | --- |
| **disqus** | [Disqus](https://disqus.com/) |
| **gitalk** | [Gitalk](https://github.com/gitalk/gitalk/) |
Expand Down Expand Up @@ -284,7 +300,7 @@ comments:

## 文章点击量

| 名称 | 文章点击量后台评论方 |
| 名称 | 文章点击量后台提供方 |
| --- | --- |
| **leancloud** | [Disqus](https://leancloud.cn/) |

Expand Down
1 change: 1 addition & 0 deletions docs/_docs/zh/2.3-layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ graph TB;
| 配置项 | 可选值 | 描述 |
| --- | --- | --- |
| **modify_date** | `!!str` | 该文章的最后修改时间, 其格式为 `YYYY-MM-DD HH:MM:SS +/-TTTT``date` 的格式相同 |
| **sharing** | true, false (default) | 是否开启分享,设置为 `true` 开启。 |
| **show_author_profile** | true, false (default) | 是否在文章开头显示作者信息卡片,设置为 `true` 显示。 |
| **license** | true, false (default), CC-BY-4.0, CC-BY-SA-4.0, CC-BY-NC-4.0, CC-BY-ND-4.0 | 该文章的许可协议。设置为 `true` 使用在 *_config.yml* 中设置的 `license` 值,设置为 `false` 不使用许可协议。 |

Expand Down
7 changes: 7 additions & 0 deletions test/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ paginate_path: /page:num # don't change this unless for special need
sources: # bootcdn (default), unpkg


## => Sharing
##############################
sharing:
provider: false # false (default), "addtoany"


## => Comments
##############################
comments:
Expand Down Expand Up @@ -176,6 +182,7 @@ defaults:
type: posts
values:
layout: article
sharing: true
license: true
aside:
toc: true
Expand Down
1 change: 1 addition & 0 deletions test/_data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ default:
show_tags: true
show_author_profile: false
full_width: false
sharing: false
comment: true
license: false
pageview: false
Expand Down

0 comments on commit e9bd7c2

Please sign in to comment.