hello hugo world

URLそのままで、wordpress から hugoへブログを移動しました。

URLを引き継ぎたかったので、移動には自作のrubyスクリプトを使いました。こういうのは車輪の再発明なんて呼ばなくて、自分にフィットしたやり方でやるほうが効率が良いのだ。

“`ruby
#!/bin/ruby

require ‘xmlsimple’
require ‘open-uri’
require ‘reverse_markdown’
require ‘date’
require “fileutils”

domain = “XXXX.YYYYY.ZZZ”
rss = “https://” + domain + “/feed”

hash = XmlSimple.xml_in(open(rss))
arr = hash[“channel”][0][“item”]

arr.each do item

title = item[“title”][0].empty? ? “無題” : item[“title”][0]
date = Time.parse(item[“pubDate”][0]).iso8601()
contents = ReverseMarkdown.convert item[“encoded”][0]
discription = ReverseMarkdown.convert item[“description”][0]
discription = discription.split(“…”)[0] + “…”

dir = item[“link”][0].split(“/”)[3] +”/”+ item[“link”][0].split(“/”)[4]
name = “/index.md”
FileUtils.mkdir_p(dir)
mdfile = “

コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です