Giter VIP home page Giter VIP logo

Comments (11)

bhollis avatar bhollis commented on September 1, 2024

A screenshot isn't particularly helpful - what about some code? I use current_article.previous_article and current_article.next_article to do that type of linking all the time. An example:

.navigation
  .prevnav
    - prev_article = current_article.previous_article
    - if prev_article
      Previous:
      %a{ :rel => "prev", :href => prev_article.url }= prev_article.title
  .nextnav
    - next_article = current_article.next_article
    - if next_article
      Next:
      %a{ :rel => "next", :href => next_article.url }= next_article.title

from middleman-blog.

renatocarvalho avatar renatocarvalho commented on September 1, 2024

@bhollis Next time I'll be better :)

Thank you very much! It worked like a charm. Here's the code I used using slim.

ul
  li.previous
    - prev_article = current_article.previous_article
    - if prev_article
      a href="#{prev_article.url}" rel="prev" title="Previous article: #{prev_article.title}" Previous
  li.next
    - next_article = current_article.next_article
    - if next_article
      a href="#{next_article.url}" rel="next" title="Next article: #{next_article.title}" Next

from middleman-blog.

nedzen avatar nedzen commented on September 1, 2024

👍 this is great, exactly what I need, but it doesn't work: this is the error I get :

undefined method `previous_article' for nil:NilClass

what can I do ?
I use :
middleman 3.3.10
middleman-blog 3.5.3

from middleman-blog.

tdreyno avatar tdreyno commented on September 1, 2024

current_article.previous_article is nil? Seems like you either don't have a previous article from the current one or you are not on an article detail page.

from middleman-blog.

nedzen avatar nedzen commented on September 1, 2024

I am on the article page and I have a previous article from the current one. What I try to do is very simple just have homepage, with last article full, and at the end the title of the previous article (linked). and the article page would be exactly the same with the title(linked) at the bottom of the article before it.
I've put this code into my template article like this <%=current_article.previous_article%> and what it returns is just a #

from middleman-blog.

nedzen avatar nedzen commented on September 1, 2024

so on a fresh install of middleman with the blog and all, I have this at the end of the layout.erb template, at the end of the page and It doesn't work I get syntax error...

  <ul>
    <li>
      <% prev_article = current_article.previous_article %>
        <% if prev_article %>
        <a href="#{prev_article.url}" rel="prev" title="Previous article: #{prev_article.title}"> Previous </a>
    </li>
    <li>
      <% next_article = current_article.next_article %>
        <% if next_article %>
        <a href="#{next_article.url}" rel="next" title="Next article: #{next_article.title}"> Next </a>
    </li>
  </ul>

from middleman-blog.

tdreyno avatar tdreyno commented on September 1, 2024

if statements need an end

from middleman-blog.

nedzen avatar nedzen commented on September 1, 2024

thank you, but still doesn't work, on the article page this code generates a "next" link and when I click it I see this http://localhost:4567/2015/03/26/flowers-are-blue/#{next_article.url} in chrome address bar. and nothing else happens: see screenshot : http://cl.ly/image/2j3F282g3O2z

from middleman-blog.

AndrewKvalheim avatar AndrewKvalheim commented on September 1, 2024

I've responded at his crosspost.

from middleman-blog.

ChasingUX avatar ChasingUX commented on September 1, 2024

This no longer seems to work with Middleman 4. Any updates?

from middleman-blog.

iwarner avatar iwarner commented on September 1, 2024

@ChasingUX Please open in another thread and post examples.

from middleman-blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.