fix(*.php.liquid): correct routing conflicts for dynamic and static pages

This commit is contained in:
Cory Dransfeldt 2025-05-16 11:35:12 -07:00
parent 48f527ab82
commit 30f34e8ff3
No known key found for this signature in database
10 changed files with 16 additions and 57 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "coryd.dev",
"version": "5.1.6",
"version": "5.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "coryd.dev",
"version": "5.1.6",
"version": "5.2.0",
"license": "MIT",
"dependencies": {
"html-minifier-terser": "7.2.0",

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "5.1.6",
"version": "5.2.0",
"description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module",
"engines": {

View file

@ -8,50 +8,11 @@
$requestUri = $_SERVER["REQUEST_URI"];
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/");
if (preg_match('/^books\/years\/(\d{4})$/', $url, $matches)) {
$year = $matches[1];
$filePath = __DIR__ . "/years/{$year}.html";
if (file_exists($filePath)) {
readfile($filePath);
} else {
http_response_code(404);
header("Content-Type: text/html; charset=utf-8");
readfile(__DIR__ . "/../404/index.html");
exit();
}
exit();
}
if ($url === "books") {
http_response_code(200);
header("Content-Type: text/html; charset=utf-8");
readfile(__DIR__ . "/index.html");
exit();
}
if ($url === "books/years") {
http_response_code(404);
header("Content-Type: text/html; charset=utf-8");
readfile(__DIR__ . "/../404/index.html");
exit();
}
if (!preg_match('/^books\/[\w-]+$/', $url)) {
http_response_code(404);
header("Content-Type: text/html; charset=utf-8");
readfile(__DIR__ . "/../404/index.html");
exit();
}
$fetcher = new BookFetcher();
$book = $fetcher->fetch($url);
if (!$book) {
http_response_code(404);
header("Content-Type: text/html; charset=utf-8");
readfile(__DIR__ . "/../404/index.html");
header("Location: /404/", true, 302);
exit();
}

View file

@ -28,24 +28,22 @@ ErrorDocument 500 /500/index.html
# dynamic page routing
## artists
RewriteRule ^music/artists/([^/]+)/?$ music/artists/index.php [L]
RewriteRule ^music/artists/([^/]+)/?$ music/artists/dynamic.php [L]
## books
RewriteRule ^books/([^/]+)/?$ books/index.php [L]
RewriteRule ^books/years/(\d{4})/?$ books/years/index.html [L]
RewriteRule ^books/?$ books/books.html [L]
RewriteRule ^books/([^/]+)/?$ books/dynamic.php [L]
## movies
RewriteRule ^watching/movies/([^/]+)/?$ watching/movies/index.php [L]
RewriteRule ^watching/movies/([^/]+)/?$ watching/movies/dynamic.php [L]
## shows
RewriteRule ^watching/shows/([^/]+)/?$ watching/shows/index.php [L]
RewriteRule ^watching/shows/([^/]+)/?$ watching/shows/dynamic.php [L]
## genres
RewriteRule ^music/genres/([^/]+)/?$ music/genres/index.php [L]
RewriteRule ^music/genres/([^/]+)/?$ music/genres/dynamic.php [L]
## tags
RewriteRule ^tags/([^/]+)(?:/([0-9]+))?/?$ tags/index.php [L]
RewriteRule ^tags/([^/]+)(?:/([0-9]+))?/?$ tags/dynamic.php [L]
## open graph assets

View file

@ -1,5 +1,5 @@
---
permalink: /music/artists/index.php
permalink: /music/artists/dynamic.php
type: dynamic
schema: artist
---

View file

@ -1,5 +1,5 @@
---
permalink: /books/index.php
permalink: /books/dynamic.php
type: dynamic
schema: book
---

View file

@ -1,5 +1,5 @@
---
permalink: /music/genres/index.php
permalink: /music/genres/dynamic.php
type: dynamic
schema: genre
---

View file

@ -1,5 +1,5 @@
---
permalink: /watching/movies/index.php
permalink: /watching/movies/dynamic.php
type: dynamic
schema: movie
---

View file

@ -1,5 +1,5 @@
---
permalink: /watching/shows/index.php
permalink: /watching/shows/dynamic.php
type: dynamic
schema: show
---

View file

@ -1,5 +1,5 @@
---
permalink: /tags/index.php
permalink: /tags/dynamic.php
type: dynamic
schema: tags
---