middleman-metaman 0.1.6 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a2a8ce9708336d9c838361407fdbde3a054d0e86e30fef8ffebfd11e91f0d73
4
- data.tar.gz: d0d52a5e5b7cb944dbbe27d55ffd9f11bc8a6638af33db012ec599ec6477fcec
3
+ metadata.gz: 8e08c257ca67ade428e6d27121867bf6c05e2be373a8323372d5d8979b51248b
4
+ data.tar.gz: c0ecba8075673e6f81a0f5b31e14389fa3355b2de3c111f2f571500a69c97d3c
5
5
  SHA512:
6
- metadata.gz: ea892ec190985247ba925cf9142b7ed06790d4b0a3a649825fdcb6cb237b7c89df82185181baa1da31f9d6ca066c2f1d7a6aeabd339fa43ac3e2797b05b31cba
7
- data.tar.gz: 84254ab7e70d46a0ca33a0fd240f36c0ddb40322888952bb16e0c1b8874832a5849c2dbbefee5f03c1ef0c58ea4888e2127ed9da6a86e059a81605c5cdf267be
6
+ metadata.gz: 2a02a8f451e0fae5cd7b48db6b76f241d84cb9fd70ff4c89773224bfe67f4743e9bf2f674532b67dd75e9682477786b8b362dc4108631511328d661ca8074cff
7
+ data.tar.gz: 074c59989a98cf4784fe901c773f422e0bd3f075d3c8439311d5dda6522bc89d529c8e45db314522832addefe39a692ba63569a7c4a8946638120f1707665e37
data/README.md CHANGED
@@ -50,7 +50,7 @@ Nested parameters like `{ og: { title: 'My Title' } }` will become `og:title`.
50
50
  ### Setting via Templates
51
51
 
52
52
  ```erb
53
- <% set_page_meta(title: 'My Title', og: { image: 'meta-image.png' } )
53
+ <% set_meta_tags(title: 'My Title', og: { image: 'meta-image.png' } )
54
54
  ```
55
55
 
56
56
  ### Setting via Front Matter
@@ -11,14 +11,18 @@ module Middleman
11
11
  @meta_tags ||= ActiveSupport::HashWithIndifferentAccess.new
12
12
  @meta_tags[:og] ||= ActiveSupport::HashWithIndifferentAccess.new
13
13
  @meta_tags[:twitter] ||= ActiveSupport::HashWithIndifferentAccess.new
14
+ @meta_tags[:canonical] = true
15
+
14
16
  if data['meta_tags']
15
17
  site_meta_tags = data['meta_tags'].with_indifferent_access
16
18
  @meta_tags.merge!(site_meta_tags)
17
19
  end
18
20
 
19
21
  # get meta from translation
20
- t_page = current_page.url.gsub('-', '_').gsub('/', '.')
21
- t_key = "#{t_page}.meta"
22
+ page_array = current_page.page_id.gsub('-', '_').split('/')
23
+ lang = page_array.first&.to_s&.gsub('_', '-')&.to_sym
24
+ page_array.shift if I18n.available_locales.include?(lang)
25
+ t_key = "#{page_array.join('.')}.meta"
22
26
  @meta_tags.merge!(I18n.t(t_key)) if I18n.exists?(t_key)
23
27
 
24
28
  # get meta from frontmatter
@@ -34,8 +38,14 @@ module Middleman
34
38
  html = []
35
39
  @meta_tags[:title] = full_title(@meta_tags[:title])
36
40
  html.push content_tag(:title, @meta_tags[:title])
41
+ if @meta_tags[:canonical]
42
+ html.push(
43
+ tag(:link, rel: 'canonical', href: "#{host}#{current_page.url}")
44
+ )
45
+ end
37
46
 
38
- excluded_keys = %w(site_name separator title image)
47
+
48
+ excluded_keys = %w(site_name separator title image canonical)
39
49
  meta_hash = @meta_tags.reject { |k| excluded_keys.include?(k) }.merge(
40
50
  og: meta_open_graph,
41
51
  twitter: meta_twitter
@@ -90,7 +100,7 @@ module Middleman
90
100
 
91
101
  # determine key for meta tag based on name
92
102
  def meta_key(key)
93
- key.match?(/^(og|music|video|article|book|profile):/i) ? 'propery' : 'name'
103
+ key.match?(/^(og|music|video|article|book|profile):/i) ? 'property' : 'name'
94
104
  end
95
105
 
96
106
  # generate open graph meta
@@ -126,7 +136,10 @@ module Middleman
126
136
 
127
137
  # get the meta image url
128
138
  def meta_image_url(image)
129
- "#{host}#{image_path(image)}" if image
139
+ return nil unless image
140
+ return image unless URI(image).scheme.nil?
141
+
142
+ "#{host}#{image_path(image)}"
130
143
  end
131
144
 
132
145
  def default_value(scope, key, default = nil)
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Metaman
3
- VERSION = '0.1.6'.freeze
3
+ VERSION = '0.1.11'.freeze
4
4
  end
5
5
  end
@@ -6,7 +6,6 @@ require 'middleman-metaman/version'
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "middleman-metaman"
8
8
  s.version = Middleman::Metaman::VERSION
9
- s.platform = Gem::Platform::RUBY
10
9
  s.authors = ['Jarrett Lusso']
11
10
  s.email = ['jarrett@cacheventures.com']
12
11
  s.homepage = 'https://github.com/cacheventures/middleman-metaman'
@@ -19,9 +18,5 @@ Gem::Specification.new do |s|
19
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
19
  s.require_paths = ["lib"]
21
20
 
22
- # The version of middleman-core your extension depends on
23
- s.add_runtime_dependency("middleman-core", [">= 4.2.1"])
24
-
25
- # Additional dependencies
26
- # s.add_runtime_dependency("gem-name", "gem-version")
21
+ s.add_runtime_dependency('middleman-core', ['>= 4.2.1'])
27
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-metaman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrett Lusso
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-14 00:00:00.000000000 Z
11
+ date: 2021-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -48,7 +48,7 @@ homepage: https://github.com/cacheventures/middleman-metaman
48
48
  licenses:
49
49
  - MIT
50
50
  metadata: {}
51
- post_install_message:
51
+ post_install_message:
52
52
  rdoc_options: []
53
53
  require_paths:
54
54
  - lib
@@ -63,8 +63,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubygems_version: 3.0.3
67
- signing_key:
66
+ rubygems_version: 3.2.15
67
+ signing_key:
68
68
  specification_version: 4
69
69
  summary: Manage your middleman meta tags.
70
70
  test_files: []