Include press and extra photos in the Atom feed
simonw opened this issue · comments
After a huge amount of experimentation, this query seems to do the trick:
SELECT
'tag:niche-museums.com,' || substr(m.created, 0, 11) || ':' || m.id as atom_id,
m.name as atom_title,
m.created as atom_updated,
'https://www.niche-museums.com/browse/museums/' || m.id as atom_link,
coalesce(
'<img src="' || m.photo_url || '?w=800&h=400&fit=crop&auto=compress">',
''
) || render_markdown(
m.description || '
' || coalesce(
(
select
group_concat(
'* [' || json_extract(p.value, '$.title') || '](' || json_extract(p.value, '$.url') || ') ' || json_extract(p.value, '$.author') || ', ' || json_extract(p.value, '$.publication') || ', ' || json_extract(p.value, '$.date'),
'
'
)
from
json_each(coalesce(m.press, '[{}]')) as p
),
''
)
) || coalesce(
(
select
group_concat(
'<p><img src="' || json_extract(ph.value, '$.url') || '?w=400&auto=compress"></p>',
''
)
from
json_each(coalesce(m.photos, '[{}]')) as ph
),
''
) as atom_content_html
FROM
museums m
order by
m.created desc
limit
15