Module: PagesCore::MetaTagsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/pages_core/meta_tags_helper.rb
Instance Method Summary collapse
-
#default_meta_image(*args) ⇒ Object
Sets a default image to use for meta tags.
-
#default_meta_image? ⇒ Boolean
Returns true if default meta image has been set.
-
#meta_description(*args) ⇒ Object
Sets a description for meta tags.
-
#meta_description? ⇒ Boolean
Returns true if meta description has been set.
-
#meta_image(*args) ⇒ Object
Sets an image to use for meta tags.
-
#meta_image? ⇒ Boolean
Returns true if meta image has been set.
-
#meta_keywords(*args) ⇒ Object
Sets keywords for meta tags.
-
#meta_keywords? ⇒ Boolean
Returns true if meta keywords have been set.
Instance Method Details
#default_meta_image(*args) ⇒ Object
Sets a default image to use for meta tags. Supports both paths and Image objects.
image_path("facebook-share.png")
root_page.image
11 12 13 14 15 16 17 |
# File 'app/helpers/pages_core/meta_tags_helper.rb', line 11 def (*args) if args.any? = args.first else end end |
#default_meta_image? ⇒ Boolean
Returns true if default meta image has been set.
20 21 22 |
# File 'app/helpers/pages_core/meta_tags_helper.rb', line 20 def ? true : false end |
#meta_description(*args) ⇒ Object
Sets a description for meta tags.
"This is an awesome site"
28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/pages_core/meta_tags_helper.rb', line 28 def (*args) if args.any? = args.first else description = description ||= @page. if @page.try(&:meta_description?) description ||= @page.excerpt if @page && !@page.excerpt.empty? (description) end end |
#meta_description? ⇒ Boolean
Returns true if meta description has been set.
40 41 42 |
# File 'app/helpers/pages_core/meta_tags_helper.rb', line 40 def .present? end |
#meta_image(*args) ⇒ Object
Sets an image to use for meta tags. Supports both paths and Image objects.
image_path("facebook-share.png")
@page.image
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/helpers/pages_core/meta_tags_helper.rb', line 50 def (*args) if args.any? = args.first else image = if image.is_a?(Image) dynamic_image_url(image, size: "1200x", only_path: false) else image end end end |
#meta_image? ⇒ Boolean
Returns true if meta image has been set.
64 65 66 |
# File 'app/helpers/pages_core/meta_tags_helper.rb', line 64 def .present? || end |
#meta_keywords(*args) ⇒ Object
Sets keywords for meta tags.
"cialis viagra"
72 73 74 75 76 77 78 79 80 |
# File 'app/helpers/pages_core/meta_tags_helper.rb', line 72 def (*args) if args.any? = Array(args.first).join(", ") else keywords = keywords ||= @page.tag_list if @page&.&.any? (keywords) end end |
#meta_keywords? ⇒ Boolean
Returns true if meta keywords have been set.
83 84 85 |
# File 'app/helpers/pages_core/meta_tags_helper.rb', line 83 def .present? end |