jekyll-seo-tag 0.1.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddb197372851982ae0bb4ab3b2bbb0c08e29dc70
4
- data.tar.gz: f238e1379de659c6100b7bfc7f2b9362aff6061a
3
+ metadata.gz: c9c2e7b63d04d2bde4d1f47a71849d7b7efc5b99
4
+ data.tar.gz: 85705921fa8691e6588ffa10953f7cfc2ed31f3f
5
5
  SHA512:
6
- metadata.gz: 990e391cc4f3ff9a354be4ea164746cea7bfce7eda85b0565ca6ed1ea84f11970ab7ef9b969e9de1adf645cd7e5e5dc4b4a59056cc76afcbfe717478fa412d58
7
- data.tar.gz: ec56d87c8c74267c174dafbf012c7233657ef95a9e210ba5ef558a0eedbac23b3dddae7b2dca197fcc5178ea9aa9f088ab3385c09e060abbe707769fea752fa0
6
+ metadata.gz: fb94e6867b9fcc64aa895e7330a18a8c5f8e46242f8acf5c5cf2928516bc4ae131174f1ec9523838e89c8f7f092f4fb11f8d19573deb4d42cd6c9cc2946ce7c5
7
+ data.tar.gz: bf8b3125ab927e7d05abfadb4f00f43ae692504b4d9449adccc6df0eeda3ada48025d10cdd44e628cbc2b908f85d32dd634dc5841ac2cf87f4fb608f47a3b9ab
data/README.md CHANGED
@@ -69,5 +69,5 @@ The SEO tag will respect the following YAML front matter if included in a post,
69
69
 
70
70
  * `title` - The title of the post, page, or document
71
71
  * `description` - A short description of the page's content
72
- * `image` - The absolute URL to an image that should be associated with the post, page, or document
72
+ * `image` - Relative URL to an image associated with the post, page, or document (e.g., `assets/page-pic.jpg`)
73
73
  * `author` - The username of the post, page, or document author
@@ -1,20 +1,13 @@
1
+ require 'jekyll-seo-tag/filters'
2
+
1
3
  module Jekyll
2
4
  class SeoTag < Liquid::Tag
3
5
 
4
6
  attr_accessor :context
5
7
 
6
- HTML_ESCAPE = {
7
- "\u201c".freeze => '&ldquo;'.freeze,
8
- "\u201d".freeze => '&rdquo;'.freeze
9
- }
10
- HTML_ESCAPE_REGEX = Regexp.union(HTML_ESCAPE.keys).freeze
11
-
12
8
  def render(context)
13
9
  @context = context
14
- output = Liquid::Template.parse(template_contents).render!(payload, info)
15
-
16
- # Encode smart quotes. See https://github.com/benbalter/jekyll-seo-tag/pull/6
17
- output.gsub!(HTML_ESCAPE_REGEX, HTML_ESCAPE)
10
+ output = template.render!(payload, info)
18
11
 
19
12
  output
20
13
  end
@@ -31,10 +24,14 @@ module Jekyll
31
24
  def info
32
25
  {
33
26
  :registers => context.registers,
34
- :filters => [Jekyll::Filters]
27
+ :filters => [Jekyll::Filters, JekyllSeoTag::Filters]
35
28
  }
36
29
  end
37
30
 
31
+ def template
32
+ @template ||= Liquid::Template.parse template_contents
33
+ end
34
+
38
35
  def template_contents
39
36
  @template_contents ||= File.read(template_path).gsub(/(>\n|[%}]})\s+(<|{[{%])/,'\1\2').chomp
40
37
  end
@@ -0,0 +1,14 @@
1
+ module JekyllSeoTag
2
+ module Filters
3
+
4
+ # This is available in Liquid from version 3 which is required by Jekyll 3
5
+ # Provided here for compatibility with Jekyll 2.x
6
+ def default(input, default_value = ''.freeze)
7
+ if !input || input.respond_to?(:empty?) && input.empty?
8
+ default_value
9
+ else
10
+ input
11
+ end
12
+ end
13
+ end
14
+ end
@@ -3,6 +3,6 @@ module Liquid; class Tag; end; end
3
3
 
4
4
  module Jekyll
5
5
  class SeoTag < Liquid::Tag
6
- VERSION = "0.1.4"
6
+ VERSION = "1.0.0"
7
7
  end
8
8
  end
@@ -2,39 +2,47 @@
2
2
 
3
3
  {% if site.url %}
4
4
  {% assign seo_url = site.url | append: site.baseurl %}
5
- {% elsif site.github.url %}
6
- {% assign seo_url = site.github.url %}
7
5
  {% endif %}
6
+ {% assign seo_url = seo_url | default: site.github.url %}
7
+
8
+ {% assign seo_site_title = site.title | default: site.name %}
8
9
 
9
10
  {% if page.title %}
10
11
  {% assign seo_title = page.title %}
11
12
  {% assign seo_page_title = page.title %}
12
- {% if site.title %}
13
- {% assign seo_title = seo_title | append:" - " | append: site.title %}
13
+ {% if seo_site_title %}
14
+ {% assign seo_title = seo_title | append:" - " | append: seo_site_title %}
15
+ {% endif %}
16
+ {% elsif seo_site_title %}
17
+ {% assign seo_title = seo_site_title %}
18
+ {% assign seo_page_title = seo_site_title %}
19
+ {% if site.description %}
20
+ {% assign seo_title = seo_title | append:" - " | append: site.description %}
14
21
  {% endif %}
15
- {% elsif site.title %}
16
- {% assign seo_title = site.title %}
17
- {% assign seo_page_title = site.title %}
18
- {% if site.description %}
19
- {% assign seo_title = seo_title | append:" - " | append: site.description %}
20
- {% endif %}
21
22
  {% endif %}
22
23
  {% if seo_title %}
23
24
  {% assign seo_title = seo_title | markdownify | strip_html | strip_newlines | escape_once %}
24
25
  {% endif %}
26
+ {% if seo_site_title %}
27
+ {% assign seo_site_title = seo_site_title | markdownify | strip_html | strip_newlines | escape_once %}
28
+ {% endif %}
25
29
  {% if seo_page_title %}
26
30
  {% assign seo_page_title = seo_page_title | markdownify | strip_html | strip_newlines | escape_once %}
27
31
  {% endif %}
28
32
 
29
- {% if page.description %}
30
- {% assign seo_description = page.description %}
31
- {% elsif site.description %}
32
- {% assign seo_description = site.description %}
33
- {% endif %}
33
+ {% assign seo_description = page.description | default: page.excerpt | default: site.description %}
34
34
  {% if seo_description %}
35
35
  {% assign seo_description = seo_description | markdownify | strip_html | strip_newlines | escape_once %}
36
36
  {% endif %}
37
37
 
38
+ {% if page.author %}
39
+ {% assign seo_author_name = page.author.name | default: page.author %}
40
+ {% assign seo_author_twitter = page.author.twitter | default: page.author %}
41
+ {% endif %}
42
+ {% if seo_author_twitter %}
43
+ {% assign seo_author_twitter = seo_author_twitter | replace:"@","" | prepend:"@" %}
44
+ {% endif %}
45
+
38
46
  {% if seo_title %}
39
47
  <title>{{ seo_title }}</title>
40
48
  {% endif %}
@@ -49,24 +57,24 @@
49
57
  {% endif %}
50
58
 
51
59
  {% if seo_url %}
52
- <link rel="canonical" href="{{ page.url | prepend: seo_url | replace:'/index.html','/' }}" itemprop="url" />
60
+ <link rel="canonical" href="{{ page.url | prepend: seo_url | replace:'/index.html','/' }}" />
53
61
  <meta property='og:url' content='{{ page.url | prepend: seo_url | replace:'/index.html','/' }}' />
54
62
  {% endif %}
55
63
 
56
- {% if site.title %}
57
- <meta property="og:site_name" content="{{ site.title }}" />
64
+ {% if seo_site_title %}
65
+ <meta property="og:site_name" content="{{ seo_site_title }}" />
58
66
  <script type="application/ld+json">
59
67
  {
60
68
  "@context" : "http://schema.org",
61
69
  "@type" : "WebSite",
62
- "name" : {{ site.title | jsonify }},
70
+ "name" : {{ seo_site_title | jsonify }},
63
71
  "url" : {{ seo_url | jsonify }}
64
72
  }
65
73
  </script>
66
74
  {% endif %}
67
75
 
68
76
  {% if page.image %}
69
- <meta property="og:image" content="{{ page.image }}" />
77
+ <meta property="og:image" content="{{ page.image | prepend: "/" | prepend: seo_url | escape }}" />
70
78
  {% endif %}
71
79
 
72
80
  {% if page.date %}
@@ -84,7 +92,7 @@
84
92
  "headline": {{ page.title | jsonify }},
85
93
  "image": {{ page.image | jsonify }},
86
94
  "datePublished": {{ page.date | date_to_xmlschema | jsonify }},
87
- "description": {{ page.description | jsonify }}
95
+ "description": {{ seo_description | jsonify }}
88
96
  }
89
97
  </script>
90
98
  {% endif %}
@@ -97,8 +105,8 @@
97
105
  {% if page.image %}
98
106
  <meta name="twitter:image" content="{{ page.image | escape }}" />
99
107
  {% endif %}
100
- {% if page.author %}
101
- <meta name="twitter:creator" content="@{{ page.author | replace:"@","" }}" />
108
+ {% if seo_author_twitter %}
109
+ <meta name="twitter:creator" content="{{ seo_author_twitter }}" />
102
110
  {% endif %}
103
111
  {% endif %}
104
112
 
@@ -118,7 +126,7 @@
118
126
  {
119
127
  "@context" : "http://schema.org",
120
128
  "@type" : "{% if site.social.type %}{{ site.social.type }}{% else %}person{% endif %}",
121
- "name" : "{% if site.social.name %}{{ site.social.name }}{% else %}{{ site.title }}{% endif %}",
129
+ "name" : "{% if site.social.name %}{{ site.social.name }}{% else %}{{ seo_site_title }}{% endif %}",
122
130
  "url" : {{ seo_url | jsonify }},
123
131
  "sameAs" : {{ site.social.links | jsonify }}
124
132
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-seo-tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-07 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -96,6 +96,7 @@ files:
96
96
  - Rakefile
97
97
  - jekyll-seo-tag.gemspec
98
98
  - lib/jekyll-seo-tag.rb
99
+ - lib/jekyll-seo-tag/filters.rb
99
100
  - lib/jekyll-seo-tag/version.rb
100
101
  - lib/template.html
101
102
  - script/bootstrap
@@ -128,3 +129,4 @@ specification_version: 4
128
129
  summary: A Jekyll plugin to add metadata tags for search engines and social networks
129
130
  to better index and display your site's content.
130
131
  test_files: []
132
+ has_rdoc: