muhh.lol/Rakefile
2024-05-02 22:53:26 +02:00

59 lines
1.1 KiB
Ruby

require "jekyll"
require "time"
desc "create a new note"
task :note, [:content] do |_t, args|
slug = "#{Date.today}-#{('a'..'z').to_a.repeated_permutation(1).to_a.sample(2).join}"
content = args[:content]
file = File.join(
File.dirname(__FILE__),
'_notes',
"#{slug}.md"
)
frontmatter = <<~EONOTE
---
layout: default
title: Note
date: "#{DateTime.now.strftime("%Y-%m-%d %H:%M")}"
---
EONOTE
unless content.nil?
File.write(file, frontmatter + content)
else
File.write(file, frontmatter)
system("#{ENV['EDITOR']} #{file}")
end
end
desc "build site"
task :build do
Jekyll::Commands::Build.process({})
end
desc "clean site"
task :clean do
Jekyll::Commands::Clean.process({})
end
desc "serve local site"
task :serve => [:build] do
Jekyll::Commands::Serve.process({
incremental: true,
livereload: true,
skip_initial_build: false,
open_url: true,
})
end
desc "deploy site"
task :deploy => [:build] do
sh "rsync -az --delete ./_site/ srv.muhh.lol:/var/www/htdocs/muhh.lol/"
end
task :default => [:clean, :build, :serve]