From: Ben Sherratt Date: Sat, 4 Jul 2026 19:31:30 +0000 (+0100) Subject: Centralise permalink generation X-Git-Url: https://git.bts.cx/cx.git/commitdiff_plain/c31a7eee27fd40e7aa558ad15e33f65f9fb6aed2?hp=7eeae5c4183434a1cf7c0613b3dc8dd953b55810 Centralise permalink generation --- diff --git a/cx/lib/posts.php b/cx/lib/posts.php index a7ebfa4..326d81c 100644 --- a/cx/lib/posts.php +++ b/cx/lib/posts.php @@ -45,6 +45,11 @@ class Post { } } + public function get_permalink_path() { + $post_permalink = $this->is_page ? '/' . $this->slug : '/' . date('Y', $this->date) . '/' . date('m', $this->date) . '/' . $this->slug; + return $post_permalink; + } + public function get_metadata() { $data = []; diff --git a/cx/templates/public/pages/atom.php b/cx/templates/public/pages/atom.php index 398443d..0fa507b 100644 --- a/cx/templates/public/pages/atom.php +++ b/cx/templates/public/pages/atom.php @@ -17,7 +17,7 @@ -date) . '/' . date('m', $post->date) . '/' . $post->slug; ?> +get_permalink_path(); ?> <?= $post->title ?> diff --git a/cx/templates/public/pages/post.php b/cx/templates/public/pages/post.php index a4123c0..0a85176 100644 --- a/cx/templates/public/pages/post.php +++ b/cx/templates/public/pages/post.php @@ -1,6 +1,6 @@ get_metadata(); ?> -date) . '/' . date('m', $post->date) . '/' . $post->slug; ?> +get_permalink_path(); ?> $post->title, 'cx_post_meta' => $post_metadata, 'cx_post_permalink' => $post_permalink]); ?>