0

Is there any way to avoid duplication of summaries and first paragraphs or the article for .haml pages? Now I have to copy and paste them every time.

The ideal case is to use to split the article with read_more link.

Mikhail Chuprynski
  • 2,404
  • 2
  • 29
  • 42

2 Answers2

1

Nesta's author here... Sorry, I've not been monitoring SO for Nesta stuff. I'll start doing that.

Did you see the Foldable plugin? I think it does pretty much what you want.

http://nestacms.com/docs/plugins/foldable

Graham Ashton
  • 614
  • 5
  • 10
0

You could use

%cut

tag in your articles and change your main part of /view/summaries.haml as follows:

- pages.each do |page|
  %li
    %article
      %header
        %h1
          %a(href="#{path_to(page.abspath)}")= page.link_text
      - if page.summary.nil? || page.summary.empty?
        - cut = page.body(self).split('<cut>')
        ~ cut.first
        -if cut.size > 1
          %p.read_more
            %a(href="#{path_to(page.abspath)}")= page.read_more
      - else
        ~ page.summary
        %p.youtube
          %a(href="#{path_to(page.abspath)}")= page.read_more
      = haml :page_meta, :layout => false, :locals => { :page => page }

Everything above %cut tag will be displayed as summary on articles page.

Mikhail Chuprynski
  • 2,404
  • 2
  • 29
  • 42