Skip to main content
Builds a URL from a file path and query parameters.

Signature

sqlpage.link(file TEXT, parameters JSON DEFAULT NULL, fragment TEXT DEFAULT NULL) -> TEXT

Parameters

file
TEXT
required
Path to the SQLPage file
parameters
JSON
Optional JSON object with URL parameters
fragment
TEXT
Optional hash/fragment for the URL

Return Value

return
TEXT
Properly encoded URL

Description

The link() function builds URLs with properly encoded parameters, preventing injection and encoding issues.

Examples

SELECT 'list' as component;
SELECT 
    name as title,
    sqlpage.link('product.sql', json_object('id', id)) as link
FROM products;
SET link = sqlpage.link(
    'search.sql',
    json_object('q', 'laptop', 'category', 'electronics', 'sort', 'price')
);
-- Result: search.sql?q=laptop&category=electronics&sort=price
SET link = sqlpage.link(
    'docs.sql',
    json_object('page', 'intro'),
    'section-3'
);
-- Result: docs.sql?page=intro#section-3

Build docs developers (and LLMs) love