forked from sqlpage/SQLPage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog.sql
25 lines (22 loc) · 824 Bytes
/
blog.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
select 'redirect' as component, '/blog.sql' as link
where ($post IS NULL AND sqlpage.path() <> '/blog.sql') OR ($post IS NOT NULL AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE title = $post));
select 'dynamic' as component, json_patch(json_extract(properties, '$[0]'), json_object(
'title', coalesce($post || ' - ', '') || 'SQLPage Blog'
)) as properties
FROM example WHERE component = 'shell' LIMIT 1;
SELECT 'text' AS component,
true as article,
content AS contents_md
FROM blog_posts
WHERE title = $post;
SELECT 'list' AS component,
'SQLPage blog' AS title;
SELECT title,
description,
icon,
sqlpage.link(
COALESCE(external_url, ''),
CASE WHEN external_url IS NULL THEN json_object('post', title) ELSE NULL END
) AS link
FROM blog_posts
ORDER BY created_at DESC;