Skip to content

Commit 6828a91

Browse files
committed
Manually emit the YAML front matter, since YAML.dump does not respect unicode.
1 parent c6137a2 commit 6828a91

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

_tasks/import.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'fileutils'
2-
require 'yaml'
32

4-
gem 'spidr', '~> 0.3'
3+
gem 'spidr', '~> 0.4'
54
require 'spidr'
65

76
gem 'kramdown', '~> 0.13'
@@ -23,14 +22,14 @@
2322
agent.every_ok_page do |page|
2423
path = page.url.path[1..-1]
2524

26-
layout = LAYOUTS[:default]
25+
layout = :default
2726

2827
if path =~ %r{^[a-z_-]+/news/\d{4}/\d{1,2}/\d{1,2}/[^/]+/$}
2928
# map news posts in to news/_posts/
3029
dirs = path.split('/')
3130
local_path = File.join(OUTPUT_DIR,dirs[0,2],'_posts',dirs[2..-1].join('-')) + '.md'
3231

33-
layout = LAYOUTS[:post]
32+
layout = :post
3433
else
3534
# normal page
3635
local_path = File.join(OUTPUT_DIR,path)
@@ -53,17 +52,18 @@
5352

5453
File.open(local_path,'w') do |file|
5554
if page.html?
56-
header = {
57-
'layout' => layout,
58-
'title' => page.title.strip,
59-
'lang' => path.split('/',2).first
60-
}
61-
62-
# add the YAML header
63-
YAML.dump(header,file)
64-
65-
# YAML header separator
66-
file.puts '---'
55+
title = page.title.strip
56+
lang = path.split('/',2).first
57+
58+
# add the YAML front matter
59+
file.puts(
60+
'---',
61+
"layout: #{LAYOUTS[layout]}",
62+
"title: \"#{title}\"",
63+
"lang: #{lang}",
64+
'---',
65+
''
66+
)
6767

6868
if (content_div = page.at('#content'))
6969
# remove all comments

0 commit comments

Comments
 (0)