Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: related posts, according to #67 #109

Merged
merged 8 commits into from
Feb 9, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,19 @@ symbols_count_time:
#alipay: /images/alipay.jpg
#bitcoin: /images/bitcoin.png

# Related popular posts
# Dependencies: https://github.com/tea3/hexo-related-popular-posts
related_posts:
enable: false
title:
params:
maxCount: 5
#ulClass: 'popular-posts'
#PPMixingRate: 0.0
#isDate: false
#isImage: false
#isExcerpt: false

# Declare license on posts
post_copyright:
enable: false
Expand Down
5 changes: 5 additions & 0 deletions layout/_macro/post.swig
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
{{ post.content }}
{% endif %}
</div>

Copy link
Member

@ivan-nginx ivan-nginx Feb 9, 2018

Choose a reason for hiding this comment

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

So many for now. oO Mb move to external swig file?
Like post-copyright.swig.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ivan-nginx OK, seems now it need to be move to the single file.

{% if theme.related_posts.enable %}
{{ popular_posts(theme.related_posts.params, post) }}
{% endif %}

{#####################}
{### END POST BODY ###}
{#####################}
Expand Down
26 changes: 26 additions & 0 deletions source/css/_common/components/third-party/related-posts.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ul.popular-posts {
padding: 0;

&:before {
content: hexo-config('related_posts.title') || 'Related Posts';
Copy link
Member

Choose a reason for hiding this comment

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

I think it is better to provide i18n for the Related Posts(ie. Related Posts -> 相关文章 in language zh-CN)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, i think so too.

margin-top: $post-eof-margin-bottom;
margin-bottom: 10px;
font-size: $font-size-headings-base;
border-bottom: 1px solid $gainsboro;
display: block;
}

.popular-posts-item {
// list-style: none;
margin-left: 2em;
.popular-posts-title {
display: block;
h3 {
Copy link
Member

@ivan-nginx ivan-nginx Feb 9, 2018

Choose a reason for hiding this comment

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

H3 here? And if will seo false and then main title will H1 and no headers will used — H1-H3 space?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ivan-nginx It is generated by the plugin (https://github.com/theme-next/hexo-theme-next/pull/109/files#diff-0e030eb6dd7b9d25bfcba06bc8ea5609R337), otherwise, do we need to custom the template?

Copy link
Member

@ivan-nginx ivan-nginx Feb 9, 2018

Choose a reason for hiding this comment

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

H3 in the bottom bad for SEO. For example, if SEO will true and we will have:

H1 (site_subtitle)
  H2 (title)
    H3
      H4
        H5
    H3
      H4
    H3 (related_posts)

It's already fine with SEO. But if SEO false, then we can get fine result:

H1 (title)
  H2
    H3 (related_posts)

But we also may get bad result:

H1 (title)
  ???
    H3 (related_posts)

So, with SEO disabled & releated_posts enabled user can totally break his seo.


Headers can go forward only seriatim. And can go back with any new position (header reseting). They can't go forward bigger then 1 or more step (e.g. H4 header and after H6).
seo


.post-body {
h1 {
font-size: 1.6em;
border-bottom: 1px solid $body-bg-color;
}
h2 {
font-size: 1.45em;
border-bottom: 1px solid $body-bg-color;
}
h3 {
font-size: 1.3em;
if use_seo {
border-bottom: 1px solid $body-bg-color;
} else {
border-bottom: 1px dotted $body-bg-color;
}
}
h4 {
font-size: 1.2em;
if use_seo {
border-bottom: 1px dotted $body-bg-color;
}
}
h5 {
font-size: 1.07em;
}
h6 {
font-size: 1.03em;
}
}

font-weight: normal;
font-size: $font-size-base;
margin: 0;
line-height: $line-height-base * 1.2;
}
}
}
}
1 change: 1 addition & 0 deletions source/css/_common/components/third-party/third-party.styl
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
@import "busuanzi-counter";
@import "algolia-search" if hexo-config('algolia_search.enable');
@import "needsharebutton" if hexo-config('needmoreshare2.enable');
@import "related-posts" if hexo-config('related_posts.enable');