Expose file and page meta data directly
This commit is contained in:
+1
-14
@@ -60,20 +60,7 @@ export async function indexLinks({ name, tree }: IndexTreeEvent) {
|
||||
export async function pageQueryProvider({
|
||||
query,
|
||||
}: QueryProviderEvent): Promise<any[]> {
|
||||
let allPages = await space.listPages();
|
||||
const allPageMap: Map<string, any> = new Map(
|
||||
allPages.map((pm) => [pm.name, pm]),
|
||||
);
|
||||
for (const { page, value } of await index.queryPrefix("meta:")) {
|
||||
const p = allPageMap.get(page);
|
||||
if (p) {
|
||||
for (const [k, v] of Object.entries(value)) {
|
||||
p[k] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
allPages = [...allPageMap.values()];
|
||||
return applyQuery(query, allPages);
|
||||
return applyQuery(query, await space.listPages());
|
||||
}
|
||||
|
||||
export async function linkQueryProvider({
|
||||
|
||||
@@ -5,10 +5,18 @@ import { space } from "$sb/silverbullet-syscall/mod.ts";
|
||||
import { niceDate } from "$sb/lib/dates.ts";
|
||||
|
||||
const maxWidth = 70;
|
||||
|
||||
export function defaultJsonTransformer(_k: string, v: any) {
|
||||
if (v === undefined) {
|
||||
return "";
|
||||
}
|
||||
return "" + v;
|
||||
}
|
||||
|
||||
// Nicely format an array of JSON objects as a Markdown table
|
||||
export function jsonToMDTable(
|
||||
jsonArray: any[],
|
||||
valueTransformer: (k: string, v: any) => string = (_k, v) => "" + v,
|
||||
valueTransformer: (k: string, v: any) => string = defaultJsonTransformer,
|
||||
): string {
|
||||
const fieldWidths = new Map<string, number>();
|
||||
for (const entry of jsonArray) {
|
||||
|
||||
Reference in New Issue
Block a user