Skip to content

Commit

Permalink
feat: details imporve
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Jul 29, 2018
1 parent 7a1a736 commit 398967a
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 135 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Breaking changes, please check [Update form 1.x to 2.x](https://tianqi.name/jeky
### Enhancements

- MathJax Support
- Add “Read More” link at the end of article excerpt.
- Add “Read more” link at the end of article excerpt.
- 404 page

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion _data/locale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NAV:
zh-Hant: "RSS"

READMORE:
en: "Read More"
en: "Read more"
zh: "阅读更多"
zh-Hans: "阅读更多"
zh-Hant: "閱讀更多"
Expand Down
156 changes: 79 additions & 77 deletions _includes/paginator.html
Original file line number Diff line number Diff line change
@@ -1,95 +1,97 @@
<nav class="pagination">
{%- if paginator.total_pages > 1 -%}
<nav class="pagination">

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

{%- assign _post_count = site.posts | size -%}
{%- assign _page_count = paginator.total_pages -%}
<p>{{ _locale_statistics | replace: '[POST_COUNT]', _post_count | replace: '[PAGE_COUNT]', _page_count }}</p>
{%- assign _post_count = site.posts | size -%}
{%- assign _page_count = paginator.total_pages -%}
<p>{{ _locale_statistics | replace: '[POST_COUNT]', _post_count | replace: '[PAGE_COUNT]', _page_count }}</p>

<ul class="menu menu--nowrap">
{%- assign _max_show = 5 -%}
{%- assign _max_show_modulo_two = _max_show | modulo: 2 -%}
{%- assign _length = paginator.total_pages -%}
{%- assign _length_mimus_one = _length | minus: 1 -%}
{%- assign _cur = paginator.page -%}
{%- assign _extra = _max_show | minus: 3 -%}
{%- assign _extra_half = _extra | divided_by: 2 -%}
<ul class="menu menu--nowrap">
{%- assign _max_show = 5 -%}
{%- assign _max_show_modulo_two = _max_show | modulo: 2 -%}
{%- assign _length = paginator.total_pages -%}
{%- assign _length_mimus_one = _length | minus: 1 -%}
{%- assign _cur = paginator.page -%}
{%- assign _extra = _max_show | minus: 3 -%}
{%- assign _extra_half = _extra | divided_by: 2 -%}

{%- if _max_show > 4 and _max_show_modulo_two == 1 and paginator.total_pages > _max_show -%}
{%- assign _condition0 = _extra | divided_by: 2 | plus: 1 -%}
{%- assign _condition1 = _length | minus: _extra_half -%}
{%- if _cur <= _condition0 -%}
{%- assign _n0 = 2 -%}
{%- assign _n1 = _extra | plus: 2 -%}
{%- elsif _cur >= _condition1 -%}
{%- assign _n0 = _length | minus: _extra | minus: 1 -%}
{%- assign _n1 = _length | minus: 1 -%}
{%- else -%}
{%- assign _n0 = _cur | minus: _extra_half -%}
{%- assign _n1 = _cur | plus: _extra_half -%}
{%- if _max_show > 4 and _max_show_modulo_two == 1 and paginator.total_pages > _max_show -%}
{%- assign _condition0 = _extra | divided_by: 2 | plus: 1 -%}
{%- assign _condition1 = _length | minus: _extra_half -%}
{%- if _cur <= _condition0 -%}
{%- assign _n0 = 2 -%}
{%- assign _n1 = _extra | plus: 2 -%}
{%- elsif _cur >= _condition1 -%}
{%- assign _n0 = _length | minus: _extra | minus: 1 -%}
{%- assign _n1 = _length | minus: 1 -%}
{%- else -%}
{%- assign _n0 = _cur | minus: _extra_half -%}
{%- assign _n1 = _cur | plus: _extra_half -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}

{%- if paginator.previous_page -%}
{%- include snippets/prepend-baseurl.html path=paginator.previous_page_path -%}
{%- assign _href = __return -%}
<li><a class="button button--secondary button--circle" href="{{ _href }}">
<i class="fas fa-angle-left"></i>
</a></li>
{%- else -%}
<li><div class="button button--secondary button--circle disabled">
<i class="fas fa-angle-left"></i>
</div></li>
{%- endif -%}
{%- if paginator.previous_page -%}
{%- include snippets/prepend-baseurl.html path=paginator.previous_page_path -%}
{%- assign _href = __return -%}
<li><a class="button button--secondary button--circle" href="{{ _href }}">
<i class="fas fa-angle-left"></i>
</a></li>
{%- else -%}
<li><div class="button button--secondary button--circle disabled">
<i class="fas fa-angle-left"></i>
</div></li>
{%- endif -%}

{%- for page in (1.._length) -%}
{%- if page == _cur -%}
<li>
<div class="button button--primary button--circle focus"><span>{{ page }}</span></div>
</li>
{%- for page in (1.._length) -%}
{%- if page == _cur -%}
<li>
<div class="button button--primary button--circle focus"><span>{{ page }}</span></div>
</li>

{%- elsif page == 1 -%}
{%- assign _home_path = site.paths.home | default: site.data.variables.default.paths.home -%}
{%- include snippets/prepend-baseurl.html path=_home_path -%}
{%- assign _href = __return -%}
<li>
<a class="button button--secondary button--circle" href="{{ _href }}"><span>{{ page }}</span></a>
</li>
{%- elsif page == 1 -%}
{%- assign _home_path = site.paths.home | default: site.data.variables.default.paths.home -%}
{%- include snippets/prepend-baseurl.html path=_home_path -%}
{%- assign _href = __return -%}
<li>
<a class="button button--secondary button--circle" href="{{ _href }}"><span>{{ page }}</span></a>
</li>

{%- else -%}
{%- if _n0 and _n1 -%}
{%- if page > 1 and page < _n0 -%}
{%- if page == 2 -%}<li><span class="pagination__omit"><i class="fas fa-ellipsis-h"></i></span></li>{%- endif -%}
{%- elsif page > _n1 and page < _length -%}
{%- if page == _length_mimus_one -%}<li><span class="omit"><i class="fas fa-ellipsis-h"></i></span></li>{%- endif -%}
{%- else -%}
{%- if _n0 and _n1 -%}
{%- if page > 1 and page < _n0 -%}
{%- if page == 2 -%}<li><span class="pagination__omit"><i class="fas fa-ellipsis-h"></i></span></li>{%- endif -%}
{%- elsif page > _n1 and page < _length -%}
{%- if page == _length_mimus_one -%}<li><span class="omit"><i class="fas fa-ellipsis-h"></i></span></li>{%- endif -%}
{%- else -%}
{%- include snippets/prepend-baseurl.html path=site.paginate_path -%}
{%- assign _href = __return -%}
<li>
<a class="button button--secondary button--circle" href="{{ _href | replace: ':num', page }}"><span>{{ page }}</span></a>
</li>
{%- endif -%}
{%- else -%}
{%- include snippets/prepend-baseurl.html path=site.paginate_path -%}
{%- assign _href = __return -%}
<li>
<a class="button button--secondary button--circle" href="{{ _href | replace: ':num', page }}"><span>{{ page }}</span></a>
</li>
{%- endif -%}
{%- else -%}
{%- include snippets/prepend-baseurl.html path=site.paginate_path -%}
{%- assign _href = __return -%}
<li>
<a class="button button--secondary button--circle" href="{{ _href | replace: ':num', page }}"><span>{{ page }}</span></a>
</li>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}

{%- if paginator.next_page -%}
{%- include snippets/prepend-baseurl.html path=paginator.next_page_path -%}
{%- assign _href = __return -%}
<li><a class="button button--secondary button--circle" href="{{ _href }}">
<i class="fas fa-angle-right"></i>
</a></li>
{%- else -%}
<li><div class="button button--secondary button--circle disabled">
<i class="fas fa-angle-right"></i>
</div></li>
{%- endif -%}
</ul>
</nav>
{%- if paginator.next_page -%}
{%- include snippets/prepend-baseurl.html path=paginator.next_page_path -%}
{%- assign _href = __return -%}
<li><a class="button button--secondary button--circle" href="{{ _href }}">
<i class="fas fa-angle-right"></i>
</a></li>
{%- else -%}
<li><div class="button button--secondary button--circle disabled">
<i class="fas fa-angle-right"></i>
</div></li>
{%- endif -%}
</ul>
</nav>
{%- endif -%}
16 changes: 7 additions & 9 deletions _includes/scripts/aside/affix.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
var tocDisabled = false;
var hasSidebar = $('.js-page-root').hasClass('layout--page--sidebar');

setTimeout(function() {
affix = $pageAside.affix({
offsetBottom: $pageFooter.outerHeight(),
scrollTarget: hasSidebar ? '.js-page-main' : null,
scroller: hasSidebar ? '.js-page-main' : null,
scroll: hasSidebar ? $('.js-page-main').children() : null,
disabled: tocDisabled
});
}, 1000);
affix = $pageAside.affix({
offsetBottom: $pageFooter.outerHeight(),
scrollTarget: hasSidebar ? '.js-page-main' : null,
scroller: hasSidebar ? '.js-page-main' : null,
scroll: hasSidebar ? $('.js-page-main').children() : null,
disabled: tocDisabled
});

$window.on('resize', window.throttle(function() {
affix && affix.setOptions({
Expand Down
53 changes: 30 additions & 23 deletions _includes/scripts/lib/affix.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
var SOURCES = window.TEXT_VARIABLES.sources;
window.Lazyload.js(SOURCES.jquery, function() {
var $window = $(window), $root, $scrollTarget, $scroller, $scroll;
var rootTop, rootLeft, rootHeight, scrollBottom, rootBottomTop, lastScrollTop;
var rootTop, rootLeft, rootHeight, scrollBottom, rootBottomTop;
var offsetBottom = 0, disabled = false, scrollTarget = window, scroller = 'html, body', scroll = window.document;
var hasInit = false, isOverallScroller = true;
var hasInit = false, isOverallScroller = true, curState;

function setOptions(options) {
var _options = options || {};
Expand All @@ -31,43 +31,50 @@
rootBottomTop = scrollBottom - rootTop;
}
function top() {
$root.removeClass('fixed').css({
left: 0,
top: 0
});
if (curState !== 'top') {
$root.removeClass('fixed').css({
left: 0,
top: 0
});
curState = 'top';
}
}
function fixed() {
$root.addClass('fixed').css({
left: rootLeft + 'px',
top: 0
});
if (curState !== 'fixed') {
$root.addClass('fixed').css({
left: rootLeft + 'px',
top: 0
});
curState = 'fixed';
}
}
function bottom() {
$root.removeClass('fixed').css({
left: 0,
top: rootBottomTop + 'px'
});
if (curState !== 'bottom') {
$root.removeClass('fixed').css({
left: 0,
top: rootBottomTop + 'px'
});
curState = 'bottom';
}
}
function setState(force) {
force !== true && (force = false);
function setState() {
var scrollTop = $scrollTarget.scrollTop();
if (scrollTop >= rootTop && scrollTop <= scrollBottom) {
(!force && lastScrollTop >= rootTop && lastScrollTop <= scrollBottom) || fixed();
fixed();
} else if (scrollTop < rootTop) {
(!force && lastScrollTop < rootTop) || top();
top();
} else {
(!force && lastScrollTop > scrollBottom) || bottom();
bottom();
}
lastScrollTop = scrollTop;
}
function init() {
if(!hasInit) {
var interval, timeout;
calc(true); setState();
// run calc every 0.5 seconds
// run calc every 100 millisecond
interval = setInterval(function() {
calc();
}, 500);
}, 100);
timeout = setTimeout(function() {
clearInterval(interval);
}, 60000);
Expand All @@ -81,7 +88,7 @@
disabled || setState();
});
$window.on('resize', window.throttle(function() {
disabled || (calc(true), setState(true));
disabled || (calc(true), setState());
}, 100));
hasInit = true;
}
Expand Down
4 changes: 2 additions & 2 deletions _includes/scripts/lib/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
var interval, timeout;
if(!hasInit) {
render(); calc(); setState(null, scrolling);
// run calc every 0.5 seconds
// run calc every 100 millisecond
interval = setInterval(function() {
calc();
}, 500);
}, 100);
timeout = setTimeout(function() {
clearInterval(interval);
}, 60000);
Expand Down
7 changes: 2 additions & 5 deletions _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@
{%- endif -%}
</div>

<p><a href="{{ _href }}">{{ _locale_readmore }}</a></p>
<p class="post-list__readmore"><a href="{{ _href }}">{{ _locale_readmore }}</a></p>
{%- include article-info.html -%}
</article>
{%- endfor -%}
</div>


{%- if paginator.total_pages > 1 -%}
{%- include paginator.html -%}
{%- endif -%}
{%- include paginator.html -%}
</div>

<script>
Expand Down
2 changes: 1 addition & 1 deletion _posts/2018-07-01-welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ key: 20180701
tags: TeXt
---

If you see this page, that means you have setup your site. enjoy :ghost: :ghost: :ghost:!
If you see this page, that means you have setup your site. enjoy! :ghost: :ghost: :ghost:

<!--more-->

Expand Down
3 changes: 3 additions & 0 deletions _sass/layout/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
max-height: 12rem;
}
}
.post-list__readmore {
font-size: map-get($base, font-size-sm);
}
}

.pagination {
Expand Down
8 changes: 4 additions & 4 deletions _sass/skins/_chocolate.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ $mask-color: rgba(#000, .8);
$select-color: rgba($main-color-3, .5);

// function colors
$green: #74a851;
$blue: #3b8e98;
$yellow: #d8a348;
$red: #d23442;
$green: #5baa34;
$blue: #1c7cd4;
$yellow: #c9771f;
$red: #da3d45;
$text-color-function: rgba(#fff, .85);

// logo colors
Expand Down
8 changes: 4 additions & 4 deletions _sass/skins/_dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ $mask-color: rgba(#000, .8);
$select-color: rgba($main-color-1, .5);

// function colors
$green: #74a851;
$blue: #3b8e98;
$yellow: #d8a348;
$red: #d23442;
$green: #5baa34;
$blue: #1c7cd4;
$yellow: #c9771f;
$red: #da3d45;
$text-color-function: rgba(#fff, .8);

// logo colors
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/locale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NAV:
zh-Hant: "RSS"

READMORE:
en: "Read More"
en: "Read more"
zh: "阅读更多"
zh-Hans: "阅读更多"
zh-Hant: "閱讀更多"
Expand Down
Loading

0 comments on commit 398967a

Please sign in to comment.