jekyll-multiple-languages 2.0.2 → 2.0.3

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
  SHA1:
3
- metadata.gz: dceec3b9f537809ad9a13c1b9365f2e093b9c3a4
4
- data.tar.gz: e8ae9840c963a672de0336850bc049bcd1c09c3a
3
+ metadata.gz: fad990406afa6adf74cab62bff58afbd8e200536
4
+ data.tar.gz: f72d6fefbce529d3e7ec3885fb474e98d2e0b62a
5
5
  SHA512:
6
- metadata.gz: 0eff793caeb0b12ce11324a0434e5de19c3d12b921a7e6e25ba46242e036c765a029526c0d88d96bbee628247a56e23e4f6c0ea7312f49901d09384086f7a6ea
7
- data.tar.gz: 38e3ec0a1b021513ce2cbfbc9a3a07535b7dc92314e94e9ba1ef4a3e6fd2338ff5e76949f7f2580b499e2804185c38133e43b3d7f7c0084ee4741820be912e2a
6
+ metadata.gz: 001830a8ff619e8b5fec3df82e2ab0cb081a99099f12314a1d8d5997d9293713310a1f2c69c85574db4c850388cbf56de556874520018c6bee479056014a299b
7
+ data.tar.gz: a28e50fc49b56678068fd80d7a4f3e8132d51a19f96718d06ee8cd2e11cff6ffdfe53cd3eeaa08fcb3ece269435767d79dad44e5a7331f5647846f2043120d6c
@@ -3,6 +3,8 @@ module Jekyll
3
3
  class Document
4
4
  include MultiLang
5
5
 
6
+ attr_accessor :next_in_language, :previous_in_language
7
+
6
8
  alias :initialize_org :initialize
7
9
  def initialize(path, relations)
8
10
  detect_language(relations[:site], path)
@@ -35,11 +37,32 @@ module Jekyll
35
37
  rewrite_url(url_org)
36
38
  end
37
39
 
40
+ def next_in_language
41
+ posts = site.posts_by_language[@language].values
42
+ pos = posts.index { |post| post.equal?(self) }
43
+ if pos && pos < posts.length - 1
44
+ posts[pos + 1]
45
+ else
46
+ nil
47
+ end
48
+ end
49
+
50
+ def previous_in_language
51
+ posts = site.posts_by_language[@language].values
52
+ pos = posts.index { |post| post.equal?(self) }
53
+ if pos && pos > 0
54
+ posts[pos - 1]
55
+ else
56
+ nil
57
+ end
58
+ end
59
+
38
60
  def inspect
39
61
  "<Post: id: #{self.id} url: #{self.url} language: #{self.language}>"
40
62
  end
41
63
 
42
64
  def language_attributes_for_liquid
65
+ %w[previous_in_language next_in_language]
43
66
  end
44
67
 
45
68
  alias :to_liquid_org :to_liquid
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  module Jekyll
3
3
  module MultiLang
4
- attr_accessor :language, :is_default_language, :url_no_language, :next_in_language, :previous_in_language
4
+ attr_accessor :language, :is_default_language
5
5
 
6
6
  def detect_language(site, name)
7
7
  name_no_language = name.dup
@@ -36,25 +36,6 @@ module Jekyll
36
36
  @url_no_language
37
37
  end
38
38
 
39
- def next_in_language
40
- posts = site.posts_by_language[@language].values
41
- pos = posts.index { |post| post.equal?(self) }
42
- if pos && pos < posts.length - 1
43
- posts[pos + 1]
44
- else
45
- nil
46
- end
47
- end
48
-
49
- def previous_in_language
50
- posts = site.posts_by_language[@language].values
51
- pos = posts.index { |post| post.equal?(self) }
52
- if pos && pos > 0
53
- posts[pos - 1]
54
- else
55
- nil
56
- end
57
- end
58
39
 
59
40
  # rewrite url
60
41
  def rewrite_url(url)
@@ -67,7 +48,7 @@ module Jekyll
67
48
 
68
49
  def append_data_for_liquid(data_for_liquid)
69
50
  attrs_for_lang = self.language_attributes_for_liquid || []
70
- attrs_for_lang.concat(%w[language is_default_language url_no_language previous_in_language next_in_language])
51
+ attrs_for_lang.concat(%w[language is_default_language])
71
52
  further_data = Hash[attrs_for_lang.map { |attribute|
72
53
  [attribute, send(attribute)]
73
54
  }]
@@ -79,6 +79,7 @@ module Jekyll
79
79
 
80
80
  original = site_payload_org
81
81
 
82
+ # convert map to array
82
83
  posts_by_language = {}
83
84
  pages_by_language = {}
84
85
  self.languages.dup.each { |lang|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-multiple-languages
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - srain