Skip to content

Commit

Permalink
feat: add author configs
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Jun 24, 2018
1 parent 84c58d0 commit 4e87359
Show file tree
Hide file tree
Showing 33 changed files with 546 additions and 223 deletions.
57 changes: 35 additions & 22 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ timezone: # see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for
## => Author and Social
##############################
author:
name: Someone
email: someone@somemail.com # your Email address e.g. someone@site.com
type: # "person" (default), "organization"
name: Someone # your name
avatar: # your Photo or Logo
bio: # your biographical work
email: # your Email address e.g. neo@site.com
facebook: # your Facebook username
twitter: # your Twitter username
github: # your GitHub username
Expand Down Expand Up @@ -95,35 +98,45 @@ sources: # bootcdn (default), unpkg

## => Comments
##############################
## Disqus
disqus:
shortname: # the Disqus shortname for the site
comments:
provider: false # false (default), "disqus", "gitalk", "custom"

## Gitalk
# please refer to https://github.com/gitalk/gitalk for more info.
gitalk:
clientID: # GitHub Application Client ID
clientSecret: # GitHub Application Client Secret
repository: # GitHub repo
owner: # GitHub repo owner
admin: # GitHub repo owner and collaborators, only these guys can initialize GitHub issues, IT IS A LIST.
# - your GitHub Id
## Disqus
disqus:
shortname: # the Disqus shortname for the site

## Gitalk
# please refer to https://github.com/gitalk/gitalk for more info.
gitalk:
clientID: # GitHub Application Client ID
clientSecret: # GitHub Application Client Secret
repository: # GitHub repo
owner: # GitHub repo owner
admin: # GitHub repo owner and collaborators, only these guys can initialize GitHub issues, IT IS A LIST.
# - your GitHub Id


## => Pageview
##############################
## Leancloud
leancloud:
app_id: # LeanCloud App id
app_key: # LeanCloud App key
app_class: # LeanCloud App class
pageview:
provider: false # false (default), "leancloud", "custom"

## Leancloud
leancloud:
app_id: # LeanCloud App id
app_key: # LeanCloud App key
app_class: # LeanCloud App class


## => Analytics
##############################
## Google Analytics
ga_tracking_id: # Google Analytics id for the site
ga_anonymize_ip: false # Anonymize IP tracking for Analytics
analytics:
provider: false # false (default), "google", "custom"

## Google Analytics
google:
tracking_id: # Google Analytics id for the site
anonymize_ip: false # Anonymize IP tracking for Analytics


## => Build
Expand Down
Empty file added _data/authors.yml
Empty file.
1 change: 1 addition & 0 deletions _data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ default:
show_header: true
show_title: true
show_edit_on_github: false
show_author_profile: false
full_width: false
pageview: false

Expand Down
2 changes: 1 addition & 1 deletion _includes/article-footer/license.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

{%- if _license -%}

{%-assign _license_name = '<a rel="license" href="[URL]">[NAME]</a>' | replace: "[URL]", _license.url | replace: "[NAME]", _license.name -%}
{%-assign _license_name = '<a itemprop="license" rel="license" href="[URL]">[NAME]</a>' | replace: "[URL]", _license.url | replace: "[NAME]", _license.name -%}
<div class="license">
<p>{{ _license_announce | replace: "[LICENSE]", _license_name }}
<a rel="license" href="{{ _license.url }}">
Expand Down
102 changes: 56 additions & 46 deletions _includes/article-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,66 @@
{%- assign _pageview = __return -%}

<div class="article__info clearfix">
{%- if page -%}
<meta itemprop="author" itemscope itemtype="https://schema.org/Person">
{%- if page.author -%}
<meta itemprop="name" content="{{ page.author }}"/>
{%- elsif site.author.name -%}
<meta itemprop="name" content="{{ site.author.name }}"/>
{%- if cur_page.tags[0] -%}
<ul class="left-col menu">
{%- if site.paths.all -%}
{%- assign all_path = site.paths.all -%}
{%- else -%}
{%- assign all_path = site.data.variables.default.paths.all -%}
{%- endif -%}
</meta>
{%- endif -%}
{%- if cur_page.tags[0] -%}
<ul class="left-col menu">
{%- if site.paths.all -%}
{%- assign all_path = site.paths.all -%}
{%- assign _keywords = '' -%}
{%- for _tag in cur_page.tags -%}
{%- assign _tag_encode = _tag | strip | url_encode } -%}
{%- if forloop.last -%}
{%- assign _keywords = _keywords | append: _tag -%}
{%- else -%}
{%- assign all_path = site.data.variables.default.paths.all -%}
{%- assign _keywords = _keywords | append: _tag | append: ',' -%}
{%- endif -%}
{%- for tag in cur_page.tags -%}
{%- assign _tag = tag | strip | url_encode } -%}
{%- assign __path = all_path | append: '?tag=' -%}
{%- include snippets/prepend-baseurl.html -%}
<li>
<a class="button button--secondary button--pill button--sm" href="{{ __return | append: _tag | replace: '//', '/' }}">{{ tag }}</a>
</li>
{%- endfor -%}
</ul>
{%- endif -%}
{%- if (_pageview or post) or cur_page.date -%}
<ul class="right-col menu">
{%- if _pageview or post -%}
{%- if site.pageview.provider -%}
{%- assign __locale = site.data.locale.VIEWS } -%}
{%- include snippets/locale-to-string.html -%}
<li class="pageview">
<span class="js-pageview" data-page-key="{{ cur_page.key }}">0</span> {{ __return }}
</li>
{%- assign __path = all_path | append: '?tag=' -%}
{%- include snippets/prepend-baseurl.html -%}
<li>
<a class="button button--secondary button--pill button--sm" href="{{ __return | append: _tag_encode | replace: '//', '/' }}">{{ _tag }}</a>
</li>
{%- endfor -%}
<meta itemprop="keywords" content="{{ _keywords }}">
</ul>
{%- endif -%}
{%- if (_pageview or post) or cur_page.date -%}
<ul class="right-col menu">
{%- if cur_page.author -%}
{%- assign _author = site.data.authors[cur_page.author] -%}
<li><i class="fas fa-user"></i> <span>{{ _author.name }}</span></li>
{%- else -%}
{%- assign _author = site.author -%}
{%- endif -%}
{%- if _author -%}
<meta itemprop="author" content="{{ _author.name }}"/>
{%- endif -%}

{%- if cur_page.date -%}
<li>
{%- assign __locale = site.data.locale.ARTICLE_DATE_FORMAT } -%}
{%- include snippets/locale-to-string.html -%}
{%- if post -%}
<i class="far fa-calendar-alt"></i> <span itemprop="datePublished">{{ cur_page.date | date: __return }}</span>
{%- elsif page -%}
<i class="far fa-calendar-alt"></i> <time datetime="{{ page.date | date_to_xmlschema }}"
itemprop="datePublished">{{ cur_page.date | date: __return }}
</time>
{%- endif -%}
{%- endif -%}
{%- if cur_page.date -%}
<li class="publish-date">
{%- assign __locale = site.data.locale.ARTICLE_DATE_FORMAT } -%}
{%- include snippets/locale-to-string.html -%}
{%- if post -%}
<span>{{ cur_page.date | date: __return }}</span>
{%- elsif page -%}
<time datetime="{{ page.date | date_to_xmlschema }}"
itemprop="datePublished">{{ cur_page.date | date: __return }}
</time>
{%- endif -%}
</li>
{%- endif -%}

{%- if _pageview or post -%}
{%- if site.pageview.provider -%}
{%- assign __locale = site.data.locale.VIEWS } -%}
{%- include snippets/locale-to-string.html -%}
<li itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter">
<link itemprop="interactionType" href="http://schema.org/WatchAction"/>
<i class="far fa-eye"></i> <span class="js-pageview" data-page-key="{{ cur_page.key }}">0</span> {{ __return }}
</li>
{%- endif -%}
</ul>
{%- endif -%}
{%- endif -%}
</ul>
{%- endif -%}
</div>
40 changes: 40 additions & 0 deletions _includes/author-profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{%- if __author -%}
{%- assign _author = __author -%}
{%- else -%}
{%- assign _author = site.author -%}
{%- endif -%}

{%- if _author.type == 'organization' -%}
{%- assign _author_itemtype = 'http://schema.org/Organization' -%}
{%- else -%}
{%- assign _author_itemtype = 'http://schema.org/Person' -%}
{%- endif -%}
<div itemscope itemtype="{{ _author_itemtype }}" class="author-profile card card--no-shadow clearfix">
{%- if _author.avatar -%}
{%- if _author.url -%}
<a href="{{ _author.url }}">
{%- endif -%}
<img itemprop="image" class="left-col" src="{{ _author.avatar }}"></img>
{%- if _author.url -%}
</a>
{%- endif -%}
{%- endif -%}
<div class="right-col clearfix">
{%- if _author.name -%}
<meta itemprop="name" content="{{ _author.name }}">
<p class="author-profile__name">
{%- if _author.url -%}
<meta itemprop="name" content="{{ _author.url }}">
<a href="{{ _author.url }}">
{%- endif -%}
{{ _author.name }}
{%- if _author.url -%}
</a>
{%- endif -%}
</p>
{%- endif -%}
{%- if _author.bio -%}<p itemprop="description">{{ _author.bio }}</p>{%- endif -%}
{%- assign __author = _author -%}
{%- include follow-me.html -%}
</div>
</div>
47 changes: 26 additions & 21 deletions _includes/follow-me.html
Original file line number Diff line number Diff line change
@@ -1,64 +1,69 @@
{%- if __author -%}
{%- assign _author = __author -%}
{%- else -%}
{%- assign _author = site.author -%}
{%- endif -%}

<div class="follow-me">
<ul class="menu menu--nowrap menu--center" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="{{ site.author.name }}">
{%- assign __path = '/'-%}
{%- include snippets/prepend-baseurl.html -%}
<link itemprop="url" href="{{ __return | prepend: site.url }}">
<ul class="menu menu--nowrap menu--center">
{%- if _author.url -%}
<link itemprop="url" href="{{ _author.url }}">
{%- endif -%}
{%- assign __locale = site.data.locale.EMAIL_ME -%}
{%- include snippets/locale-to-string.html -%}
{%- if site.author.email -%}
{%- if _author.email -%}
<li title="{{ __return }}">
<a class="button button--circle mail-button" itemprop="sameAs" href="mailto:{{ site.author.email }}" target="_blank">
<a class="button button--circle mail-button" itemprop="email" href="mailto:{{ _author.email }}" target="_blank">
<i class="fas fa-envelope"></i>
</a>
{%- endif -%}
{%- assign __locale = site.data.locale.FOLLOW_ME -%}
{%- include snippets/locale-to-string.html -%}
{%- if site.author.weibo -%}
{%- if _author.weibo -%}
<li title="{{ __return | replace: '[NAME]', 'Weibo' }}">
<a class="button button--circle weibo-button" itemprop="sameAs" href="https://weibo.com/{{ site.author.weibo }}" target="_blank">
<a class="button button--circle weibo-button" itemprop="sameAs" href="https://weibo.com/{{ _author.weibo }}" target="_blank">
<div class="icon">{%- include svg/icon/social/weibo.svg -%}</div>
</a>
</li>
{%- endif -%}
{%- if site.author.facebook -%}
{%- if _author.facebook -%}
<li title="{{ __return | replace: '[NAME]', 'Facebook' }}">
<a class="button button--circle facebook-button" itemprop="sameAs" href="https://www.facebook.com/{{ site.author.facebook }}" target="_blank">
<a class="button button--circle facebook-button" itemprop="sameAs" href="https://www.facebook.com/{{ _author.facebook }}" target="_blank">
<div class="icon">{%- include svg/icon/social/facebook.svg -%}</div>
</a>
</li>
{%- endif -%}
{%- if site.author.twitter -%}
{%- if _author.twitter -%}
<li title="{{ __return | replace: '[NAME]', 'Twitter' }}">
<a class="button button--circle twitter-button" itemprop="sameAs" href="https://twitter.com/{{ site.author.twitter }}" target="_blank">
<a class="button button--circle twitter-button" itemprop="sameAs" href="https://twitter.com/{{ _author.twitter }}" target="_blank">
<div class="icon">{%- include svg/icon/social/twitter.svg -%}</div>
</a>
</li>
{%- endif -%}
{%- if site.author.googleplus -%}
{%- if _author.googleplus -%}
<li title="{{ __return | replace: '[NAME]', 'Google+' }}">
<a class="button button--circle googlepluse-button" itemprop="sameAs" href="https://plus.google.com/u/0/{{ site.author.googleplus }}" target="_blank">
<a class="button button--circle googlepluse-button" itemprop="sameAs" href="https://plus.google.com/u/0/{{ _author.googleplus }}" target="_blank">
<div class="icon">{%- include svg/icon/social/googleplus.svg -%}</div>
</a>
</li>
{%- endif -%}
{%- if site.author.github -%}
{%- if _author.github -%}
<li title="{{ __return | replace: '[NAME]', 'Github' }}">
<a class="button button--circle github-button" itemprop="sameAs" href="https://github.com/{{ site.author.github }}" target="_blank">
<a class="button button--circle github-button" itemprop="sameAs" href="https://github.com/{{ _author.github }}" target="_blank">
<div class="icon">{%- include svg/icon/social/github.svg -%}</div>
</a>
</li>
{%- endif -%}
{%- if site.author.linkedin -%}
{%- if _author.linkedin -%}
<li title="{{ __return | replace: '[NAME]', 'Linkedin' }}">
<a class="button button--circle linkedin-button" itemprop="sameAs" href="https://www.linkedin.com/in/{{ site.author.linkedin }}" target="_blank">
<a class="button button--circle linkedin-button" itemprop="sameAs" href="https://www.linkedin.com/in/{{ _author.linkedin }}" target="_blank">
<div class="icon">{%- include svg/icon/social/linkedin.svg -%}</div>
</a>
</li>
{%- endif -%}
{%- if site.author.douban -%}
{%- if _author.douban -%}
<li title="{{ __return | replace: '[NAME]', 'Douban' }}">
<a class="button button--circle douban-button" itemprop="sameAs" href="https://www.douban.com/people/{{ site.author.douban }}" target="_blank">
<a class="button button--circle douban-button" itemprop="sameAs" href="https://www.douban.com/people/{{ _author.douban }}" target="_blank">
<div class="icon">{%- include svg/icon/social/douban.svg -%}</div>
</a>
</li>
Expand Down
22 changes: 21 additions & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@

<div class="footer js-page-footer">
<div class="main">
<aside> {%- include follow-me.html -%} </aside>
{%- assign __author = site.author -%}
{%- if __author.type == 'organization' -%}
{%- assign _author_itemtype = 'http://schema.org/Organization' -%}
{%- else -%}
{%- assign _author_itemtype = 'http://schema.org/Person' -%}
{%- endif -%}
<aside itemscope itemtype="{{ _author_itemtype }}">
<meta itemprop="name" content="{{ __author.name }}">
{%- if __author.url -%}
{%- assign _author_url = __author.url -%}
{%- else -%}
{%- assign __path = '/'-%}
{%- include snippets/prepend-baseurl.html -%}
{%- assign _author_url = __return -%}
{%- endif -%}
<meta itemprop="url" content="{{ _author_url }}">
{%- if __author.bio -%}
<meta itemprop="description" content="{{ __author.bio }}">
{%- endif -%}
{%- include follow-me.html -%}
</aside>
<footer class="site-info">
{%- assign __path = site.paths.rss | default: site.data.variables.default.paths.rss -%}
{%- include snippets/get-nav-url.html -%}
Expand Down
2 changes: 1 addition & 1 deletion _includes/pageview-providers/leancloud/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var $this = $(this);
var key = $this.attr('data-page-key');
pageview.get(key, function(view) {
$this.text(view);
$this.attr('itemprop', 'userInteractionCount').attr('content', view).text(view);
});
});
});
Expand Down
Loading

0 comments on commit 4e87359

Please sign in to comment.