Merge branch 'meta_feature'
This commit is contained in:
commit
a6d18cb05f
|
@ -44,8 +44,17 @@ class Post
|
||||||
self.visited_count
|
self.visited_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 显示给首页截断数据
|
||||||
def sub_content
|
def sub_content
|
||||||
HTML_Truncator.truncate(content_html,30)
|
HTML_Truncator.truncate(content_html, 300, length_in_chars: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
# 显示给 meta description
|
||||||
|
def meta_content
|
||||||
|
html = HTML_Truncator.truncate(content_html, 100, :length_in_chars => true, ellipsis: '')
|
||||||
|
# 加上 div 以方便 Nokogiri 获取 text()
|
||||||
|
html = '<div>' + html + '</div>'
|
||||||
|
Nokogiri.parse(html).text()
|
||||||
end
|
end
|
||||||
|
|
||||||
def labels_content( need_blank=false )
|
def labels_content( need_blank=false )
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
- if ENV['INTRODUCE'].present?
|
||||||
|
- content_for(:meta) do
|
||||||
|
meta name="description" content="#{ENV['INTRODUCE'].dup.force_encoding('UTF-8')}"
|
||||||
- content_for(:title) do
|
- content_for(:title) do
|
||||||
| 首页
|
| 首页
|
||||||
.row
|
.row
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
- content_for(:meta) do
|
||||||
|
meta name="description" content="#{@post.meta_content}"
|
||||||
|
meta name="keywords" content=@post.labels_content
|
||||||
|
|
||||||
- content_for(:title) do
|
- content_for(:title) do
|
||||||
| #{@post.title}
|
| #{@post.title}
|
||||||
.row
|
.row
|
||||||
|
|
|
@ -2,6 +2,8 @@ html
|
||||||
head
|
head
|
||||||
meta charset="utf-8"
|
meta charset="utf-8"
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
||||||
|
- if content_for?(:meta)
|
||||||
|
= yield(:meta)
|
||||||
title
|
title
|
||||||
= content_for?(:title) ? yield(:title) + " | #{ENV['SITE_NAME']}" : ENV['SITE_NAME']
|
= content_for?(:title) ? yield(:title) + " | #{ENV['SITE_NAME']}" : ENV['SITE_NAME']
|
||||||
= stylesheet_link_tag "application"
|
= stylesheet_link_tag "application"
|
||||||
|
|
Loading…
Reference in New Issue