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: 4c5e3a1ccdca6c7b5bf0337403228e7d2e4684a3
4
- data.tar.gz: 63c4a7ce9ef3fcb59138340e913e0280c059c6ca
3
+ metadata.gz: c000bb6ebfda72f6f406bdab3e42dbbe497fd206
4
+ data.tar.gz: 86628c8c052b43529a1cdafad189d8510c9a49fb
5
5
  SHA512:
6
- metadata.gz: 4e95f35451ec42f52c51505d58e93b1b7c0466076bb9c23fa246d21a219cf6d79ed47a85913bebbff57f134aa7d60343f61ae6261cf315e416e38cfc4f3d8266
7
- data.tar.gz: d24b2cc2e8af7ba699763d920e5c996f508e7af3a569b0915f070dc3077048ed5aae87d219086b96402a4a679063baed53c86925d045ede76348f5ffe0a1ebd0
6
+ metadata.gz: 104d65622591677c318a44ce61d5324a0643d666ffff39e1172a9927f7ebcc381e3b6a961df136dbcab2aad947e668663a80fbc85052a5509a5eab09e54b5128
7
+ data.tar.gz: 178b03c4159090d6bfb4c8c7a7d2bdb1aff1a266631739dfd424b1d325ad03f5e69f6c821adae92bef95a6971528a7970175f0808d090e9b6aa94085acc6b560
@@ -1,5 +1,6 @@
1
1
  require "jekyll"
2
2
  require "jekyll-relative-links/generator"
3
+ require "jekyll-relative-links/context"
3
4
 
4
5
  module JekyllRelativeLinks
5
6
  end
@@ -0,0 +1,13 @@
1
+ module JekyllRelativeLinks
2
+ class Context
3
+ attr_reader :site
4
+
5
+ def initialize(site)
6
+ @site = site
7
+ end
8
+
9
+ def registers
10
+ { :site => site }
11
+ end
12
+ end
13
+ end
@@ -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 = site
15
+ @site = site
16
+ @context = context
13
17
  end
14
18
 
15
19
  def generate(site)
16
- @site = 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}](#{site.baseurl}#{url})"
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
@@ -1,3 +1,3 @@
1
1
  module JekyllRelativeLinks
2
- VERSION = "0.1.1".freeze
2
+ VERSION = "0.1.2".freeze
3
3
  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.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.6.8
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