feat: first entities in database

This commit is contained in:
2026-04-23 12:21:13 +02:00
parent 28141deb8b
commit 13ac446793
10 changed files with 568 additions and 1 deletions

23
lib/bds/slug.ex Normal file
View File

@@ -0,0 +1,23 @@
defmodule BDS.Slug do
@moduledoc false
@german_transliterations %{"ß" => "ss"}
def slugify(nil), do: ""
def slugify(value) when is_binary(value) do
value
|> replace_german_characters()
|> String.normalize(:nfd)
|> String.replace(~r/[^\p{ASCII}]/u, "")
|> String.downcase()
|> String.replace(~r/[^a-z0-9]+/u, "-")
|> String.replace(~r/^-+|-+$/u, "")
end
defp replace_german_characters(value) do
Enum.reduce(@german_transliterations, value, fn {source, target}, acc ->
String.replace(acc, source, target)
end)
end
end