Ignore tags in first paragraph of page for paragraph indexing
This commit is contained in:
parent
9b6214e7e1
commit
99fe8e8c68
@ -22,11 +22,13 @@ export type ParagraphObject = ObjectValue<
|
|||||||
export async function indexParagraphs({ name: page, tree }: IndexTreeEvent) {
|
export async function indexParagraphs({ name: page, tree }: IndexTreeEvent) {
|
||||||
const objects: ParagraphObject[] = [];
|
const objects: ParagraphObject[] = [];
|
||||||
addParentPointers(tree);
|
addParentPointers(tree);
|
||||||
|
let paragraphCounter = 0;
|
||||||
|
|
||||||
await traverseTreeAsync(tree, async (p) => {
|
await traverseTreeAsync(tree, async (p) => {
|
||||||
if (p.type !== "Paragraph") {
|
if (p.type !== "Paragraph") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
paragraphCounter++;
|
||||||
|
|
||||||
if (findParentMatching(p, (n) => n.type === "ListItem")) {
|
if (findParentMatching(p, (n) => n.type === "ListItem")) {
|
||||||
// Not looking at paragraphs nested in a list
|
// Not looking at paragraphs nested in a list
|
||||||
@ -35,10 +37,14 @@ export async function indexParagraphs({ name: page, tree }: IndexTreeEvent) {
|
|||||||
|
|
||||||
// So we're looking at indexable a paragraph now
|
// So we're looking at indexable a paragraph now
|
||||||
const tags = new Set<string>(["paragraph"]);
|
const tags = new Set<string>(["paragraph"]);
|
||||||
// tag the paragraph with any hashtags inside it
|
if (paragraphCounter > 1) {
|
||||||
collectNodesOfType(p, "Hashtag").forEach((tagNode) => {
|
// Only attach hashtags to later paragraphs than the first
|
||||||
tags.add(tagNode.children![0].text!.substring(1));
|
|
||||||
});
|
// tag the paragraph with any hashtags inside it
|
||||||
|
collectNodesOfType(p, "Hashtag").forEach((tagNode) => {
|
||||||
|
tags.add(tagNode.children![0].text!.substring(1));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const attrs = await extractAttributes(p, false);
|
const attrs = await extractAttributes(p, false);
|
||||||
const pos = p.from!;
|
const pos = p.from!;
|
||||||
|
@ -72,10 +72,10 @@ rating: 5
|
|||||||
|
|
||||||
But where things get _really_ interesting is when using features like [[Live Queries]] that allow you to query all types of [[Objects]] indexed based on the pages in your space.
|
But where things get _really_ interesting is when using features like [[Live Queries]] that allow you to query all types of [[Objects]] indexed based on the pages in your space.
|
||||||
|
|
||||||
Let’s explore this with a meta example of using this for this very website. All pages in this space that represent a plug are tagged with the #plug tag. Now, if we would want to render a list of all plugs in one place using the [[template/plug]] template, we can simply do this:
|
Let’s explore this with a meta example of using this for this very website. All pages in this space that represent a plug are tagged with the `#plug` tag. Now, if we would want to render a list of all plugs in one place using the [[template/plug]] template, we can simply do this:
|
||||||
|
|
||||||
```query
|
```query
|
||||||
plug where tags = "page" render [[template/plug]]
|
plug render [[template/plug]]
|
||||||
```
|
```
|
||||||
Hover over that list, click the edit button to see the query that generates this view.
|
Hover over that list, click the edit button to see the query that generates this view.
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
> **Warning** Deprecated
|
> **Warning** Deprecated
|
||||||
> Directives are now deprecated and will likely soon be removed, use [[Live Templates]] and [[Live Queries]] instead.
|
> Directives are now deprecated and will likely soon be removed, use [[Live Templates]] and [[Live Queries]] instead.
|
||||||
|
|
||||||
|
|
||||||
The directive plug is a built-in plug implementing various so-called “directive” that all take the form of `<!-- #directiveName ... -->` and close with `<!-- /directiveName -->`. Currently the following directives are supported:
|
The directive plug is a built-in plug implementing various so-called “directive” that all take the form of `<!-- #directiveName ... -->` and close with `<!-- /directiveName -->`. Currently the following directives are supported:
|
||||||
|
|
||||||
* `#query` to perform queries: [[Live Queries]]
|
* `#query` to perform queries: [[Live Queries]]
|
||||||
|
@ -17,12 +17,12 @@ Plugs are distributed as self-contained JavaScript bundles (ending with `.plug.j
|
|||||||
## Core plugs
|
## Core plugs
|
||||||
These plugs are distributed with SilverBullet and are automatically enabled:
|
These plugs are distributed with SilverBullet and are automatically enabled:
|
||||||
```query
|
```query
|
||||||
plug where tags = "page" and uri = null order by name render [[template/plug]]
|
plug where uri = null order by name render [[template/plug]]
|
||||||
```
|
```
|
||||||
## Third-party plugs
|
## Third-party plugs
|
||||||
These plugs are written either by third parties or distributed separately from the main SB distribution:
|
These plugs are written either by third parties or distributed separately from the main SB distribution:
|
||||||
```query
|
```query
|
||||||
plug where tags = "page" and uri != null order by name render [[template/plug]]
|
plug where uri != null order by name render [[template/plug]]
|
||||||
```
|
```
|
||||||
|
|
||||||
## How to develop your own plug
|
## How to develop your own plug
|
||||||
|
Loading…
Reference in New Issue
Block a user