jekyll-locales 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +6 -0
- data/lib/jekyll/locales.rb +1 -0
- data/lib/jekyll/locales/hooks/post_render.rb +35 -0
- data/lib/jekyll/locales/site.rb +1 -0
- data/lib/jekyll/locales/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8064e214d9d871fab3a7d775064068f01acbf3194d8776601be47b245452b783
|
4
|
+
data.tar.gz: e00d19218061374a29e73baea210ad871535ff40c5bf3e775b5d1fa57ed04f5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b14589c075687b8f9c498b9b670339b37901690b4b51aebcd6b994d68d4b53d12ed47f42579df9abf8afd46a6585d7d3888eff420b22b79c742759b1325934e
|
7
|
+
data.tar.gz: 59d3a80ac8136b4b5e15343b4f25598c1468cde8797b6efae816f1303995d92c4559b9d26e73a460cea269965017e34dcf664d67eb2765b26534d385c043e612
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.1.11
|
4
|
+
|
5
|
+
- Add alternate URLs to link between languages when using
|
6
|
+
jekyll-linked-posts
|
7
|
+
|
8
|
+
## 0.1.10
|
9
|
+
|
10
|
+
- Prevent cleanup from removing other languages
|
11
|
+
|
3
12
|
## 0.1.9
|
4
13
|
|
5
14
|
- Loading locales as collection makes Jekyll render them even when
|
data/README.md
CHANGED
@@ -64,6 +64,12 @@ locales:
|
|
64
64
|
|
65
65
|
Then you can access them by using `page.locales` in your layout.
|
66
66
|
|
67
|
+
**Tip:** You can use
|
68
|
+
[jekyll-linked-posts](https://rubygems.org/gems/jekyll-linked-posts) to
|
69
|
+
make this process more resilient. It uses IDs instead of URLs and it
|
70
|
+
also allows you to access other data. From v0.1.11 it will also
|
71
|
+
generate alternate URLs so search engines can link between translations.
|
72
|
+
|
67
73
|
### Pages
|
68
74
|
|
69
75
|
You can translate the front matter by adding locale-specific variables
|
data/lib/jekyll/locales.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Jekyll::Hooks.register :site, :post_render do |site|
|
4
|
+
unless site.config['plugins'].include? 'jekyll-linked-posts'
|
5
|
+
Jekyll.logger.warn 'Enable jekyll-linked-posts to generate metadata about alternate pages'
|
6
|
+
next
|
7
|
+
end
|
8
|
+
|
9
|
+
# URLs can be relative but Google asks for fully qualified URLs
|
10
|
+
# @see {https://support.google.com/webmasters/answer/189077?hl=en}
|
11
|
+
url = site.config['url']&.sub(%r{/\z}, '')
|
12
|
+
|
13
|
+
unless url
|
14
|
+
Jekyll.logger.warn 'Provide a `url` value in configuration to create fully qualified URLs'
|
15
|
+
next
|
16
|
+
end
|
17
|
+
|
18
|
+
site.each_site_file do |doc|
|
19
|
+
next unless doc.is_a? Jekyll::Document
|
20
|
+
next if doc.output.nil?
|
21
|
+
next unless doc&.data&.dig 'locales'
|
22
|
+
|
23
|
+
alternate = doc.data['locales'].map do |translation|
|
24
|
+
locale = translation.collection.label
|
25
|
+
# TODO: Every doc should know how to build their own URL
|
26
|
+
doc_url = [url, locale, translation.url].join('/')
|
27
|
+
|
28
|
+
%(<link rel="alternate" hreflang="#{locale}" href="#{doc_url}" />)
|
29
|
+
end
|
30
|
+
|
31
|
+
next if alternate.empty?
|
32
|
+
|
33
|
+
doc.output.sub! '<head>', '<head>' + alternate.join
|
34
|
+
end
|
35
|
+
end
|
data/lib/jekyll/locales/site.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-locales
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/jekyll/locales.rb
|
92
92
|
- lib/jekyll/locales/hooks/cleanup.rb
|
93
93
|
- lib/jekyll/locales/hooks/page_post_init.rb
|
94
|
+
- lib/jekyll/locales/hooks/post_render.rb
|
94
95
|
- lib/jekyll/locales/site.rb
|
95
96
|
- lib/jekyll/locales/site_drop.rb
|
96
97
|
- lib/jekyll/locales/version.rb
|
@@ -101,7 +102,7 @@ metadata:
|
|
101
102
|
homepage_uri: https://0xacab.org/sutty/jekyll/jekyll-locales
|
102
103
|
source_code_uri: https://0xacab.org/sutty/jekyll/jekyll-locales
|
103
104
|
changelog_uri: https://0xacab.org/sutty/jekyll/jekyll-locales/blob/master/CHANGELOG.md
|
104
|
-
post_install_message:
|
105
|
+
post_install_message:
|
105
106
|
rdoc_options: []
|
106
107
|
require_paths:
|
107
108
|
- lib
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
120
|
rubygems_version: 3.0.3
|
120
|
-
signing_key:
|
121
|
+
signing_key:
|
121
122
|
specification_version: 4
|
122
123
|
summary: Jekyll plugin for localized sites
|
123
124
|
test_files: []
|