feat(*): refactor metadata handling; move metadata to backend where possible, refine client views

This commit is contained in:
Cory Dransfeldt 2025-05-25 20:15:45 -07:00
parent 929bc9f9f8
commit 9687509e4a
No known key found for this signature in database
35 changed files with 506 additions and 339 deletions

View file

@ -173,12 +173,25 @@ SELECT
END AS feed,
(SELECT TO_CHAR(days_read, 'FM999G999G999') FROM reading_streak LIMIT 1) AS days_read,
json_build_object(
'title', CONCAT('Book • ', b.title, ' by ', b.author, '', globals.site_name),
'description', LEFT(
regexp_replace(
regexp_replace(
regexp_replace( b.description, E'[*_`~#>-]', '', 'g'),
E'\\[(.*?)\\]\\((.*?)\\)', E'\\1', 'g'
),
E'!\\[(.*?)\\]\\((.*?)\\)', '', 'g'
),
250
),
'open_graph_image', CASE
WHEN df.filename_disk IS NOT NULL AND df.filename_disk != '' AND df.filename_disk != '/' THEN CONCAT('/', df.filename_disk)
ELSE NULL
END
END,
'url', CONCAT(globals.url, b.slug),
'type', 'book'
) AS metadata
FROM books b
LEFT JOIN directus_files df ON b.art = df.id
CROSS JOIN optimized_globals globals
GROUP BY b.id, df.filename_disk, globals.cdn_url;
GROUP BY b.id, df.filename_disk, globals.cdn_url, globals.site_name, globals.url;