From b1ec57890287a4ca5a026fce49d49cc1b6b8a853 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Thu, 6 Feb 2025 18:39:20 -0500 Subject: [PATCH] Format atom feed --- lib/DB.rakumod | 3 ++- lib/XQ.rakumod | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 lib/XQ.rakumod diff --git a/lib/DB.rakumod b/lib/DB.rakumod index fe30ec0..d5b8307 100644 --- a/lib/DB.rakumod +++ b/lib/DB.rakumod @@ -6,6 +6,7 @@ unit module DB; use Pandoc; use JSON::Class:auth; use XML; +use XQ; use DB::Post; use DB::BlogMeta; @@ -101,7 +102,7 @@ class PostDB { # Render the rss/atom feed my $atom-path = $out-dir.add('atom.xml'); my $atom = posts-to-atom self; - $atom-path.spurt: ~$atom; + $atom-path.spurt: format-xml(~$atom); } #| Get a list of posts sorted by date diff --git a/lib/XQ.rakumod b/lib/XQ.rakumod new file mode 100644 index 0000000..f7b0481 --- /dev/null +++ b/lib/XQ.rakumod @@ -0,0 +1,10 @@ +#| Interaction with xq +unit module XQ; + +#| Format an xml string +sub format-xml(Str:D $input --> Str:D) is export { + my $xq = run , :out, :in; + # Inject the xml + $xq.in.spurt: $input, :close; + $xq.out.slurp: :close +}