Add page-specific JavaScript support

Update documentation for new JS variables and rendering pipeline

Add script.js file support to content directories

Implement cache-busting for JavaScript files

Update static file serving to include JavaScript files

Document page-specific script loading in base.php
This commit is contained in:
Ruben 2026-02-06 18:47:23 +01:00
parent f8a352afce
commit f1447049e4
6 changed files with 70 additions and 7 deletions

View file

@ -211,6 +211,27 @@ MD5 hash of page-specific CSS for cache busting.
**Optional:** Only set if `$pageCssUrl` exists
**Example:** See `$pageCssUrl` above
### `$pageJsUrl`
URL to page-specific JavaScript file.
**Type:** String (URL)
**Optional:** Only set if `script.js` exists in content directory
**Example:**
```php
<?php if (!empty($pageJsUrl)): ?>
<script defer src="<?= htmlspecialchars($pageJsUrl) ?>?v=<?= htmlspecialchars($pageJsHash ?? '') ?>"></script>
<?php endif; ?>
```
### `$pageJsHash`
MD5 hash of page-specific JavaScript for cache busting.
**Type:** String (MD5 hash)
**Optional:** Only set if `$pageJsUrl` exists
**Example:** See `$pageJsUrl` above
### `$feedUrl`
URL to the Atom feed for the current list page.
@ -415,6 +436,8 @@ Then use in templates:
| `$translations` | ✓ | — | — |
| `$pageCssUrl` | ✓ | — | — |
| `$pageCssHash` | ✓ | — | — |
| `$pageJsUrl` | ✓ | — | — |
| `$pageJsHash` | ✓ | — | — |
| `$feedUrl` | ✓ | — | — |
| `$metadata` | — | ✓ | ✓ |
| `$pageContent` | — | — | ✓ |