middleman-dato 0.6.1 → 0.7.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: 350ddc7ef70748046571194c17e29f843297c9c8
4
- data.tar.gz: fe3eb4419b27d91804beeb795a64a9280d310bb4
3
+ metadata.gz: 58d96f4274983ff4f7dbb53ce87535f60d0a85a7
4
+ data.tar.gz: 44ca86cac8e9b7b0761f7a226f8f3799bb004cfe
5
5
  SHA512:
6
- metadata.gz: f7688e47beeb4197b91c178751044dcaeae92c19670d5d2a412d0d6c05e7186b1cc9590934ee88f3191196d0281de532eeaeb3de45e623d949e7f9ea9131c549
7
- data.tar.gz: 40003527ad0b4db7f05de87323cdd389a242bdf6a7010c789be0039792c44b7b83c330ebcfaa470a04057760a7a308490c60bada78eac22c6751680608da7acd
6
+ metadata.gz: e3aa277cd4ef6b1371236da52cf3ef6b8391aad1562d4a646ae0925e23d2d44f62cb069f2750d0970459e24fbfe56abf8cddcf9711fe0537f441042d4070fe15
7
+ data.tar.gz: 3d9951128381105479635c09f8ee535da7d57b83ae7513edaa9d7924241306daa0fa1401f19699578c9ea5468c552a2bf5852889cb5d90ff34d7455a74f9c5d1
@@ -3,63 +3,21 @@ require 'middleman-core'
3
3
  require 'middleman-core/version'
4
4
  require 'dato/site/client'
5
5
  require 'dato/local/loader'
6
- require 'middleman_dato/meta_tags_builder'
7
- require 'middleman_dato/meta_tags/favicon'
8
- require 'pusher-client'
9
- require 'singleton'
6
+ require 'dato/watch/site_change_watcher'
7
+ require 'middleman_dato/watcher'
8
+ require 'dato/utils/seo_tags_builder'
9
+ require 'dato/utils/favicon_tags_builder'
10
10
 
11
11
  module MiddlemanDato
12
- class Watcher
13
- include Singleton
14
- attr_reader :event_queue
15
-
16
- def initialize
17
- PusherClient.logger.level = Logger::WARN
18
- @site_id = nil
19
- @apps = []
20
- end
21
-
22
- def watch(app, loader, site_id)
23
- @app = app
24
- @loader = loader
25
-
26
- if site_id != @site_id
27
- if @socket && @socket.connected
28
- @apps = []
29
- @socket.disconnect
30
- end
31
-
32
- @apps = [ app.object_id ]
33
- @site_id = site_id
34
- @socket = PusherClient::Socket.new('75e6ef0fe5d39f481626', secure: true)
35
- @socket.subscribe("site-#{site_id}")
36
- @socket.bind('site:change') do
37
- print "DatoCMS content changed, refreshing data..."
38
- @loader.load
39
- puts " done!"
40
- @app.sitemap.rebuild_resource_list!(:touched_dato_content)
41
- end
42
- @socket.connect(true)
43
- else
44
- @apps[@apps.size - 1] = app.object_id
45
- end
46
- end
47
-
48
- def shutdown(app)
49
- if @socket && @socket.connected && @apps == [ app.object_id ]
50
- @socket.disconnect
51
- end
52
- @apps.delete(app.object_id)
53
- end
54
- end
55
-
56
12
  class MiddlemanExtension < ::Middleman::Extension
57
13
  attr_reader :loader
58
14
 
59
- option :domain, nil, 'Site domain (legacy)'
60
- option :token, nil, 'Site API token'
15
+ option :token, ENV['DATO_API_TOKEN'], 'Site API token'
61
16
  option :api_base_url, 'https://site-api.datocms.com', 'Site API host'
62
- option :base_url, nil, 'Website base URL'
17
+ option :live_reload, true, 'Live reload of content coming from DatoCMS'
18
+
19
+ option :base_url, nil, 'Website base URL (deprecated)'
20
+ option :domain, nil, 'Site domain (deprecated)'
63
21
 
64
22
  expose_to_config dato: :dato_collector
65
23
  expose_to_application dato_items_repo: :items_repo
@@ -71,13 +29,13 @@ module MiddlemanDato
71
29
  @loader.load
72
30
 
73
31
  app.after_configuration do
74
- if !app.build?
32
+ if options_hash[:live_reload] && !app.build?
75
33
  Watcher.instance.watch(app, loader, loader.items_repo.site.id)
76
34
  end
77
35
  end
78
36
 
79
37
  app.before_shutdown do
80
- if !app.build?
38
+ if options_hash[:live_reload] && !app.build?
81
39
  Watcher.instance.shutdown(app)
82
40
  end
83
41
  end
@@ -106,45 +64,40 @@ module MiddlemanDato
106
64
 
107
65
  module InstanceMethods
108
66
  def dato
109
- extensions[:dato].loader.items_repo
67
+ extensions[:dato].items_repo
110
68
  end
111
69
  end
112
70
 
113
71
  helpers do
114
72
  def dato
115
- extensions[:dato].loader.items_repo
73
+ extensions[:dato].items_repo
116
74
  end
117
75
 
118
76
  def dato_meta_tags(item)
119
- site_entity = extensions[:dato].loader
120
- .entities_repo
121
- .find_entities_of_type('site')
122
- .first
123
-
124
- builder = MetaTagsBuilder.new(
125
- self,
126
- extensions[:dato].options[:base_url],
127
- site_entity,
128
- item
129
- )
130
- builder.meta_tags
77
+ meta_tags = Dato::Utils::SeoTagsBuilder.new(item, dato.site).meta_tags
78
+
79
+ meta_tags.map do |data|
80
+ if data[:content]
81
+ content_tag(data[:tag_name], data[:content], data[:attributes])
82
+ else
83
+ tag(data[:tag_name], data[:attributes])
84
+ end
85
+ end.join
131
86
  end
132
87
 
133
88
  def dato_favicon_meta_tags(options = {})
134
- site_entity = extensions[:dato].loader
135
- .entities_repo
136
- .find_entities_of_type('site')
137
- .first
138
-
139
- options[:theme_color] ||= '#ffffff'
140
- options[:app_name] ||= ''
141
-
142
- favicon_builder = MetaTags::Favicon.new(
143
- self,
144
- site_entity,
89
+ meta_tags = Dato::Utils::FaviconTagsBuilder.new(
90
+ dato.site,
145
91
  options[:theme_color]
146
- )
147
- favicon_builder.build
92
+ ).meta_tags
93
+
94
+ meta_tags.map do |data|
95
+ if data[:content]
96
+ content_tag(data[:tag_name], data[:content], data[:attributes])
97
+ else
98
+ tag(data[:tag_name], data[:attributes])
99
+ end
100
+ end.join
148
101
  end
149
102
  end
150
103
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MiddlemanDato
3
- VERSION = '0.6.1'
3
+ VERSION = '0.7.0'
4
4
  end
@@ -0,0 +1,44 @@
1
+ require 'singleton'
2
+
3
+ module MiddlemanDato
4
+ class Watcher
5
+ include Singleton
6
+
7
+ def initialize
8
+ @site_id = nil
9
+ @apps = []
10
+ @watcher = nil
11
+ end
12
+
13
+ def watch(app, loader, site_id)
14
+ @app = app
15
+ @loader = loader
16
+
17
+ if site_id != @site_id
18
+ if @watcher && @watcher.connected?
19
+ @apps = []
20
+ @watcher.disconnect!
21
+ end
22
+
23
+ @apps = [ app.object_id ]
24
+ @site_id = site_id
25
+ @watcher = Dato::Watch::SiteChangeWatcher.new(site_id).connect do
26
+ print "DatoCMS content changed, refreshing data..."
27
+ @loader.load
28
+ puts " done!"
29
+ @app.sitemap.rebuild_resource_list!(:touched_dato_content)
30
+ end
31
+ else
32
+ @apps[@apps.size - 1] = app.object_id
33
+ end
34
+ end
35
+
36
+ def shutdown(app)
37
+ if @watcher && @watcher.connected? && @apps == [ app.object_id ]
38
+ @watcher.disconnect!
39
+ end
40
+
41
+ @apps.delete(app.object_id)
42
+ end
43
+ end
44
+ end
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency('coveralls')
24
24
 
25
25
  s.add_runtime_dependency('middleman-core', ['>= 4.1.10'])
26
- s.add_runtime_dependency('dato', ['>= 0.2.4'])
26
+ s.add_runtime_dependency('dato', ['>= 0.3.0'])
27
27
  s.add_runtime_dependency('activesupport')
28
28
  s.add_runtime_dependency('pusher-client')
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-dato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2016-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.4
47
+ version: 0.3.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.4
54
+ version: 0.3.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activesupport
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -96,25 +96,9 @@ files:
96
96
  - README.md
97
97
  - Rakefile
98
98
  - lib/middleman-dato.rb
99
- - lib/middleman_dato/meta_tags/article_modified_time.rb
100
- - lib/middleman_dato/meta_tags/article_publisher.rb
101
- - lib/middleman_dato/meta_tags/base.rb
102
- - lib/middleman_dato/meta_tags/description.rb
103
- - lib/middleman_dato/meta_tags/favicon.rb
104
- - lib/middleman_dato/meta_tags/image.rb
105
- - lib/middleman_dato/meta_tags/og_locale.rb
106
- - lib/middleman_dato/meta_tags/og_meta_tag.rb
107
- - lib/middleman_dato/meta_tags/og_site_name.rb
108
- - lib/middleman_dato/meta_tags/og_type.rb
109
- - lib/middleman_dato/meta_tags/robots.rb
110
- - lib/middleman_dato/meta_tags/title.rb
111
- - lib/middleman_dato/meta_tags/twitter_card.rb
112
- - lib/middleman_dato/meta_tags/twitter_meta_tag.rb
113
- - lib/middleman_dato/meta_tags/twitter_site.rb
114
- - lib/middleman_dato/meta_tags/url.rb
115
- - lib/middleman_dato/meta_tags_builder.rb
116
99
  - lib/middleman_dato/middleman_extension.rb
117
100
  - lib/middleman_dato/version.rb
101
+ - lib/middleman_dato/watcher.rb
118
102
  - middleman-dato.gemspec
119
103
  - spec/middleman_dato/meta_tags/article_modified_time_spec.rb
120
104
  - spec/middleman_dato/meta_tags/favicon_spec.rb
@@ -152,4 +136,3 @@ test_files:
152
136
  - spec/middleman_dato/meta_tags/og_locale_spec.rb
153
137
  - spec/spec_helper.rb
154
138
  - spec/support/mock_builder.rb
155
- has_rdoc:
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/og_meta_tag'
3
- require 'time'
4
-
5
- module MiddlemanDato
6
- module MetaTags
7
- class ArticleModifiedTime < OgMetaTag
8
- def buildable?
9
- item && !item.singleton?
10
- end
11
-
12
- def name
13
- 'article:modified_time'
14
- end
15
-
16
- def value
17
- item.updated_at.iso8601
18
- end
19
- end
20
- end
21
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/og_meta_tag'
3
- require 'time'
4
-
5
- module MiddlemanDato
6
- module MetaTags
7
- class ArticlePublisher < OgMetaTag
8
- def buildable?
9
- item && !item.singleton? &&
10
- global_seo_field(:facebook_page_url).present?
11
- end
12
-
13
- def name
14
- 'article:publisher'
15
- end
16
-
17
- def value
18
- global_seo_field(:facebook_page_url)
19
- end
20
- end
21
- end
22
- end
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'forwardable'
3
- require 'dato/local/field_type/seo'
4
- require 'active_support/core_ext/object/blank'
5
-
6
- module MiddlemanDato
7
- module MetaTags
8
- class Base
9
- attr_reader :builder, :base_url, :site, :item_type, :item
10
-
11
- def initialize(builder, base_url, site, item)
12
- @site = site
13
- @base_url = base_url
14
- @item = item
15
- @builder = builder
16
- end
17
-
18
- def seo_field_with_fallback(attribute, alternative = nil, &block)
19
- seo = first_item_field_of_type(:seo)
20
-
21
- alternatives = []
22
-
23
- alternatives << seo.send(attribute) if seo
24
- alternatives << alternative if alternative
25
- alternatives << fallback_seo.send(attribute) if fallback_seo
26
-
27
- alternatives = alternatives.select(&:present?)
28
- alternatives = alternatives.select(&block) if block
29
-
30
- alternatives.first
31
- end
32
-
33
- def title_suffix
34
- global_seo_field(:title_suffix) || ''
35
- end
36
-
37
- def no_index?
38
- site && site.no_index
39
- end
40
-
41
- def global_seo_field(attribute)
42
- global_seo[attribute] if global_seo
43
- end
44
-
45
- def first_item_field_of_type(type)
46
- return nil unless item
47
-
48
- field = item.fields.detect do |f|
49
- f.field_type == type.to_s
50
- end
51
-
52
- item.send(field.api_key) if field
53
- end
54
-
55
- def fallback_seo
56
- @fallback_seo ||= begin
57
- Dato::Local::FieldType::Seo.parse(global_seo[:fallback_seo], nil) if global_seo
58
- end
59
- end
60
-
61
- def global_seo
62
- @global_seo ||= begin
63
- if site && site.global_seo
64
- global_seo = site.global_seo
65
- if site.locales.size > 1
66
- global_seo[I18n.locale]
67
- else
68
- global_seo
69
- end
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/base'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class Description < Base
7
- def build
8
- if description.present?
9
- [
10
- builder.tag(
11
- :meta,
12
- name: 'description',
13
- content: description
14
- ),
15
- builder.tag(
16
- :meta,
17
- property: 'og:description',
18
- content: description
19
- ),
20
- builder.tag(
21
- :meta,
22
- name: 'twitter:description',
23
- content: description
24
- )
25
- ]
26
- end
27
- end
28
-
29
- def description
30
- @description ||= seo_field_with_fallback(:description)
31
- end
32
- end
33
- end
34
- end
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/local/field_type/image'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class Favicon
7
- attr_reader :builder, :theme_color, :favicon, :app_name
8
- APPLE_TOUCH_ICON_SIZES = [57, 60, 72, 76, 114, 120, 144, 152, 180].freeze
9
- ICON_SIZES = [16, 32, 96, 192].freeze
10
- APPLICATION_SIZES = [70, 150, 310].freeze
11
-
12
- def initialize(builder, entity, theme_color)
13
- @favicon = entity.favicon
14
- @builder = builder
15
- @theme_color = theme_color
16
- @app_name = entity.global_seo['site_name'] || ''
17
- end
18
-
19
- def image
20
- Dato::Local::FieldType::Image.parse(favicon, nil) if favicon.present?
21
- end
22
-
23
- def url(width, height = nil)
24
- height ||= width
25
- image.file.width(width).height(height).to_url
26
- end
27
-
28
- def build_apple_icon_tags
29
- APPLE_TOUCH_ICON_SIZES.map do |size|
30
- builder.tag(:link,
31
- rel: 'apple-touch-icon',
32
- sizes: "#{size}x#{size}",
33
- href: url(size))
34
- end
35
- end
36
-
37
- def build_icon_tags
38
- ICON_SIZES.map do |size|
39
- builder.tag(:link,
40
- rel: 'icon',
41
- type: "image/#{image.format}",
42
- href: url(size),
43
- sizes: "#{size}x#{size}")
44
- end
45
- end
46
-
47
- def build_application_tags
48
- APPLICATION_SIZES.map do |size|
49
- builder.tag(:meta,
50
- name: "msapplication-square#{size}x#{size}logo",
51
- content: url(size))
52
- end + [builder.tag(:meta,
53
- name: 'msapplication-wide310x150logo',
54
- content: url(310, 150))]
55
- end
56
-
57
- def main_tags
58
- [
59
- builder.tag(:meta, name: 'application-name', content: app_name),
60
- builder.tag(:meta, name: 'theme-color', content: theme_color),
61
- builder.tag(:meta,
62
- name: 'msapplication-TileColor',
63
- content: theme_color)
64
- ]
65
- end
66
-
67
- def build_tags
68
- tags = main_tags
69
- unless image.nil?
70
- tags += build_apple_icon_tags
71
- tags += build_icon_tags
72
- tags += build_application_tags
73
- end
74
- tags
75
- end
76
-
77
- def build
78
- build_tags.join("\n")
79
- end
80
- end
81
- end
82
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/base'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class Image < Base
7
- def build
8
- if image.present?
9
- [
10
- builder.tag(:meta, property: 'og:image', content: image),
11
- builder.tag(:meta, name: 'twitter:image', content: image)
12
- ]
13
- end
14
- end
15
-
16
- def image
17
- image = seo_field_with_fallback(
18
- :image,
19
- first_item_field_of_type(:image)
20
- ) do |i|
21
- i.width >= 200 && i.height >= 200
22
- end
23
-
24
- image.file.format('jpg').to_url if image
25
- end
26
- end
27
- end
28
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/og_meta_tag'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class OgLocale < OgMetaTag
7
- def buildable?
8
- true
9
- end
10
-
11
- def name
12
- 'og:locale'
13
- end
14
-
15
- def value
16
- locale = I18n.locale
17
- "#{locale}_#{locale.upcase}"
18
- end
19
- end
20
- end
21
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/base'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class OgMetaTag < Base
7
- def buildable?
8
- false
9
- end
10
-
11
- def build
12
- builder.tag(:meta, property: name, content: value) if buildable?
13
- end
14
-
15
- def name
16
- raise NotImplementedError
17
- end
18
-
19
- def value
20
- raise NotImplementedError
21
- end
22
- end
23
- end
24
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/og_meta_tag'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class OgSiteName < OgMetaTag
7
- def buildable?
8
- global_seo_field(:site_name).present?
9
- end
10
-
11
- def name
12
- 'og:site_name'
13
- end
14
-
15
- def value
16
- global_seo_field(:site_name)
17
- end
18
- end
19
- end
20
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/og_meta_tag'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class OgType < OgMetaTag
7
- def buildable?
8
- true
9
- end
10
-
11
- def name
12
- 'og:type'
13
- end
14
-
15
- def value
16
- if !item
17
- 'website'
18
- elsif item.singleton?
19
- 'website'
20
- else
21
- 'article'
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/base'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class Robots < Base
7
- def build
8
- builder.tag(:meta, name: 'robots', content: 'noindex') if no_index?
9
- end
10
- end
11
- end
12
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/base'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class Title < Base
7
- def build
8
- if title.present?
9
- [
10
- builder.content_tag(:title, title_with_suffix),
11
- builder.tag(:meta, property: 'og:title', content: title),
12
- builder.tag(:meta, name: 'twitter:title', content: title)
13
- ]
14
- end
15
- end
16
-
17
- def title
18
- @title ||= begin
19
- title_field = item.fields.find do |field|
20
- field.field_type == 'string' &&
21
- field.appeareance[:type] == 'title'
22
- end
23
-
24
- seo_field_with_fallback(
25
- :title,
26
- item && title_field && item.send(title_field.api_key)
27
- )
28
- end
29
- end
30
-
31
- def title_with_suffix
32
- title_plus_suffix = title + title_suffix
33
-
34
- if title_plus_suffix.size <= 60
35
- title_plus_suffix
36
- else
37
- title
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/twitter_meta_tag'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class TwitterCard < TwitterMetaTag
7
- def buildable?
8
- true
9
- end
10
-
11
- def name
12
- 'twitter:card'
13
- end
14
-
15
- def value
16
- 'summary'
17
- end
18
- end
19
- end
20
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/base'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class TwitterMetaTag < Base
7
- def buildable?
8
- false
9
- end
10
-
11
- def build
12
- builder.tag(:meta, name: name, content: value) if buildable?
13
- end
14
-
15
- def name
16
- raise NotImplementedError
17
- end
18
-
19
- def value
20
- raise NotImplementedError
21
- end
22
- end
23
- end
24
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/twitter_meta_tag'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class TwitterSite < TwitterMetaTag
7
- def buildable?
8
- global_seo_field(:twitter_account).present?
9
- end
10
-
11
- def name
12
- 'twitter:site'
13
- end
14
-
15
- def value
16
- global_seo_field(:twitter_account)
17
- end
18
- end
19
- end
20
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/base'
3
-
4
- module MiddlemanDato
5
- module MetaTags
6
- class Url < Base
7
- def build
8
- if url.present?
9
- [
10
- builder.tag(:link, rel: 'canonical', href: url),
11
- builder.tag(:meta, property: 'og:url', content: url),
12
- builder.tag(:meta, name: 'twitter:url', content: url)
13
- ]
14
- end
15
- end
16
-
17
- def url
18
- base_url + builder.current_page.url
19
- end
20
- end
21
- end
22
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'middleman_dato/meta_tags/title'
3
- require 'middleman_dato/meta_tags/description'
4
- require 'middleman_dato/meta_tags/image'
5
- require 'middleman_dato/meta_tags/url'
6
- require 'middleman_dato/meta_tags/robots'
7
- require 'middleman_dato/meta_tags/og_locale'
8
- require 'middleman_dato/meta_tags/og_type'
9
- require 'middleman_dato/meta_tags/og_site_name'
10
- require 'middleman_dato/meta_tags/article_modified_time'
11
- require 'middleman_dato/meta_tags/article_publisher'
12
- require 'middleman_dato/meta_tags/twitter_card'
13
- require 'middleman_dato/meta_tags/twitter_site'
14
-
15
- module MiddlemanDato
16
- class MetaTagsBuilder
17
- META_TAGS = [
18
- MetaTags::Title,
19
- MetaTags::Description,
20
- MetaTags::Image,
21
- MetaTags::Url,
22
- MetaTags::Robots,
23
- MetaTags::OgLocale,
24
- MetaTags::OgType,
25
- MetaTags::OgSiteName,
26
- MetaTags::ArticleModifiedTime,
27
- MetaTags::ArticlePublisher,
28
- MetaTags::TwitterCard,
29
- MetaTags::TwitterSite
30
- ].freeze
31
-
32
- def initialize(*args)
33
- @args = args
34
- end
35
-
36
- def meta_tags
37
- META_TAGS.map do |klass|
38
- klass.new(*@args).build
39
- end.flatten.compact.join("\n")
40
- end
41
- end
42
- end