1
0

Include tags in frontmatter in autocomplete

This commit is contained in:
Zef Hemel 2023-03-13 09:59:58 +01:00
parent a333803876
commit ea293be159
2 changed files with 12 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import type {
QueryProviderEvent, QueryProviderEvent,
} from "$sb/app_event.ts"; } from "$sb/app_event.ts";
import { applyQuery, removeQueries } from "$sb/lib/query.ts"; import { applyQuery, removeQueries } from "$sb/lib/query.ts";
import { extractFrontmatter } from "../../plug-api/lib/frontmatter.ts";
// Key space // Key space
// tag:TAG => true (for completion) // tag:TAG => true (for completion)
@ -13,6 +14,10 @@ import { applyQuery, removeQueries } from "$sb/lib/query.ts";
export async function indexTags({ name, tree }: IndexTreeEvent) { export async function indexTags({ name, tree }: IndexTreeEvent) {
removeQueries(tree); removeQueries(tree);
const allTags = new Set<string>(); const allTags = new Set<string>();
const { tags } = extractFrontmatter(tree);
if (Array.isArray(tags)) {
tags.forEach((t) => allTags.add(t));
}
collectNodesOfType(tree, "Hashtag").forEach((n) => { collectNodesOfType(tree, "Hashtag").forEach((n) => {
allTags.add(n.children![0].text!.substring(1)); allTags.add(n.children![0].text!.substring(1));
}); });

View File

@ -3,6 +3,13 @@ release.
--- ---
## Next
* Tags included in `tags` [[Frontmatter]] now included in hash tag auto complete
* Regression fix: when instantiating a page from a template it would always claim the page already existed (even if it didn't)
---
## 0.2.12 ## 0.2.12
* Added support to override CSS styles on a per-space basis. This replaces the previous `fontFamily` setting. See [[STYLES]] for hints on how to use this new experimental feature. * Added support to override CSS styles on a per-space basis. This replaces the previous `fontFamily` setting. See [[STYLES]] for hints on how to use this new experimental feature.