Indexing fixes
This commit is contained in:
parent
f7b664aad3
commit
13903a3e30
@ -176,6 +176,6 @@ export async function objectSourceProvider({
|
||||
|
||||
export async function discoverSources() {
|
||||
return (await datastore.query({ prefix: [indexKey, "tag"] })).map((
|
||||
{ key },
|
||||
) => key[2]);
|
||||
{ value },
|
||||
) => value.name);
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ export async function indexItems({ name, tree }: IndexTreeEvent) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const tags = new Set<string>(["item"]);
|
||||
|
||||
const item: ItemObject = {
|
||||
ref: `${name}@${n.from}`,
|
||||
tags: [],
|
||||
@ -44,7 +46,7 @@ export async function indexItems({ name, tree }: IndexTreeEvent) {
|
||||
|
||||
collectNodesOfType(n, "Hashtag").forEach((h) => {
|
||||
// Push tag to the list, removing the initial #
|
||||
item.tags.push(h.children![0].text!.substring(1));
|
||||
tags.add(h.children![0].text!.substring(1));
|
||||
});
|
||||
|
||||
for (const child of n.children!.slice(1)) {
|
||||
@ -62,11 +64,9 @@ export async function indexItems({ name, tree }: IndexTreeEvent) {
|
||||
}
|
||||
|
||||
item.name = textNodes.map(renderToText).join("").trim();
|
||||
item.tags = [...tags.values()];
|
||||
|
||||
if (item.tags.length > 0) {
|
||||
// Only index items with tags
|
||||
items.push(item);
|
||||
}
|
||||
items.push(item);
|
||||
}
|
||||
// console.log("Found", items, "item(s)");
|
||||
await indexObjects(name, items);
|
||||
|
@ -8,15 +8,16 @@ import {
|
||||
traverseTreeAsync,
|
||||
} from "$sb/lib/tree.ts";
|
||||
import { extractAttributes } from "$sb/lib/attribute.ts";
|
||||
import { ObjectValue } from "$sb/types.ts";
|
||||
|
||||
/** ParagraphObject An index object for the top level text nodes */
|
||||
export type ParagraphObject = {
|
||||
ref: string;
|
||||
tags: string[];
|
||||
text: string;
|
||||
page: string;
|
||||
pos: number;
|
||||
} & Record<string, any>;
|
||||
export type ParagraphObject = ObjectValue<
|
||||
{
|
||||
text: string;
|
||||
page: string;
|
||||
pos: number;
|
||||
} & Record<string, any>
|
||||
>;
|
||||
|
||||
export async function indexParagraphs({ name: page, tree }: IndexTreeEvent) {
|
||||
const objects: ParagraphObject[] = [];
|
||||
|
@ -43,7 +43,7 @@ export async function indexTags({ name, tree }: IndexTreeEvent) {
|
||||
[...tags].map((tag) => {
|
||||
const [tagName, parent] = tag.split(":");
|
||||
return {
|
||||
ref: tagName,
|
||||
ref: tag,
|
||||
tags: ["tag"],
|
||||
name: tagName,
|
||||
page: name,
|
||||
|
Loading…
Reference in New Issue
Block a user