tea3 / hexo-related-popular-posts

A hexo plugin that generates a list of links to related posts and popular posts. Also , this plugin can get Visitor Counts (PV) on posts.
MIT License
109 stars 14 forks source link

isImageとisExcerptはfrontmatterで設定してもjsonでは取得できない #13

Closed minhnh94 closed 5 years ago

minhnh94 commented 5 years ago

有用なプラグインありがとうございます。使わせていただいています。 ちょっと質問なんですが、popular_posts_json()が返している { date: '', img: '', title: 'Mentality to fight against loneliness and depression', path: '/en/lifestyle/mentality-to-fight-against-loneliness-and-depression/', excerpt: '' } のような戻り値ですがimgとexcerptは空っぽです。 markdownファイルのfrontmatterでimgとexcerptを定義するようにしていますがここの戻り値ではゲットできないです。 どういう定義しかたでimgとexcerptが取得できるのですか?

tea3 commented 5 years ago

@minhnh94

Thank you for using this plugin. To get img and excerpt, please specify eyeCatchImage and description in frontmatter of markdown file. For example, it is a description example as follows.

プラグインをご利用いただきありがとうございます。imgexcerptを取得するには、markdownファイルのfrontmatterでeyeCatchImagedescriptionを指定してください。例えば次のような記述例となります。

Step1. Description example of frontmatter

---
title:  Title sample
tags:
  - program
  - diary
  - web
date: 2018-10-17 12:00:00
eyeCatchImage: https://sample.image-01.jpg
description: Write excerpt here.
---

hoge hoge

Also, it is possible to omit eyeCatchImage. In this case, the image file that appears first in the article is automatically acquired as img.

また、eyeCatchImageを省略することが可能です。この場合は、記事の中で1番目に登場する画像ファイルをimgとして自動取得します。

Step2. Specify options for popular_posts ()

In addition, please specify isImage: true andisExcerpt: true options for themepopular_posts () and popular_posts_json (). For example, article.ejs of hexo-theme-landscape specifies as follows I will.

さらに、テーマに記述するpopular_posts()popular_posts_json()にはisImage: trueisExcerpt: trueのオプション指定をしてください。例えばhexo-theme-landscapeのarticle.ejsでは次のように指定します。

<h3>Related posts</h3>
<div>
      <%- popular_posts( {isImage: true, isExcerpt: true} , page ) %>
</div>

Reference

https://github.com/tea3/hexo-related-popular-posts/wiki/More-Settings#hepler