Module: Blogit::PostsHelper

Defined in:
app/helpers/blogit/posts_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) archive_list_for_posts(archive_posts)

Creates a ul tag tree with posts by year and months. Include blogit/archive.js in your js to enabled expand collapse.

Examples:

<%= archive_list_for_posts(@posts) %>
# => <div class="blogit_archive">
       <ul class="blogit_archive__list blogit_archive__list--years">
         ...
       </ul>
     </div>

Returns:

  • an HTML safe String


43
44
45
# File 'app/helpers/blogit/posts_helper.rb', line 43

def archive_list_for_posts(archive_posts)
  render Blogit::Archive::List.new(archive_posts)
end

- (Object) comments_for_post(post)

Renders the comments for a Blogit::Post based on the Configuration::include_comments configuration


8
9
10
11
12
# File 'app/helpers/blogit/posts_helper.rb', line 8

def comments_for_post(post)
  comment_type = Blogit.configuration.include_comments
  render(partial: "blogit/comments/#{comment_type}_comments", 
    locals: { post: post, comment: Blogit::Comment.new })
end

- (Object) related_posts_for_post(post)

Returns the Posts that share one or more of the same tags for a given post

Parameters:

Returns:


26
27
28
# File 'app/helpers/blogit/posts_helper.rb', line 26

def related_posts_for_post(post)
  post.find_related_on_tags.active
end

- (Object) share_bar_for_post(post)

Renders the comments for a JS share bar based on the Configuration::include_share_bar configuration


16
17
18
19
# File 'app/helpers/blogit/posts_helper.rb', line 16

def share_bar_for_post(post)
  return "" unless Blogit.configuration.include_share_bar
  render(partial: "blogit/posts/share_bar", locals: { post: post})
end