This commit is contained in:
Zef Hemel
2025-06-05 11:50:33 +02:00
parent b1b1363574
commit 839860ade8
2 changed files with 13 additions and 7 deletions
+7 -5
View File
@@ -1,8 +1,8 @@
import { type ParseTree, traverseTree } from "./tree.ts";
const builtinPrefixes = [
"/tag:",
"/search:",
"tag:",
"search:",
];
// [[Wikilinks]] use absolute paths and should pass pathToResolve with a leading / to this function
@@ -26,9 +26,7 @@ export function resolvePath(
}
function strippableSlashPrefix(p: string) {
return p.startsWith("/") &&
// Don't remove prefix / for built-in prefixes
!builtinPrefixes.some((prefix) => p.startsWith(prefix));
return p.startsWith("/");
}
export function isLocalPath(path: string): boolean {
@@ -97,3 +95,7 @@ export function relativeToAbsolutePath(page: string, linkTo: string): string {
return [...splitPage, ...splitLink].join("/");
}
export function isBuiltinPath(path: string): boolean {
return builtinPrefixes.some((prefix) => path.startsWith(prefix));
}
+6 -2
View File
@@ -3,7 +3,10 @@ import { syntaxTree } from "@codemirror/language";
import { Decoration } from "@codemirror/view";
import type { Client } from "../client.ts";
import { decoratorStateField, isCursorInRange, LinkWidget } from "./util.ts";
import { resolvePath } from "@silverbulletmd/silverbullet/lib/resolve";
import {
isBuiltinPath,
resolvePath,
} from "@silverbulletmd/silverbullet/lib/resolve";
import {
encodePageURI,
encodeRef,
@@ -45,7 +48,8 @@ export function cleanWikiLinkPlugin(client: Client) {
}
if (
pageRef.page === "" ||
client.plugSpaceRemotePrimitives.isLikelyHandled(pageRef.page)
client.plugSpaceRemotePrimitives.isLikelyHandled(pageRef.page) ||
isBuiltinPath(pageRef.page)
) {
// Empty page name with local @anchor use or a link to a page that dynamically generated by a plug
fileExists = true;