Add /_css and /_js endpoints.

This commit is contained in:
Jacob 2024-05-30 18:16:41 +02:00
parent 08249aaaf6
commit 3132a6ea0f
2 changed files with 17 additions and 1 deletions

View file

@ -53,6 +53,9 @@ Markdown document and it can be at any point.
- `@csgen.displayAuthors = "true"`
- `@csgen.enableComments = "true";`
- `@csgen.addAuthor = "one author here";`
- `@csgen.author = "author1|author2|author3";`
- `@csgen.addTag = "one tag here";`
- `@csgen.tag = "tag1|tag2|tag3";`
- `@csgen.markAsFeed = "false";`
- `@csgen.includePage = "/blog/my-awesome-blog-post";`
- `@csgen.redirectTo = "/blog/rss.xml";`
@ -81,6 +84,10 @@ There are also special csgen reserved endpoints. These are:
- Additional items to prepend to the menu.
- `/_404`
- The error to display when no page was found for the endpoint.
- `/_css`
- Stylesheet to append.
- `/_js`
- JavaScript to append.
## License

View file

@ -581,7 +581,16 @@ function printHeader($html, $printpage) {
$endpointFound = 1;
$html .= "\t\t<small id='title'>$Header->data</small>\n";
break;
}
if ($head['endpoint'] == "/_css") {
$html .= "<style>\n";
$html .= htmlspecialchars_decode(file_get_contents($head['file']));
$html .= "</style>\n";
}
if ($head['endpoint'] == "/_js") {
$html .= "<script>\n";
$html .= htmlspecialchars_decode(file_get_contents($head['file']));
$html .= "</script>\n";
}
}