pull/679/head
Zef Hemel 2024-02-03 14:58:29 +01:00
parent 04abc283b0
commit 9bb72d01b2
1 changed files with 18 additions and 18 deletions

View File

@ -4,6 +4,7 @@ import { events } from "$sb/syscalls.ts";
import { QueryProviderEvent } from "$sb/app_event.ts";
import { resolvePath } from "$sb/lib/resolve.ts";
import { renderQueryTemplate } from "../template/util.ts";
import { parse } from "../../common/markdown_parser/parse_tree.ts";
export async function query(
query: string,
@ -25,10 +26,10 @@ export async function renderQuery(
variables?: Record<string, any>,
): Promise<any[] | string> {
const results = await queryParsed(parsedQuery, variables);
if (results.length === 0 && !parsedQuery.renderAll) {
return results;
} else {
if (parsedQuery.render) {
if (results.length === 0 && !parsedQuery.renderAll) {
return "No results";
}
// Configured a custom rendering template, let's use it!
const templatePage = resolvePath(
variables?.page?.name,
@ -45,7 +46,6 @@ export async function renderQuery(
return results;
}
}
export async function queryParsed(
parsedQuery: Query,