require "jekyll" require "time" desc "create a new note" task :note do slug = "#{Date.today}-#{('a'..'z').to_a.repeated_permutation(1).to_a.sample(2).join}" 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 File.write(file, frontmatter) system("#{ENV['EDITOR']} #file}") 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]