feat: links cruzados autor->/autor y parodia->/franquicia en posts
This commit is contained in:
@@ -420,6 +420,23 @@ export function getAuthorBySlug(slug: string): Author | null {
|
||||
return row ? rowToAuthor(row) : null
|
||||
}
|
||||
|
||||
// Devuelve el slug de un autor por su nombre (para enlazar desde los posts).
|
||||
// Si el autor no está registrado, lo registra sobre la marcha.
|
||||
export function getAuthorSlugByName(name: string): string | null {
|
||||
const d = getDb()
|
||||
const clean = (name || "").trim()
|
||||
if (!clean || clean === "sin artista" || clean === "dummy") return null
|
||||
|
||||
d.prepare("INSERT OR IGNORE INTO authors(name, slug) VALUES (?, ?)").run(
|
||||
clean,
|
||||
slugify(clean),
|
||||
)
|
||||
const row = d.prepare("SELECT slug FROM authors WHERE name = ?").get(clean) as
|
||||
| { slug: string }
|
||||
| undefined
|
||||
return row ? row.slug : null
|
||||
}
|
||||
|
||||
export function getSeriesBySlug(slug: string): Series | null {
|
||||
const d = getDb()
|
||||
const row = d
|
||||
|
||||
Reference in New Issue
Block a user