File tree 2 files changed +13
-11
lines changed
lib/jekyll-relative-links
spec/jekyll-relative-links
2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
module JekyllRelativeLinks
4
4
class Generator < Jekyll ::Generator
5
- attr_accessor :site
5
+ attr_accessor :site , :config
6
6
7
7
# Use Jekyll's native relative_url filter
8
8
include Jekyll ::Filters ::URLFilters
@@ -16,20 +16,20 @@ class Generator < Jekyll::Generator
16
16
CONFIG_KEY = "relative_links"
17
17
ENABLED_KEY = "enabled"
18
18
COLLECTIONS_KEY = "collections"
19
- LOG_KEY = "JekyllRelativeLinks :"
19
+ LOG_KEY = "Relative Links :"
20
20
21
21
safe true
22
22
priority :lowest
23
23
24
- def initialize ( site )
25
- @site = site
26
- @context = context
24
+ def initialize ( config )
25
+ @config = config
27
26
end
28
27
29
28
def generate ( site )
29
+ return if disabled?
30
+
30
31
@site = site
31
32
@context = context
32
- return if disabled?
33
33
34
34
documents = site . pages
35
35
documents = site . pages + site . docs_to_write if collections?
@@ -124,7 +124,7 @@ def fragment?(string)
124
124
end
125
125
126
126
def option ( key )
127
- site . config [ CONFIG_KEY ] && site . config [ CONFIG_KEY ] [ key ]
127
+ config [ CONFIG_KEY ] && config [ CONFIG_KEY ] [ key ]
128
128
end
129
129
130
130
def disabled?
@@ -150,7 +150,7 @@ def excluded?(document)
150
150
end
151
151
152
152
def global_entry_filter
153
- @global_entry_filter ||= Jekyll ::EntryFilter . new ( @ site)
153
+ @global_entry_filter ||= Jekyll ::EntryFilter . new ( site )
154
154
end
155
155
end
156
156
end
Original file line number Diff line number Diff line change 17
17
let ( :item ) { doc_by_path ( site , "_items/some-item.md" ) }
18
18
let ( :item_2 ) { doc_by_path ( site , "_items/some-subdir/another-item.md" ) }
19
19
20
- subject { described_class . new ( site ) }
20
+ subject { described_class . new ( site . config ) }
21
21
22
22
before ( :each ) do
23
23
site . reset
24
24
site . read
25
25
end
26
26
27
- it "saves the site " do
28
- expect ( subject . site ) . to eql ( site )
27
+ it "saves the config " do
28
+ expect ( subject . config ) . to eql ( site . config )
29
29
end
30
30
31
31
context "detecting markdown" do
32
+ before { subject . instance_variable_set "@site" , site }
33
+
32
34
it "knows when an extension is markdown" do
33
35
expect ( subject . send ( :markdown_extension? , ".md" ) ) . to eql ( true )
34
36
end
You can’t perform that action at this time.
0 commit comments