Comments (11)
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.
@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.
👍 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.
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.
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.
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.
if
statements need an end
from middleman-blog.
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.
I've responded at his crosspost.
from middleman-blog.
This no longer seems to work with Middleman 4. Any updates?
from middleman-blog.
@ChasingUX Please open in another thread and post examples.
from middleman-blog.
Related Issues (20)
- Add more informations in head of article HOT 2
- Extension should not fail to activate if middleman-core/cli is missing
- Paging on untagged posts HOT 1
- How to make paginate work with localize blog? HOT 2
- Cyrillic tags stopped working in 4.0.2 HOT 2
- Support i18n mount_at_root option in permalinks HOT 3
- 4.0.2 regression bug when specifying the blog in the front-matter HOT 7
- feed.xml error on multi-blog site HOT 1
- RuntimeError flag --blog HOT 1
- 4.0.2 on RubyGems.org has different dependencies to the git repo HOT 3
- Very poor and outdated blog template which does not match with default template HOT 4
- Iterating through blog.tags spits out extraneous frontmatter HOT 5
- How to get links to all calendar/tag pages HOT 5
- Calendar and tag pages without .html aren't rendered within layout automatically HOT 1
- How to configure URLs of articles with underscore HOT 6
- `middleman article` generates incorrect yaml when the title contains characters that should be escaped HOT 1
- Middleman blog frontmatter evaluating files under build directory HOT 3
- preserve i18n locale on non-localized article page HOT 2
- YAML error on Ruby 3.1.0 HOT 7
- Paginate is showing as false even if set in config.rb to true HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from middleman-blog.