parent
fdd3d1b650
commit
1508f6bcbf
|
@ -15,6 +15,7 @@ import { Fragment, renderHtml, type Tag } from "./html_render.ts";
|
||||||
import { isLocalPath } from "@silverbulletmd/silverbullet/lib/resolve";
|
import { isLocalPath } from "@silverbulletmd/silverbullet/lib/resolve";
|
||||||
import type { PageMeta } from "@silverbulletmd/silverbullet/types";
|
import type { PageMeta } from "@silverbulletmd/silverbullet/types";
|
||||||
import * as TagConstants from "../../plugs/index/constants.ts";
|
import * as TagConstants from "../../plugs/index/constants.ts";
|
||||||
|
import { extractHashtag } from "@silverbulletmd/silverbullet/lib/tags";
|
||||||
|
|
||||||
export type MarkdownRenderOptions = {
|
export type MarkdownRenderOptions = {
|
||||||
failOnUnknown?: true;
|
failOnUnknown?: true;
|
||||||
|
@ -342,8 +343,8 @@ function render(
|
||||||
name: "a",
|
name: "a",
|
||||||
attrs: {
|
attrs: {
|
||||||
class: "hashtag sb-hashtag",
|
class: "hashtag sb-hashtag",
|
||||||
"data-tag-name": tagText.replace("#", ""),
|
"data-tag-name": extractHashtag(tagText),
|
||||||
href: `/${TagConstants.tagPrefix}${tagText.replace("#", "")}`,
|
href: `/${TagConstants.tagPrefix}${extractHashtag(tagText)}`,
|
||||||
},
|
},
|
||||||
body: tagText,
|
body: tagText,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { parsePageRef } from "@silverbulletmd/silverbullet/lib/page_ref";
|
import { parsePageRef } from "@silverbulletmd/silverbullet/lib/page_ref";
|
||||||
import type { Client } from "../client.ts";
|
import type { Client } from "../client.ts";
|
||||||
import { tagPrefix } from "../../plugs/index/constants.ts";
|
import { tagPrefix } from "../../plugs/index/constants.ts";
|
||||||
|
import { extractHashtag } from "@silverbulletmd/silverbullet/lib/tags";
|
||||||
|
|
||||||
export function attachWidgetEventHandlers(
|
export function attachWidgetEventHandlers(
|
||||||
div: HTMLElement,
|
div: HTMLElement,
|
||||||
|
@ -45,7 +46,7 @@ export function attachWidgetEventHandlers(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.navigate({
|
client.navigate({
|
||||||
page: `${tagPrefix}${el.innerText.slice(1)}`,
|
page: `${tagPrefix}${extractHashtag(el.innerText)}`,
|
||||||
pos: 0,
|
pos: 0,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,8 +4,9 @@ import type {
|
||||||
CompletionContext,
|
CompletionContext,
|
||||||
CompletionResult,
|
CompletionResult,
|
||||||
} from "@codemirror/autocomplete";
|
} from "@codemirror/autocomplete";
|
||||||
import type { PageMeta } from "../../plug-api/types.ts";
|
import type { PageMeta } from "@silverbulletmd/silverbullet/types";
|
||||||
import { tagRegex as mdTagRegex } from "$common/markdown_parser/constants.ts";
|
import { tagRegex as mdTagRegex } from "$common/markdown_parser/constants.ts";
|
||||||
|
import { extractHashtag } from "@silverbulletmd/silverbullet/lib/tags";
|
||||||
|
|
||||||
const tagRegex = new RegExp(mdTagRegex.source, "g");
|
const tagRegex = new RegExp(mdTagRegex.source, "g");
|
||||||
|
|
||||||
|
@ -151,7 +152,7 @@ export function PageNavigator({
|
||||||
const allTags = phrase.match(tagRegex);
|
const allTags = phrase.match(tagRegex);
|
||||||
if (allTags) {
|
if (allTags) {
|
||||||
// Search phrase contains hash tags, let's pre-filter the results based on this
|
// Search phrase contains hash tags, let's pre-filter the results based on this
|
||||||
const filterTags = allTags.map((t) => t.slice(1));
|
const filterTags = allTags.map((t) => extractHashtag(t));
|
||||||
options = options.filter((pageMeta) => {
|
options = options.filter((pageMeta) => {
|
||||||
if (!pageMeta.tags) {
|
if (!pageMeta.tags) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue