govuk_tech_docs 2.0.13 → 2.1.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
  SHA256:
3
- metadata.gz: 35c96cfb5a9198c31ad6a4e4d4a3676299c938089127b1c2a564d2401c50ac10
4
- data.tar.gz: 7ea84b4a4c0601a8c291020f538817b4d7dd7503aa57c22124e2dedf8deb3f34
3
+ metadata.gz: e6eb13261f7f9ed89665a78f4a39b41936486bbbb945de36818908d703f078cd
4
+ data.tar.gz: b968b91fe10b4075ed1544d7a98e8f4257401464f138c790ee1290d597a1e018
5
5
  SHA512:
6
- metadata.gz: 3b906c3c277e8f1a5a923c7e05a57491b801109d61d8bda3f3ab393905eff5b39297663ce856ec06735703df5bc1a2389be39948e6b23f633657cc6744226233
7
- data.tar.gz: 0ffe6a62bed3f6f8e32c4a087fb3d1a7fb617ff1867e27d3d99f20c08e098de53230885e4dcd438348347596368366212bf17a81042528e5767abe5baa6300d0
6
+ metadata.gz: cdbe93545cd55d9b8ae9d9d2490c08e9e55bccceb5653b9d5ab680ce141b3238391d12949b50df6b52821847e8902891f6d1c5ed76417b7f6dbe035735b92702
7
+ data.tar.gz: 1becd936b596332a278fd5895f6f37ad67356b862bdb33bd5df6d1aa49f441bdfd2a2b94cd9f4bb75d15fbc54c94568a0be12629ecefbd1809ed7013aef67c81
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 2.1.0
6
+
7
+ ### New features
8
+
9
+ #### Exclude pages from search engine results
10
+
11
+ You can now exclude a page from search engine results by including `prevent_indexing: true` in the page's frontmatter.
12
+
13
+ This was added in [pull request #192: Fixes and improvements to meta tags](https://github.com/alphagov/tech-docs-gem/pull/192).
14
+
15
+ ### Fixes
16
+
17
+ We’ve made fixes in the following pull requests:
18
+
19
+ - [#192: Fixes and improvements to meta tags](https://github.com/alphagov/tech-docs-gem/pull/192)
20
+
3
21
  ## 2.0.13
4
22
 
5
23
  - [Pull request #189: Update orange code highlight colour to meet minimum AA colour contrast ratio criterion](https://github.com/alphagov/tech-docs-gem/pull/189)
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  title: GOV.UK Documentation Example
3
+ description: Example of a documentation homepage
3
4
  old_paths:
4
5
  - /something/old-as-well.html
5
6
  ---
@@ -0,0 +1,10 @@
1
+ ---
2
+ title: Un-indexed Page
3
+ prevent_indexing: true
4
+ hide_in_navigation: true
5
+ ---
6
+
7
+ # Un-indexed page
8
+
9
+ This page should not be indexed by search engines, because it contains a
10
+ `<meta name="robots" content="noindex">` tag.
@@ -8,12 +8,8 @@ module GovukTechDocs
8
8
  def tags
9
9
  all_tags = {
10
10
  "description" => page_description,
11
- "og:description" => page_description,
12
- "og:image" => page_image,
13
- "og:site_name" => site_name,
14
- "og:title" => page_title,
15
- "og:type" => "object",
16
- "og:url" => canonical_url,
11
+ "google-site-verification" => google_site_verification,
12
+ "robots" => robots,
17
13
  "twitter:card" => "summary",
18
14
  "twitter:domain" => URI.parse(host).host,
19
15
  "twitter:image" => page_image,
@@ -24,6 +20,21 @@ module GovukTechDocs
24
20
  Hash[all_tags.select { |_k, v| v }]
25
21
  end
26
22
 
23
+ # OpenGraph uses the non-standard property attribute instead of name, so we
24
+ # return these separately so we can output them correctly.
25
+ def opengraph_tags
26
+ all_opengraph_tags = {
27
+ "og:description" => page_description,
28
+ "og:image" => page_image,
29
+ "og:site_name" => site_name,
30
+ "og:title" => page_title,
31
+ "og:type" => "object",
32
+ "og:url" => canonical_url,
33
+ }
34
+
35
+ Hash[all_opengraph_tags.select { |_k, v| v }]
36
+ end
37
+
27
38
  def browser_title
28
39
  [page_title, site_name].select(&:present?).uniq.join(" - ")
29
40
  end
@@ -45,11 +56,19 @@ module GovukTechDocs
45
56
  end
46
57
 
47
58
  def page_description
48
- locals[:description] || frontmatter.description
59
+ locals[:description] || frontmatter[:description]
49
60
  end
50
61
 
51
62
  def page_title
52
- locals[:title] || frontmatter.title
63
+ locals[:title] || frontmatter[:title]
64
+ end
65
+
66
+ def robots
67
+ "noindex" if config[:tech_docs][:prevent_indexing] || frontmatter[:prevent_indexing]
68
+ end
69
+
70
+ def google_site_verification
71
+ config[:tech_docs][:google_site_verification]
53
72
  end
54
73
 
55
74
  def host
@@ -1,3 +1,3 @@
1
1
  module GovukTechDocs
2
- VERSION = "2.0.13".freeze
2
+ VERSION = "2.1.0".freeze
3
3
  end
@@ -4,9 +4,6 @@
4
4
  <meta content="IE=edge" http-equiv="X-UA-Compatible">
5
5
  <meta charset="utf-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
7
- <% if config[:tech_docs][:prevent_indexing] %>
8
- <meta name="robots" content="noindex">
9
- <% end %>
10
7
 
11
8
  <title><%= meta_tags.browser_title %></title>
12
9
 
@@ -14,11 +11,11 @@
14
11
 
15
12
  <link rel="canonical" href="<%= meta_tags.canonical_url %>">
16
13
 
17
- <% if config[:tech_docs][:google_site_verification] %>
18
- <meta name="google-site-verification" content="<%= config[:tech_docs][:google_site_verification] %>" />
14
+ <% meta_tags.tags.each do |name, content| %>
15
+ <%= tag :meta, name: name, content: content %>
19
16
  <% end %>
20
17
 
21
- <% meta_tags.tags.each do |property, content| %>
18
+ <% meta_tags.opengraph_tags.each do |property, content| %>
22
19
  <%= tag :meta, property: property, content: content %>
23
20
  <% end %>
24
21
 
@@ -1108,9 +1108,9 @@
1108
1108
  }
1109
1109
  },
1110
1110
  "lodash": {
1111
- "version": "4.17.15",
1112
- "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
1113
- "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==",
1111
+ "version": "4.17.19",
1112
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
1113
+ "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
1114
1114
  "dev": true
1115
1115
  },
1116
1116
  "loose-envify": {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_tech_docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Government Digital Service
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-28 00:00:00.000000000 Z
11
+ date: 2020-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -363,6 +363,7 @@ files:
363
363
  - example/source/nested-page/index.html.md
364
364
  - example/source/not-expired-page.html.md
365
365
  - example/source/pets.yml
366
+ - example/source/prevent-index-page.html.md
366
367
  - example/source/stylesheets/print.css.scss
367
368
  - example/source/stylesheets/screen-old-ie.css.scss
368
369
  - example/source/stylesheets/screen.css.scss