Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
4
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

Middleman(middleman-blog)で続きがないときに「続きを読む(READMORE)」を表示しない

Middlemanで要約に全文表示したい時って、文の最後にREADMOREを書くのが良いのですが、こうすると今度は「続きを読む」ボタンが常に表示されて鬱陶しいですね。

- blog.articles[0...3].each do |article|
  = article.summary
  - unless article.summary == article.body
    = link_to "続きを読む", article

こんな風に、article.summaryとarticle.bodyを比較してあげると、本当に要約されているのかどうか判断ができるので、必要なときだけ「続きを読む」ボタンを表示できます。

http://4th-cluster.com で実際に使っている様子が見れるので参考まで。

しかしMiddlemanってどれぐらいの人が使ってるんだろうね...

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
4
Help us understand the problem. What are the problem?