Class: PandaCms::Post

Inherits:
ApplicationRecord show all
Defined in:
app/models/panda_cms/post.rb

Instance Method Summary collapse

Instance Method Details

#excerpt(length = 100, squish: true) ⇒ Object



40
41
42
43
44
# File 'app/models/panda_cms/post.rb', line 40

def excerpt(length = 100, squish: true)
  excerpt = post_content.to_plain_text
  excerpt = excerpt.squish if squish
  excerpt.truncate(length).html_safe
end

#formatted_slugObject



50
51
52
53
54
55
56
# File 'app/models/panda_cms/post.rb', line 50

def formatted_slug
  if slug[0] == "/"
    slug[1, slug.length].to_s
  else
    slug
  end
end

#pathObject



46
47
48
# File 'app/models/panda_cms/post.rb', line 46

def path
  "/" + PandaCms.config.posts[:prefix] + slug.to_s
end

#to_paramObject



36
37
38
# File 'app/models/panda_cms/post.rb', line 36

def to_param
  formatted_slug.to_s
end