Skip to content

Commit

Permalink
feat: search panel, article-list
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Aug 12, 2018
1 parent 5056c80 commit 2465d59
Show file tree
Hide file tree
Showing 45 changed files with 618 additions and 392 deletions.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Prefer English -->

## Description

[Description of the bug, feature or question]

## Steps to Reproduce (Bugs Only)

1. [First Step]
2. [Second Step]
3. [and so on...]

**Expected behavior:** [What you expected to happen]

**Actual behavior:** [What actually happened]

## Environment (If Necessary)

- OS: [e.g. Github Pages, Windows 10, macOS 10.13, Linux(CentOS 7.5), iOS 11, Android 8(Pixel 2)]
- Ruby: [e.g. Github Pages, 2.4.0p0]
- Jekyll: [e.g. Github Pages, 3.7.3]
- Broser: [e.g. Chrome, Safari, Edge, Firefox]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ package-lock.json

# jekyll
Gemfile.lock
package-lock.json
_site/
.sass-cache/
.jekyll-metadata
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ paths:
home : # home layout url, "/" (default)
archive : # "/archive.html" (default)
rss : # "/feed.xml" (default)
search_json: # "/search.json" (default)


## => Post
Expand Down
6 changes: 6 additions & 0 deletions _data/locale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ READMORE:
zh-Hans: "阅读更多"
zh-Hant: "閱讀更多"

CANCEL:
en: "Cancle"
zh: "取消"
zh-Hans: "取消"
zh-Hant: "取消"

VIEWS:
en: "views"
zh: "阅读"
Expand Down
1 change: 1 addition & 0 deletions _data/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ default:
home: /
archive: /archive.html
rss: /feed.xml
search_json: /search.json
mathjax: false
mathjax_autoNumber: false
mermaid: false
Expand Down
54 changes: 19 additions & 35 deletions _includes/article-info.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
{%- if post -%}
{%- assign _cur_page = post -%}
{%- elsif page -%}
{%- assign _cur_page = page -%}
{%- endif -%}

{%- include snippets/assign.html target=site.data.variables.default.pageview source0=page.pageview -%}
{%- assign _pageview = __return -%}

{%- assign _paths_archive = site.paths.archive | default: site.data.variables.default.paths.archive -%}

{%- if _cur_page.author -%}
{%- assign _author = site.data.authors[_cur_page.author] -%}
{%- if include.article.author -%}
{%- assign _author = site.data.authors[include.article.author] -%}
{%- else -%}
{%- assign _author = site.author -%}
{%- endif -%}
Expand All @@ -22,57 +16,47 @@
<meta itemprop="author" content="{{ _author.name }}"/>
{%- endif -%}

{%- if _cur_page.tags[0] -%}
{%- if include.article.tags[0] -%}
<ul class="left-col menu">

{%- assign _keywords = '' -%}
{%- for _tag in _cur_page.tags -%}
{%- assign _tag_path = _paths_archive | append: '?tag=' -%}
{%- include snippets/prepend-baseurl.html path=_tag_path -%}

{%- for _tag in include.article.tags -%}
{%- assign _tag_path = __return -%}
{%- assign _tag_encode = _tag | strip | url_encode } -%}
{%- if forloop.last -%}
{%- assign _keywords = _keywords | append: _tag -%}
{%- else -%}
{%- assign _keywords = _keywords | append: _tag | append: ',' -%}
{%- endif -%}
{%- assign _tag_path = _paths_archive | append: '?tag=' -%}
{%- include snippets/prepend-baseurl.html path=_tag_path -%}
<li>
<a class="button button--secondary button--pill button--sm"
href="{{ __return | append: _tag_encode | replace: '//', '/' }}">{{ _tag }}</a>
href="{{ _tag_path | append: _tag_encode | replace: '//', '/' }}">{{ _tag }}</a>
</li>
{%- endfor -%}
<meta itemprop="keywords" content="{{ _keywords }}">
{%- assign _keywords = include.article.tags | join: ',' %}
</ul>
<meta itemprop="keywords" content="{{ _keywords }}">
{%- endif -%}


{%- if (_pageview or post) or _cur_page.date -%}
{%- if include.article.author or include.article.date or _pageview or post -%}
<ul class="right-col menu">
{%- if !_cur_page.author -%}
<li><i class="fas fa-user"></i> <span>{{ _author.name }}</span></li>
{%- if include.article.author -%}
<li><i class="fas fa-user"></i> <span>{{ _author.name }}</span></li>
{%- endif -%}

{%- if _cur_page.date -%}
{%- if include.article.date -%}
<li>
{%- include snippets/locale-to-string.html locale=site.data.locale.ARTICLE_DATE_FORMAT -%}
{%- 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 -%}
<i class="far fa-calendar-alt"></i> <span>{{ include.article.date | date: __return }}</span>
<meta itemprop="datePublished" content="{{ include.article.date | date_to_xmlschema }}">
</li>
{%- endif -%}

{%- if _pageview or post -%}
{%- if _pageview or include.show_pageview -%}
{%- if site.pageview.provider -%}

{%- include snippets/locale-to-string.html locale=site.data.locale.VIEWS -%}
{%- assign _locale_views = __return -%}

<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> {{ _locale_views }}
<i class="far fa-eye"></i> <span class="js-pageview" data-page-key="{{ include.article.key }}">0</span> {{ _locale_views }}
</li>
{%- endif -%}
{%- endif -%}
Expand Down
71 changes: 71 additions & 0 deletions _includes/article-list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{%- assign _excerpt_truncate = include.excerpt_truncate | default: 350 -%}

{%- assign _excerpt_type = include.excerpt_type | default: site.data.variables.default.excerpt_type -%}

{%- assign _sorted_list = include.articles -%}
{%- if include.group_by == 'year' -%}
{%- assign _sorted_list = _sorted_list | sort: 'date' -%}
{%- endif -%}
{%- if include.reverse -%}
{%- assign _sorted_list = _sorted_list | reverse -%}
{%- endif -%}

{%- if include.type == 'common' -%}
<div class="article-list--common">
{%- elsif include.type == 'brief' -%}
<div class="article-list--brief">
{%- endif -%}

{%- for _article in _sorted_list -%}

{%- include snippets/prepend-baseurl.html path=_article.url -%}
{%- assign _href = __return -%}

{%- include snippets/locale-to-string.html locale=site.data.locale.READMORE -%}
{%- assign _locale_readmore = __return -%}

{%- if include.type == 'common' -%}

<article itemscope itemtype="http://schema.org/BlogPosting">
<header class="article__header"><h2 itemprop="headline"><a href="{{ _href }}">{{ _article.title }}</a></h2></header>
{%- if _article.excerpt and include.show_excerpt -%}
<div class="article__content" itemprop="description articleBody">
{%- if _excerpt_type == 'html' -%}
{{ _article.excerpt }}
{%- else -%}
{{ _article.excerpt | strip_html | truncate: _excerpt_truncate }}
{%- endif -%}
</div>
{%- endif -%}
<p class="readmore"><a href="{{ _href }}">{{ _locale_readmore }}</a></p>
{%- include article-info.html article=_article show_pageview=true -%}
</article>


{%- elsif include.type == 'brief' -%}
{%- assign _tags = '' -%}
{%- for _tag in _article.tags -%}
{%- assign _tag_encode = _tag | strip | url_encode } -%}
{%- if forloop.last -%}
{%- assign _tags = _tags | append: _tag_encode -%}
{%- else -%}
{%- assign _tags = _tags | append: _tag_encode | append: ',' -%}
{%- endif -%}
{%- endfor -%}
{%- include snippets/locale-to-string.html locale=site.data.locale.ARTICLE_DATE_FORMAT -%}
{%- if include.group_by == 'year' -%}
{%- assign _currentdate = _article.date | date: '%Y' -%}
{%- if _currentdate != _date -%}
{%- unless forloop.first -%}</section>{%- endunless -%}
<section><h2 class="group">{{ _currentdate }}</h2>
{%- assign _date = _currentdate -%}
{%- endif -%}
{%- endif -%}
<article itemscope itemtype="http://schema.org/BlogPosting" data-tags="{{ _tags }}">
<span class="date">{{ _article.date | date: __return }}</span><a itemprop="headline" class="title" href="{{ _href }}">{{ _article.title }}</a>
<meta itemprop="datePublished" content="{{ include.article.date | date_to_xmlschema }}">
</article>
{%- endif -%}

{%- endfor -%}
</div>
13 changes: 13 additions & 0 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,21 @@
<li><a href="{{ _nav_url }}">{%- if _item.title -%}{{ _item.title }}{%- else -%}{{ __return }}{%- endif -%}</a></li>
{%- endif -%}
{%- endfor -%}
<li><button class="button button--secondary button--circle js-search-button"><i class="fas fa-search"></i></button></li>
</ul>
</nav>
{%- endif -%}
</div>
</header>
<script>
(function() {
var SOURCES = window.TEXT_VARIABLES.sources;
window.Lazyload.js(SOURCES.jquery, function() {
var $pageRoot = $('.js-page-root');
var $searchButton = $('.js-search-button');
$searchButton.on('click', function() {
$pageRoot.toggleClass('show-search-panel');
});
});
})();
</script>
6 changes: 3 additions & 3 deletions _includes/markdown-enhancements.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{%- include snippets/assign.html target = site.data.variables.default.chart source0=site.chart -%}
{%- include snippets/assign.html target=site.data.variables.default.chart source0=site.chart -%}
{%- include snippets/assign.html target=__return source0=page.chart -%}

{%- if __return == true -%}
{%- include markdown-enhancements/chart.html -%}
{%- endif -%}

{%- include snippets/assign.html target = site.data.variables.default.mathjax source0=site.mathjax -%}
{%- include snippets/assign.html target=site.data.variables.default.mathjax source0=site.mathjax -%}
{%- include snippets/assign.html target=__return source0=page.mathjax -%}

{%- if __return == true -%}
{%- include markdown-enhancements/mathjax.html -%}
{%- endif -%}

{%- include snippets/assign.html target = site.data.variables.default.mermaid source0=site.mermaid -%}
{%- include snippets/assign.html target=site.data.variables.default.mermaid source0=site.mermaid -%}
{%- include snippets/assign.html target=__return source0=page.mermaid -%}

{%- if __return == true -%}
Expand Down
Loading

0 comments on commit 2465d59

Please sign in to comment.