From 3f87d09ba024425e9882ac38b60fd5e866bb52e1 Mon Sep 17 00:00:00 2001 From: Ophir Lojkine Date: Sat, 28 Nov 2026 23:48:14 +0000 Subject: [PATCH] Find settings by file or environment name in documentation search --- examples/official-site/search.sql | 8 +++++++- examples/official-site/test.hurl | 20 ++++++++++++++++++++ scripts/site/search.sql | 3 +++ tests/site/prepared-seed.test.mjs | 4 ++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/examples/official-site/search.sql b/examples/official-site/search.sql index eede7173a..b7563da0d 100644 --- a/examples/official-site/search.sql +++ b/examples/official-site/search.sql @@ -7,6 +7,9 @@ where name = lower($search) or (kind = 'function' and lower($search) in ( )) order by kind limit 1; +select 'redirect' as component, '/configuration#' || name as link +from config_option where lower($search) in (name, 'sqlpage_' || name); + select 'shell-docs' as component, 'Search' as section, coalesce($search || ' | ', '') || 'SQLPage documentation search' as title; @@ -17,7 +20,10 @@ set escaped_search = '"' || replace(coalesce($search, ''), '"', '""') || '"'; with matches as ( select title, trim(description, char(13) || char(10) || ' ') as summary, page, parameters, fragment, rank, - row_number() over (partition by page, parameters order by rank, rowid) as position + row_number() over ( + partition by page, parameters, case when page = '/configuration' then fragment end + order by rank, rowid + ) as position from documentation_fts where documentation_fts match $escaped_search ) diff --git a/examples/official-site/test.hurl b/examples/official-site/test.hurl index b130d8ed7..4662ad0f6 100644 --- a/examples/official-site/test.hurl +++ b/examples/official-site/test.hurl @@ -27,6 +27,26 @@ xpath "normalize-space(//*[@id='listen_on']/dd)" contains "443" xpath "//*[@id='database_connection_idle_timeout_seconds']" count == 1 body not contains "An error occurred" +GET http://localhost:8080/search.sql?search=LISTEN_ON +HTTP 302 +[Asserts] +header "Location" == "/configuration#listen_on" + +GET http://localhost:8080/search.sql?search=web_root +HTTP 302 +[Asserts] +header "Location" == "/functions.sql?function=web_root" + +GET http://localhost:8080/search.sql?search=SQLPAGE_WEB_ROOT +HTTP 302 +[Asserts] +header "Location" == "/configuration#web_root" + +GET http://localhost:8080/search.sql?search=SMTP +HTTP 200 +[Asserts] +xpath "//main//a[starts-with(@href, '/configuration#smtp_')]" count > 1 + GET http://localhost:8080/components.sql HTTP 200 [Asserts] diff --git a/scripts/site/search.sql b/scripts/site/search.sql index ee0ba09e8..23d6db026 100644 --- a/scripts/site/search.sql +++ b/scripts/site/search.sql @@ -23,3 +23,6 @@ JOIN reference_entry AS e ON e.kind = 'component' AND e.name = x.component; INSERT INTO documentation_fts(title, description, page, parameters) SELECT title, description, '/blog.sql', json_object('post', title) FROM blog_posts; + +INSERT INTO documentation_fts(title, description, page, fragment) +SELECT name, description_md, '/configuration', name FROM config_option; diff --git a/tests/site/prepared-seed.test.mjs b/tests/site/prepared-seed.test.mjs index 9083b2bbb..1810a7636 100644 --- a/tests/site/prepared-seed.test.mjs +++ b/tests/site/prepared-seed.test.mjs @@ -29,6 +29,10 @@ test("the published seed is reproducible and replays with searchable reference l search.get("embed", "table component: embed").link, "/component.sql?component=table#top-level-parameters-embed", ); + assert.equal( + search.get("listen_on", "listen_on").link, + "/configuration#listen_on", + ); const { source } = db .prepare( "SELECT source FROM example_with_source WHERE component = 'table' AND example_number = 4",