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 5fe5535b4f
No known key found for this signature in database
10 changed files with 17 additions and 52 deletions

4
package-lock.json generated
View file

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

View file

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

View file

@ -9,39 +9,8 @@
$requestUri = $_SERVER["REQUEST_URI"]; $requestUri = $_SERVER["REQUEST_URI"];
$url = trim(parse_url($requestUri, PHP_URL_PATH), "/"); $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)) { if (!preg_match('/^books\/[\w-]+$/', $url)) {
http_response_code(404); header("Location: /404/", true, 302);
header("Content-Type: text/html; charset=utf-8");
readfile(__DIR__ . "/../404/index.html");
exit(); exit();
} }
@ -49,9 +18,7 @@
$book = $fetcher->fetch($url); $book = $fetcher->fetch($url);
if (!$book) { if (!$book) {
http_response_code(404); header("Location: /404/", true, 302);
header("Content-Type: text/html; charset=utf-8");
readfile(__DIR__ . "/../404/index.html");
exit(); exit();
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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