SET apply = TRUE;
SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/internal/cookie.sql') AS properties;
SELECT 'redirect' AS component
, (
  SELECT CASE
    WHEN $title IN (SELECT name FROM sqlpage_pages)
    THEN '/grocery/'||lower($title)||'.sql'
    ELSE '/grocery/internal/404.sql'
  END
) AS link
;