jekyll-migrate-permalink 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/README.md +1 -1
- data/lib/jekyll/commands/migrate_permalink.rb +24 -18
- data/lib/jekyll/migrate/permalink/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73dac4e6c719e1b652d0bba9b4e2d0479f845126
|
4
|
+
data.tar.gz: 49fd29a1c4db9d6cf3cdf2fcdc8a9e229521dc53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc9486ef3d7c1715847cc4b215a71cbb9942c1e10371b656b57268a12c8771639e4a9845fa6167453edb06a5cdf775f4d230c34ca9ca0800ba95ffb71bd620c
|
7
|
+
data.tar.gz: 520b8f1907ed35fc92eb21c96a6d6feb0302396d2843597c39da031063c1078ee1632352abcf727daf8fb3bce8b9432116de2785442b57ba177bf5fe08f3d653
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -41,6 +41,6 @@ The [`jekyll-redirect-from`](https://github.com/jekyll/jekyll-redirect-from) plu
|
|
41
41
|
2. Update your permalink in `_config.yml`
|
42
42
|
3. Build your site!
|
43
43
|
|
44
|
-
|
44
|
+
## Caveats
|
45
45
|
|
46
46
|
Note that the plugin loads the front matter as YAML in order to safely manipulate, and then converts it back to a string. This process may result in some slight formatting changes to your front matter.
|
@@ -26,30 +26,36 @@ module Jekyll
|
|
26
26
|
|
27
27
|
site.posts.docs.each do |post|
|
28
28
|
content = File.read(post.path, Utils.merged_file_read_opts(site, options))
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
output = process_content(content, post.url, opts["stategy"])
|
30
|
+
File.write(post.path, output, :mode => "w")
|
31
|
+
end
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
def process_content(content, url, strategy)
|
35
|
+
if content =~ Document::YAML_FRONT_MATTER_REGEXP
|
36
|
+
content = $POSTMATCH
|
37
|
+
frontmatter = SafeYAML.load(Regexp.last_match(1))
|
38
|
+
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
+
if frontmatter.nil?
|
41
|
+
frontmatter = frontmatter.to_h
|
42
|
+
end
|
43
|
+
|
44
|
+
if strategy == "retain" && !frontmatter["permalink"]
|
45
|
+
frontmatter["permalink"] = url
|
46
|
+
else
|
47
|
+
if frontmatter["redirect_from"].is_a? Array
|
48
|
+
frontmatter["redirect_from"].push(url)
|
49
|
+
elsif frontmatter["redirect_from"].is_a? String
|
50
|
+
frontmatter["redirect_from"] = [frontmatter["redirect_from"], url]
|
40
51
|
else
|
41
|
-
|
42
|
-
frontmatter["redirect_from"].push(post.url)
|
43
|
-
else
|
44
|
-
frontmatter["redirect_from"] = [post.url]
|
45
|
-
end
|
52
|
+
frontmatter["redirect_from"] = [url]
|
46
53
|
end
|
47
|
-
|
48
|
-
output = "#{frontmatter.to_yaml}---\n\n#{content}"
|
49
|
-
File.write(post.path, output, :mode => "w")
|
50
|
-
|
51
54
|
end
|
52
55
|
|
56
|
+
output = "#{frontmatter.to_yaml}---\n\n#{content}"
|
57
|
+
|
58
|
+
output
|
53
59
|
end
|
54
60
|
|
55
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-migrate-permalink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Chadwick
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
|
+
- .rspec
|
49
50
|
- .travis.yml
|
50
51
|
- Gemfile
|
51
52
|
- LICENSE.txt
|