Files
site/new_post.pl
2026-06-25 23:33:20 -06:00

49 lines
1.2 KiB
Perl

#!/usr/bin/env perl
use strict;
use warnings;
use Carp qw(croak);
use HTML::Composer;
use File::Slurp;
my $post_name = $ARGV[0];
if ( !$post_name ) {
croak "No post named provided!";
}
my $h = HTML::Composer->new;
my $post_template = [
head => [
title => ["An awesome new post!"],
meta => { name => "description", content => "Description of post" },
meta => { name => "robots" },
meta => { name => "keywords", content => "Awesome keywords" },
meta => { name => "charset", content => "utf-8", charset => "utf-8" },
link => { href => "/index.css", rel => "stylesheet" }
],
body => [
a => { href => "/" } => ["<< back"],
h1 => ["Post Title"],
p => ["Blah blah blah"],
h2 => ["Sub title"],
p => ["Blah blah blah"],
h4 => ["Related links:"],
ul => [
li => [
a => { href => "https://rawley.xyz/related-content" } =>
["Related content"]
]
]
]
];
my $html = $h->html($post_template);
print "Writing $post_name.html\n";
write_file( "posts/$post_name.html", $html );
print "DONE\n";