fix(*.php.liquid): correct routing conflicts for dynamic and static pages
This commit is contained in:
parent
48f527ab82
commit
30f34e8ff3
10 changed files with 16 additions and 57 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -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",
|
||||||
|
|
|
@ -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": {
|
||||||
|
|
|
@ -8,50 +8,11 @@
|
||||||
|
|
||||||
$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)) {
|
|
||||||
http_response_code(404);
|
|
||||||
header("Content-Type: text/html; charset=utf-8");
|
|
||||||
readfile(__DIR__ . "/../404/index.html");
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$fetcher = new BookFetcher();
|
$fetcher = new BookFetcher();
|
||||||
$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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
permalink: /music/artists/index.php
|
permalink: /music/artists/dynamic.php
|
||||||
type: dynamic
|
type: dynamic
|
||||||
schema: artist
|
schema: artist
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
permalink: /books/index.php
|
permalink: /books/dynamic.php
|
||||||
type: dynamic
|
type: dynamic
|
||||||
schema: book
|
schema: book
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
permalink: /music/genres/index.php
|
permalink: /music/genres/dynamic.php
|
||||||
type: dynamic
|
type: dynamic
|
||||||
schema: genre
|
schema: genre
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
permalink: /watching/movies/index.php
|
permalink: /watching/movies/dynamic.php
|
||||||
type: dynamic
|
type: dynamic
|
||||||
schema: movie
|
schema: movie
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
permalink: /watching/shows/index.php
|
permalink: /watching/shows/dynamic.php
|
||||||
type: dynamic
|
type: dynamic
|
||||||
schema: show
|
schema: show
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
permalink: /tags/index.php
|
permalink: /tags/dynamic.php
|
||||||
type: dynamic
|
type: dynamic
|
||||||
schema: tags
|
schema: tags
|
||||||
---
|
---
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue