Closed iwarner closed 7 years ago
Hiya any news on this
You can see this in action here: http://codeblender.net/ Click on the paging on the home page - transitions but brings up same articles!
ok so the code that is the issue is in helpers.rb of middleman blog
This is called when naming a blog - and not when the name is missing
It will always show the first x blogs because it returns only that - it really should call the paginator class.
limit ? articles.first(limit)
# Returns the list of articles to display on this particular page (when using pagination).
# @param [Symbol, String] blog_name Optional name of the blog to use.
# @return [Array<Middleman::Sitemap::Resource>]
def page_articles(blog_name=nil)
meta = current_resource.metadata
limit = current_resource.data[:per_page]
# "articles" local variable is populated by Calendar and Tag page generators
# If it's not set then use the complete list of articles
articles = meta[:locals]["articles"] || blog(blog_name).articles
limit ? articles.first(limit) : articles
end
Hope this helps - my ruby skills are still too new to fix such an issue, but learning.
same problem here
I found a solution: instead of use page_articles( "portfolio" )
I wrote inside the frontmatter blog: portfolio
. After this the loop over the portfolio-items it works correctly with a working pagination
Many thanks I will test this now
@spazione I can confirm this works closing
@iwarner @spazione can you guys confirm this solution still works for you? And if so, with which gem versions? I'm getting crazy as I get results without consistency regardless your suggestions and many other attempts I have done. Really annoyed now!
@andreamoro Please provide your gem versions :)
I am always on the cutting edge preferring to pull from master rather than a deployed GEM.
i.e.
# Middleman core
# @see https://github.com/middleman
gem 'middleman-core', git: 'https://github.com/middleman/middleman.git', branch: 'master'
gem 'middleman-cli', git: 'https://github.com/middleman/middleman.git', branch: 'master'
gem 'middleman-blog', git: 'https://github.com/middleman/middleman-blog.git', branch: 'master'
gem 'middleman-livereload', git: 'https://github.com/middleman/middleman-livereload.git', branch: 'master'
gem 'middleman-syntax', git: 'https://github.com/middleman/middleman-syntax.git', branch: 'master'
gem 'middleman-autoprefixer', git: 'https://github.com/middleman/middleman-autoprefixer.git', branch: 'master'
gem 'middleman-minify-html', git: 'https://github.com/middleman/middleman-minify-html.git', branch: 'master'
Hey @iwarner I thought that without specifying anything in the gemfile, middleman was always pulling out from the master branch? Am I wrong?
BTW, below the "incriminated" gemfile
source 'https://rubygems.org'
gem 'middleman', '~> 4.2'
gem 'middleman-blog'
gem 'middleman-autoprefixer', '~> 2.7' # This is used for adding vendor prefixes to the CSS code
gem 'i18n', '~> 0.7.0'
gem "middleman-livereload"
gem 'nokogiri'
gem 'middleman-minify-html', '~> 3.4.1'
gem 'middleman-deploy', '~> 2.0.0.pre.alpha'
gem 'middleman-robots'
gem 'builder'
gem "middleman-syntax"
Hiya
This does not produce the desired affects in rendering articles from the named blog
I have this on the index.html page
I have two blogs both named, it seems the first one is always rendered
Edit // Tried on another page other than index.html and I get the desired results
Using master also : middleman-blog (4.0.1)
Seems when Pageable is true and - page_articles( "portfolio" ) will default to the first blog, in this case it is not portfolio
When Pageable is false then page_articles( "portfolio" ) will show the portfolio blog.
Ok = page_articles( "portfolio" ) does not seem to work with pagination at all.
Viewing : http://localhost:8080/page/11/ and putting a name in page_articles simply renders the first page of the blog set, on each page transition
If I simply put - = page_articles it works if I append brackets at all i.e. = page_articles() then it does not paginate correctly. The brackets are required to call the blog name with this helper. Unless I am calling this helper incorrectly.
http://www.rubydoc.info/github/middleman/middleman-blog/Middleman/Blog/Helpers#page_articles-instance_method
In the helper:
Seems on index the meta is always called so we never get the blog name articles = meta[:locals]["articles"] || blog(blog_name).articles
And this return does not take into account the current page so returns the first X limit ? articles.first(limit) : articles