fix: fix CSM-016 for real (previous commit was 015)

This commit is contained in:
2026-05-09 17:18:32 +02:00
parent f1de11a205
commit ce80f28e60
11 changed files with 35 additions and 20 deletions

View File

@@ -25,18 +25,24 @@ defmodule BDS.Rendering.FileSystem do
raise Liquex.Error, message: "Illegal template path '#{template_path}'"
true ->
filename = ensure_liquid_ext(normalized_path)
root_paths
|> Enum.map(&Path.expand(Path.join(&1, normalized_path <> ".liquid")))
|> Enum.map(&Path.expand(Path.join(&1, filename)))
|> Enum.find(&File.regular?/1)
|> case do
nil ->
Path.expand(Path.join(List.first(root_paths) || ".", normalized_path <> ".liquid"))
Path.expand(Path.join(List.first(root_paths) || ".", filename))
path ->
path
end
end
end
defp ensure_liquid_ext(path) do
if Path.extname(path) == ".liquid", do: path, else: path <> ".liquid"
end
end
defimpl Liquex.FileSystem, for: BDS.Rendering.FileSystem do

View File

@@ -50,13 +50,13 @@ defmodule BDS.Rendering.LinksAndLanguages do
])
|> String.downcase()
Map.put(acc, source_key, "/" <> media.file_path)
Map.put(acc, source_key, Path.join("/", media.file_path))
end)
end
def post_path(post, language_prefix)
when is_binary(language_prefix) and language_prefix != "" do
language_prefix <> post_path(post, nil)
String.trim_trailing(language_prefix, "/") <> post_path(post, nil)
end
def post_path(post, ""), do: post_path(post, nil)
@@ -65,13 +65,12 @@ defmodule BDS.Rendering.LinksAndLanguages do
datetime = Persistence.from_unix_ms!(post.created_at)
Path.join([
"/",
Integer.to_string(datetime.year),
String.pad_leading(Integer.to_string(datetime.month), 2, "0"),
String.pad_leading(Integer.to_string(datetime.day), 2, "0"),
post.slug,
"index.html"
])
|> then(&("/" <> String.trim_trailing(&1, "index.html")))
post.slug
]) <> "/"
end
def post_path(post, language, main_language) do

View File

@@ -24,6 +24,10 @@ defmodule BDS.Rendering.Metadata do
Enum.map(items, &to_template_menu_item/1)
end
def menu_items_from_raw(items) when is_list(items) do
Enum.map(items, &to_template_menu_item/1)
end
defp to_template_menu_item(item) do
kind = Map.get(item, :kind)
children = Enum.map(Map.get(item, :children, []), &to_template_menu_item/1)
@@ -40,7 +44,7 @@ defmodule BDS.Rendering.Metadata do
defp menu_item_href(%{kind: :home}), do: "/"
defp menu_item_href(%{kind: :page, slug: slug}) when is_binary(slug) and slug != "",
do: "/#{slug}/"
do: "/#{URI.encode(slug)}/"
defp menu_item_href(%{kind: :category_archive, slug: slug}) when is_binary(slug) and slug != "",
do: "/category/#{URI.encode(slug)}/"
@@ -109,7 +113,7 @@ defmodule BDS.Rendering.Metadata do
def default_pico_stylesheet_href(theme), do: PreviewAssets.stylesheet_href(theme)
def href_for_language(""), do: "/"
def href_for_language(prefix), do: prefix <> "/"
def href_for_language(prefix), do: String.trim_trailing(prefix, "/") <> "/"
def calendar_initial_year(%{created_at: created_at}) when is_integer(created_at),
do: Persistence.from_unix_ms!(created_at).year