jekyll-relative-links 0.1.1 → 0.1.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c000bb6ebfda72f6f406bdab3e42dbbe497fd206
|
4
|
+
data.tar.gz: 86628c8c052b43529a1cdafad189d8510c9a49fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 104d65622591677c318a44ce61d5324a0643d666ffff39e1172a9927f7ebcc381e3b6a961df136dbcab2aad947e668663a80fbc85052a5509a5eab09e54b5128
|
7
|
+
data.tar.gz: 178b03c4159090d6bfb4c8c7a7d2bdb1aff1a266631739dfd424b1d325ad03f5e69f6c821adae92bef95a6971528a7970175f0808d090e9b6aa94085acc6b560
|
@@ -2,6 +2,9 @@ module JekyllRelativeLinks
|
|
2
2
|
class Generator < Jekyll::Generator
|
3
3
|
attr_accessor :site
|
4
4
|
|
5
|
+
# Use Jekyll's native relative_url filter
|
6
|
+
include Jekyll::Filters::URLFilters
|
7
|
+
|
5
8
|
LINK_REGEX = %r!\[([^\]]+)\]\(([^\)]+)\)!
|
6
9
|
CONVERTER_CLASS = Jekyll::Converters::Markdown
|
7
10
|
|
@@ -9,12 +12,14 @@ module JekyllRelativeLinks
|
|
9
12
|
priority :lowest
|
10
13
|
|
11
14
|
def initialize(site)
|
12
|
-
@site
|
15
|
+
@site = site
|
16
|
+
@context = context
|
13
17
|
end
|
14
18
|
|
15
19
|
def generate(site)
|
16
|
-
@site
|
17
|
-
|
20
|
+
@site = site
|
21
|
+
@context = context
|
22
|
+
|
18
23
|
site.pages.each do |page|
|
19
24
|
next unless markdown_extension?(page.extname)
|
20
25
|
url_base = File.dirname(page.path)
|
@@ -26,7 +31,7 @@ module JekyllRelativeLinks
|
|
26
31
|
path_from_root = absolute_path.sub(%r!\A#{Dir.pwd}/!, "")
|
27
32
|
|
28
33
|
if (url = url_for_path(path_from_root))
|
29
|
-
"[#{link_text}](#{
|
34
|
+
"[#{link_text}](#{url})"
|
30
35
|
else
|
31
36
|
original
|
32
37
|
end
|
@@ -36,6 +41,10 @@ module JekyllRelativeLinks
|
|
36
41
|
|
37
42
|
private
|
38
43
|
|
44
|
+
def context
|
45
|
+
JekyllRelativeLinks::Context.new(site)
|
46
|
+
end
|
47
|
+
|
39
48
|
def markdown_extension?(extension)
|
40
49
|
markdown_converter.matches(extension)
|
41
50
|
end
|
@@ -49,7 +58,7 @@ module JekyllRelativeLinks
|
|
49
58
|
return unless markdown_extension?(extension)
|
50
59
|
|
51
60
|
page = site.pages.find { |p| p.path == path }
|
52
|
-
page.url if page
|
61
|
+
relative_url(page.url) if page
|
53
62
|
end
|
54
63
|
end
|
55
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-relative-links
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- lib/jekyll-relative-links.rb
|
63
|
+
- lib/jekyll-relative-links/context.rb
|
63
64
|
- lib/jekyll-relative-links/generator.rb
|
64
65
|
- lib/jekyll-relative-links/version.rb
|
65
66
|
homepage: https://github.com/benbalter/jekyll-relative-links
|
@@ -82,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
83
|
version: '0'
|
83
84
|
requirements: []
|
84
85
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.5.2
|
86
87
|
signing_key:
|
87
88
|
specification_version: 4
|
88
89
|
summary: A Jekyll plugin to convert relative links to markdown files to their rendered
|