jekyll-stickyposts 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -0
- data/lib/jekyll/stickyposts.rb +20 -10
- data/lib/jekyll/stickyposts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be51434121b3596109ea4476f0c9b24cfa5bd503
|
4
|
+
data.tar.gz: f14b96fddc2097c5b25a196ed63f7ce60b43dddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7efbd0f07966d7ce235825562692c041f67a228c03c3c1923361642d1efd05bd598260bf2581f97485a92d679bcbbd3fdb14b5c0370c7d08a9a3e723a99f048d
|
7
|
+
data.tar.gz: 45080989ab2ef724fe13eadf0b34c64f26b32c82493dc3a232e023be6575f9b6606fb5c557a9765f704c4aa7ceace1b38ca3f52668d215a249853b30517c523e
|
data/.gitignore
CHANGED
data/lib/jekyll/stickyposts.rb
CHANGED
@@ -10,8 +10,8 @@ module Jekyll
|
|
10
10
|
Jekyll.logger.info "StickyPosts:", msg
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.debug(msg)
|
14
|
-
self.info msg if @debug
|
13
|
+
def self.debug(msg, doc = nil)
|
14
|
+
self.info msg if @debug && (doc.nil? || !doc.data['autogen_page'])
|
15
15
|
end
|
16
16
|
|
17
17
|
class Generator < Jekyll::Generator
|
@@ -46,20 +46,18 @@ module Jekyll
|
|
46
46
|
|
47
47
|
unless config["sort"] == "none"
|
48
48
|
sorted.sort! { |docB, docA|
|
49
|
-
a = docA.data
|
50
|
-
b = docB.data
|
49
|
+
a = sort_value(docA.data, sort_field)
|
50
|
+
b = sort_value(docB.data, sort_field)
|
51
51
|
|
52
52
|
if a.nil? && !b.nil?
|
53
53
|
-1
|
54
54
|
elsif !a.nil? && b.nil?
|
55
55
|
1
|
56
|
-
|
57
|
-
|
58
|
-
if a.respond_to?('to_datetime') && b.respond_to?('to_datetime')
|
56
|
+
elsif a.respond_to?('to_datetime') && b.respond_to?('to_datetime')
|
59
57
|
a.to_datetime <=> b.to_datetime
|
58
|
+
else
|
59
|
+
a <=> b
|
60
60
|
end
|
61
|
-
|
62
|
-
a <=> b
|
63
61
|
}
|
64
62
|
|
65
63
|
sorted.reverse! if sort_reverse
|
@@ -70,7 +68,7 @@ module Jekyll
|
|
70
68
|
sticky = []
|
71
69
|
sorted.delete_if do |doc|
|
72
70
|
if doc.data['sticky']
|
73
|
-
StickyPosts::debug "\"#{doc.data['title']}\" is sticky
|
71
|
+
StickyPosts::debug "\"#{doc.data['title']}\" is sticky; #{remove ? "removing" : "retaining"} copy", doc
|
74
72
|
if remove
|
75
73
|
sticky << doc
|
76
74
|
else
|
@@ -95,6 +93,18 @@ module Jekyll
|
|
95
93
|
StickyPosts::info "[#{collection}] #{sticky.length} post(s) pinned"
|
96
94
|
end
|
97
95
|
end
|
96
|
+
|
97
|
+
private
|
98
|
+
def sort_value(data, path)
|
99
|
+
value = data
|
100
|
+
|
101
|
+
path.split(":").each do |key|
|
102
|
+
return nil unless value = value[key.downcase.strip]
|
103
|
+
end
|
104
|
+
|
105
|
+
value.is_a?(Hash) ? nil : value
|
106
|
+
end
|
107
|
+
|
98
108
|
end
|
99
109
|
end
|
100
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-stickyposts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Ibrado
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|