Skip to content

Commit

Permalink
Remove cheers and auto_excerpt (#1284)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Nov 26, 2019
1 parent 33d3603 commit ad8065a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 38 deletions.
9 changes: 0 additions & 9 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ chat:
# Automatically excerpt description in homepage as preamble text.
excerpt_description: true

# Automatically excerpt (Not recommend).
# Use <!-- more --> in the post to control excerpt accurately.
auto_excerpt:
enable: false
length: 150

# Read more button
# If true, the read more button will be displayed in excerpt section.
read_more_btn: true
Expand Down Expand Up @@ -315,9 +309,6 @@ post_navigation: left
# See: https://theme-next.org/docs/theme-settings/custom-pages
# ---------------------------------------------------------------

# Enable "cheers" for archive page.
cheers: true

# TagCloud settings for tags page.
tagcloud:
# All values below are same as default, change them by yourself.
Expand Down
3 changes: 0 additions & 3 deletions layout/archive.swig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
{#####################}
<div class="post-block">
<div class="posts-collapse">

{%- if theme.cheers %}
<div class="collection-title">
{%- set posts_length = site.posts.length %}
{%- if posts_length > 210 %}
Expand All @@ -30,7 +28,6 @@
{%- endif %}
<span class="collection-header">{{ __('cheers.' + cheers) }}! {{ _p("counter.archive_posts", site.posts.length) }} {{ __('keep_on') }}</span>
</div>
{%- endif %}

{{ post_template.render(page.posts) }}

Expand Down
28 changes: 2 additions & 26 deletions scripts/filters/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ hexo.extend.filter.register('after_post_render', data => {
const { config } = hexo;
const theme = hexo.theme.config;
const filters = {
excerpt : theme.auto_excerpt && theme.auto_excerpt.enable && data.excerpt === '',
exturl : theme.exturl,
lazyload: theme.lazyload
};
if (!filters.excerpt && !filters.exturl && !filters.lazyload) return;
if (!filters.exturl && !filters.lazyload) return;
const cheerio = require('cheerio');
const $ = cheerio.load(data.content, {
decodeEntities: false
Expand Down Expand Up @@ -45,29 +44,6 @@ hexo.extend.filter.register('after_post_render', data => {
});
});
}
if (filters.excerpt) {
const elements = $.root().children();
const _$ = cheerio.load('', {
decodeEntities: false
});
var length = 0;
elements.each((i, o) => {
if (length > theme.auto_excerpt.length) return;
length += $(o).text().length;
_$.root().append($(o).remove());
});

if ($.root().children().length) {
data.excerpt = _$.html();
data.more = $.html();
data.content = data.excerpt + '<a id="more"></a>' + data.more;
} else {
data.excerpt = '';
data.content = _$.html();
data.more = data.content;
}
} else {
data.content = $.html();
}
data.content = $.html();

}, 20);

2 comments on commit ad8065a

@willisk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change did not remove "cheers", but rather just the check.
Cheers is enabled by default now.

@stevenjoezhang
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, there are some problems with the commit message. cheers can be hidden via css:

.collection-title { display: none! important; }

Please sign in to comment.