fix: issue #11 wrong page titles compared to old app

This commit is contained in:
2026-07-05 12:58:44 +02:00
parent cf1d4bd46f
commit 28398b17f4
8 changed files with 208 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ defmodule BDS.Generation.Outputs do
import BDS.Generation.Sitemap, only: [render_feed: 3, render_atom: 3, render_calendar: 1]
alias BDS.Rendering.RenderContext
alias BDS.Rendering.Metadata, as: RenderMetadata
alias BDS.Rendering.TemplateSelection
@type output_callback :: ({String.t(), iodata()} -> any()) | nil
@@ -214,6 +215,7 @@ defmodule BDS.Generation.Outputs do
concurrent_flat_map(posts_by_category, fn {category, posts} ->
paginated_posts = Enum.chunk_every(posts, max(plan.max_posts_per_page, 1))
category_slug = archive_route_segment(category)
category_title = RenderMetadata.category_display_name(plan.category_settings, category)
total_pages = length(paginated_posts)
total_items = length(posts)
@@ -256,7 +258,7 @@ defmodule BDS.Generation.Outputs do
["category", category_slug],
page_number
),
render_archive_page(plan, category, page_posts, language, "category", pagination)
render_archive_page(plan, category_title, page_posts, language, "category", pagination)
}
report_output(output, on_output)
@@ -508,7 +510,7 @@ defmodule BDS.Generation.Outputs do
render_list_output(
plan,
language,
plan.project_name,
blog_page_title(plan),
page_posts,
%{kind: "core"},
pagination_for_page(

View File

@@ -4,20 +4,23 @@ defmodule BDS.Generation.Renderers do
alias BDS.Generation.Paths
alias BDS.Projects
alias BDS.Rendering
alias BDS.Rendering.Metadata, as: RenderMetadata
alias BDS.Rendering.RenderContext
@doc "Render the home page (HTML) using the project's template engine."
@spec render_home(map(), String.t() | nil) :: String.t()
def render_home(plan, language) do
title = blog_page_title(plan)
[
"<html>",
"<head><title>",
plan.project_name,
title,
"</title></head>",
"<body data-language=\"",
to_string(language),
"\"><main><h1>",
plan.project_name,
title,
"</h1></main></body>",
"</html>"
]
@@ -67,14 +70,15 @@ defmodule BDS.Generation.Renderers do
end
# Shared by every archive kind so category/tag pages get the same post
# payloads (loaded bodies, real hrefs) as date archives.
# payloads (loaded bodies, real hrefs) as date archives. The document title
# stays the blog title; the archive-specific label lives in `archive_context`.
defp render_archive_list_page(plan, title, archive_context, posts, language, kind, pagination) do
fallback = fn -> render_inline_list_page(title, posts, language, kind) end
render_list_output(
plan,
language,
title,
blog_page_title(plan),
build_list_posts(plan, posts, Paths.route_language(plan.language, language)),
archive_context,
pagination,
@@ -128,6 +132,14 @@ defmodule BDS.Generation.Renderers do
)
end
@doc "Blog document title (description, then name) shared by list/home pages."
@spec blog_page_title(map()) :: String.t()
def blog_page_title(plan) do
RenderMetadata.blog_page_title(
Map.get(plan, :project_description),
Map.get(plan, :project_name)
)
end
@doc "Render the project's 404 page via its template, falling back to a static page."
@spec render_not_found_output(map(), String.t() | nil) :: String.t()
def render_not_found_output(