Me pehea te whakamahi i a Jekyll ki te whakaputa aunoa i te waa hanga tuhinga me te ngawari ki te whakapiki ake i te waa whakahou blog?

ka rite koe ki te whakamahiJekyllKa tuhi tuhinga, karekau koe e pai ki te whakararuraru i te hanga-a-ringa i nga konae, te whakarereke i nga toronga konae, katahi ka taapiri i te wetereo yml ki te timatanga o te tuhinga, tika?

Na ka whakaaro pea koeHe tuhinga hou a Jekyll, ki te whakangawari i enei mea katoa, kaore e tika kia tuhia he tuhinga?

Kaua nga kaihōtaka katoa e tuhi waehere kia mangere noa? I tenei wa, ka taea e Rake te whai waahi.

Me pehea te whakamahi i a Jekyll hei whakaputa aunoa i nga tuhinga?

I runga i nga whakaritenga a Jekyll mo te taitara md me te whakatakotoranga yaml, he uaua rawa ki te tuhi a-ringa i te yaml i nga wa katoa, no reira he pai te whiriwhiri ma te whakamahi i nga tuhinga hei whakaputa i nga ihirangi.

Me pehea te whakamahi i a Jekyll ki te whakaputa aunoa i te waa hanga tuhinga me te ngawari ki te whakapiki ake i te waa whakahou blog?

Tuatahi, tirohia mena kua whakauruhia te rake:

gem list rake

Mena kaore i whakauruhia, whakauruhia:

gem install rake

Muri iho, hangahia he Rakefile ka tuu ki te raarangi pakiaka o jekyll.

Na, kapehia te waehere e whai ake nei ki te Rakefile:

require 'rake'
require 'yaml'

SOURCE = "."
CONFIG = {
'posts' => File.join(SOURCE, "_posts"),
'post_ext' => "md",
}

# Usage: rake post title="A Title"
desc "Begin a new post in #{CONFIG['posts']}"
task :post do
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
title = ENV["title"] || "new-post"
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
filename = File.join(CONFIG['posts'], "#{Time.now.strftime('%Y-%m-%d')}-#{slug}.#{CONFIG['post_ext']}")
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end

puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "title: \"#{title.gsub(/-/,' ')}\""
post.puts "category: "
post.puts "tags: []"
post.puts "---"
end
end # task :post
  • He putanga ngawari noa tenei.

Hei whakamutunga, tomo ki te raina whakahau:

rake post title="article name"

Ma te tangi, ka noho koe ki reira _post I roto i te kōpaki, i kite ahau i tetahi tuhinga hou me te ingoa kōnae年-月-日-文章标题.md.

发表 评论

Ka kore e whakaputaina to wahitau imeera. 必填 项 已 用 * Tapanga

Panuku ki te Runga