->select('meta[name=created]')
->set_attribute(content => $page->created)
->select('link[data-cur-page-css]')->${\sub {
- if (-f $static_dir . "/page-css/" . $page->path . ".css") {
- $_[0]->set_attribute(href => "/static/page-css/" . $page->path . ".css");
- } else {
- $_[0]->replace('');
+ my $path = '';
+ my $replace = '';
+ my @parts = split /\//, $page->path;
+
+ foreach my $part (@parts) {
+ next unless $part;
+
+ $path .= "/" . $part;
+
+ if (-f $static_dir . "/page-css/$path.css") {
+ $replace .= "<link href='/static/page-css/$path.css' rel='stylesheet' type='text/css' />";
+ }
}
+
+ $_[0]->replace(HTML::Zoom->from_html($replace));
}}
->select('script[data-cur-page-js]')->${\sub {
- if (-f $static_dir . "/page-js/" . $page->path . ".js") {
- $_[0]->set_attribute(src => "/static/page-js/" . $page->path . ".js");
- } else {
- $_[0]->replace('');
- }
+ my $path = '';
+ my $replace = '';
+ my @parts = split /\//, $page->path;
+
+ foreach my $part (@parts) {
+ next unless $part;
+
+ $path .= "/" . $part;
+
+ if (-f $static_dir . "/page-js/$path.js") {
+ $replace .= "<script src='/static/page-js/$path.js' type='text/javascript'></script>";
+ }
+ }
+
+ $_[0]->replace(HTML::Zoom->from_html($replace));
}}
}