Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cli/src/lib/components/CLIPageWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@
// Create filter and inline query contexts
// Pass serialized filters so they're deserialized and available to components
// Pass SQL files so they can be referenced as data sources
const pageFilters = createPageFiltersContext(serializedFilters);
// Wire the filters to the browser URL (same pattern as the published/preview
// routes in Studio): an input reads its initial value from `?<id>=…` and
// writes user choices back, so drill-through links and shared URLs work in
// `evidence dev` / `evidence serve` too.
const pageFilters = createPageFiltersContext(serializedFilters, {
url: () =>
typeof window !== 'undefined' ? new URL(window.location.href) : new URL('http://localhost'),
updateUrl: (url) => window.history.replaceState(window.history.state, '', url.toString())
});
const inlineQueries = createInlineQueriesContext(
{ filterContexts: [pageFilters] },
serializedInlineQueries,
Expand Down
6 changes: 5 additions & 1 deletion cli/src/lib/markdown/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export interface ProcessOptions {
/** Resolved translations (translations.yaml) for the current language, exposed
* to markdown as the `$translations` variable. */
translations?: TranslationMap;
/** Request URL of the page being rendered. Inputs read their initial value
* from its search params (`?<filter id>=…`), so server-rendered output
* matches what the client restores from the URL. */
url?: URL;
}

export interface Processed {
Expand All @@ -84,7 +88,7 @@ export async function process(markdown: string, options: ProcessOptions = {}): P
const dialect = dialectFor(options.connectionType);

const filters = new Filters({
url: new URL('http://localhost'),
url: options.url ?? new URL('http://localhost'),
projectSettings: { first_day_of_week: 'sunday' },
updateUrl: undefined,
dialect
Expand Down
3 changes: 2 additions & 1 deletion cli/src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export const load: PageServerLoad = async ({ url, cookies, setHeaders, parent })
customComponents,
basePath,
useRelativeResolution,
translations
translations,
url
});
markdownData = {
serializedTree: serializeTree(tree),
Expand Down
3 changes: 2 additions & 1 deletion cli/src/routes/[...path]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export const load: PageServerLoad = async ({ params, url, cookies, setHeaders, p
customComponents,
basePath,
useRelativeResolution,
translations
translations,
url
});

return {
Expand Down