| ... | ... |
@@ -6,18 +6,16 @@ |
| 6 | 6 |
<meta charset="utf-8"> |
| 7 | 7 |
<title>{% if page.title %}{{page.title}} - {% endif %}{{site.title}}</title>
|
| 8 | 8 |
<meta name="author" content="{{site.author}}">
|
| 9 |
- {% if page.description %}
|
|
| 10 |
- <meta name="description" content="{{page.description}}"/>
|
|
| 11 |
- {% endif %}
|
|
| 9 |
+ |
|
| 10 |
+ {% capture description %}{% if page.description %}{{ page.description }}{% else %}{{ content | raw_content }}{% endif %}{% endcapture %}
|
|
| 11 |
+ <meta name="description" content="{{ description | strip_newlines | strip_html | truncate:150 }}">
|
|
| 12 |
+ {% if page.keywords %}<meta name="keywords" content="{{ page.keywords }}">{% endif %}
|
|
| 12 | 13 |
|
| 13 | 14 |
<!-- http://t.co/dKP3o1e --> |
| 14 | 15 |
<meta name="HandheldFriendly" content="True"> |
| 15 | 16 |
<meta name="MobileOptimized" content="320"> |
| 16 | 17 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 17 | 18 |
|
| 18 |
- {% if page.keywords %}
|
|
| 19 |
- <meta name="keywords" content="{{page.keywords}}"/>
|
|
| 20 |
- {% endif %}
|
|
| 21 | 19 |
{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' }}{% endif %}{% endcapture %}
|
| 22 | 20 |
<link rel="canonical" href="{{ canonical }}">
|
| 23 | 21 |
<link href="{{ root_url }}/favicon.png" rel="shortcut icon" />
|
| ... | ... |
@@ -56,6 +56,13 @@ module OctopressLiquidFilters |
| 56 | 56 |
end |
| 57 | 57 |
end |
| 58 | 58 |
|
| 59 |
+ # Extracts raw content DIV from template, used for page description as {{ content }}
|
|
| 60 |
+ # contains complete sub-template code on main page level |
|
| 61 |
+ def raw_content(input) |
|
| 62 |
+ /.<div class="entry-content">(?<content>[\s\S]*?)<\/div>\s*<\/article>/ =~ input |
|
| 63 |
+ return (content.nil?) ? input : content |
|
| 64 |
+ end |
|
| 65 |
+ |
|
| 59 | 66 |
# Replaces relative urls with full urls |
| 60 | 67 |
def expand_urls(input, url='') |
| 61 | 68 |
url ||= '/' |