added blog entry; added robots.txt and sitemap
This commit is contained in:
parent
0343750b0b
commit
a8a532106e
@ -5,6 +5,8 @@ RewriteEngine On
|
|||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
RewriteRule ^blog/([^/]+)/?$ /blog.php?id=$1 [L,QSA]
|
RewriteRule ^blog/([^/]+)/?$ /blog.php?id=$1 [L,QSA]
|
||||||
|
|
||||||
|
RewriteRule ^sitemap\.xml$ /sitemap.php
|
||||||
|
|
||||||
# ----------------------------------------------------
|
# ----------------------------------------------------
|
||||||
# 2. Rewrite /lib/* or /blog/* to /error.php?code=404
|
# 2. Rewrite /lib/* or /blog/* to /error.php?code=404
|
||||||
# with 404 response code (internal rewriting)
|
# with 404 response code (internal rewriting)
|
||||||
|
@ -29,6 +29,8 @@ $rand_send_comment = mt_rand() % 5;
|
|||||||
|
|
||||||
<base target="_blank">
|
<base target="_blank">
|
||||||
|
|
||||||
|
<meta name="keywords" content="ludwig lehnert,blog,<?= join(",", $blog->keywords) ?>">
|
||||||
|
|
||||||
<title><?= $blog->title ?></title>
|
<title><?= $blog->title ?></title>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"title": "Test: First Blog Entry",
|
"title": "Test: First Blog Entry",
|
||||||
|
"keywords": [
|
||||||
|
"test",
|
||||||
|
"first blog entry"
|
||||||
|
],
|
||||||
"date": "2025-04-15",
|
"date": "2025-04-15",
|
||||||
"files": [
|
"files": [
|
||||||
"0.svg"
|
"0.svg"
|
||||||
|
12
www/blog/1.json
Normal file
12
www/blog/1.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"title": "Thoughts about edge computation",
|
||||||
|
"keywords": [
|
||||||
|
"edge",
|
||||||
|
"edge computation",
|
||||||
|
"thoughts about edge computation"
|
||||||
|
],
|
||||||
|
"date": "2025-04-17",
|
||||||
|
"files": [
|
||||||
|
"1.svg"
|
||||||
|
]
|
||||||
|
}
|
1
www/blog/1.svg
Normal file
1
www/blog/1.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 9.3 MiB |
@ -6,7 +6,7 @@ require_once __DIR__ . "/lib/_index.php";
|
|||||||
|
|
||||||
$blogs = Blog::getAll();
|
$blogs = Blog::getAll();
|
||||||
usort($blogs, function ($a, $b) {
|
usort($blogs, function ($a, $b) {
|
||||||
strtotime($b->date) - strtotime($a->date);
|
return strtotime($b->date) - strtotime($a->date);
|
||||||
});
|
});
|
||||||
|
|
||||||
?><!DOCTYPE html>
|
?><!DOCTYPE html>
|
||||||
|
@ -4,13 +4,15 @@ class Blog
|
|||||||
{
|
{
|
||||||
public readonly string $id;
|
public readonly string $id;
|
||||||
public readonly string $title;
|
public readonly string $title;
|
||||||
|
public readonly array $keywords;
|
||||||
public readonly string $date;
|
public readonly string $date;
|
||||||
public readonly array $files;
|
public readonly array $files;
|
||||||
|
|
||||||
public function __construct(string $id, string $title, string $date, array $files)
|
public function __construct(string $id, string $title, array $keywords, string $date, array $files)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
|
$this->keywords = $keywords;
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
$this->files = $files;
|
$this->files = $files;
|
||||||
}
|
}
|
||||||
@ -35,7 +37,7 @@ class Blog
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$json = json_decode(file_get_contents($path), true);
|
$json = json_decode(file_get_contents($path), true);
|
||||||
return new Blog($id, $json['title'], $json['date'], $json['files']);
|
return new Blog($id, $json['title'], $json['keywords'], $json['date'], $json['files']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
3
www/robots.txt
Normal file
3
www/robots.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
User-agent: *
|
||||||
|
Disallow: /assets/
|
||||||
|
Sitemap: https://lehnert.dev/sitemap.xml
|
39
www/sitemap.php
Normal file
39
www/sitemap.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . "/lib/_index.php";
|
||||||
|
|
||||||
|
$blogs = Blog::getAll();
|
||||||
|
|
||||||
|
echo '<?';
|
||||||
|
?>xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
<url>
|
||||||
|
<loc>https://lehnert.dev/</loc>
|
||||||
|
<lastmod>2025-04-17</lastmod>
|
||||||
|
<changefreq>monthly</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
|
||||||
|
<?php foreach ($blogs as $blog): ?>
|
||||||
|
<url>
|
||||||
|
<loc>https://lehnert.dev/blog/<?= $blog->id ?></loc>
|
||||||
|
<lastmod><?= $blog->date ?></lastmod>
|
||||||
|
<priority>0.8</priority>
|
||||||
|
</url>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>https://lehnert.dev/imprint</loc>
|
||||||
|
<lastmod>2025-04-16</lastmod>
|
||||||
|
<changefreq>yearly</changefreq>
|
||||||
|
<priority>0.5</priority>
|
||||||
|
</url>
|
||||||
|
|
||||||
|
<url>
|
||||||
|
<loc>https://lehnert.dev/privacy</loc>
|
||||||
|
<lastmod>2025-04-16</lastmod>
|
||||||
|
<changefreq>yearly</changefreq>
|
||||||
|
<priority>0.5</priority>
|
||||||
|
</url>
|
||||||
|
</urlset>
|
Loading…
x
Reference in New Issue
Block a user