Revert "Handle absolute markdown links with leading slash"

This reverts commit 2efd0ad58e.

There's a bug with root-level links in markdown docs.
This commit is contained in:
Rūdolfs Ošiņš
2024-03-29 16:48:28 +01:00
parent 2efd0ad58e
commit 127efc49a5
9 changed files with 55 additions and 67 deletions
+1 -4
View File
@@ -3,7 +3,6 @@
import markdown from "@app/lib/markdown";
import { twemoji } from "@app/lib/utils";
import { activeUnloadedRouteStore } from "@app/lib/router";
import { Renderer } from "@app/lib/markdown";
export let content: string;
@@ -14,9 +13,7 @@
const render = (content: string): string =>
dompurify.sanitize(
markdown.parseInline(content, {
renderer: new Renderer($activeUnloadedRouteStore, {
stripEmphasizedStyling,
}),
renderer: new Renderer(undefined, stripEmphasizedStyling),
}) as string,
);
</script>
+4 -5
View File
@@ -11,7 +11,6 @@
import ErrorModal from "@app/modals/ErrorModal.svelte";
import markdown from "@app/lib/markdown";
import { Renderer } from "@app/lib/markdown";
import { activeUnloadedRouteStore } from "@app/lib/router";
import { highlight } from "@app/lib/syntax";
import {
isUrl,
@@ -23,6 +22,8 @@
import { mimes } from "@app/lib/file";
export let content: string;
// If present, resolve all relative links with respect to this URL
export let linkBaseUrl: string | undefined = undefined;
export let path: string = "/";
export let rawPath: string;
// If present, means we are in a preview context,
@@ -62,7 +63,7 @@
}
/**
* Do internal navigation for clicks on anchor elements if possible
* Do internal navigation on for clicks on anchor elements if possible
*/
function navigateInternalOnAnchor(event: MouseEvent) {
if (router.useDefaultNavigation(event)) {
@@ -93,9 +94,7 @@
function render(content: string): string {
return dompurify.sanitize(
markdown.parse(content, {
renderer: new Renderer($activeUnloadedRouteStore, {
stripEmphasizedStyling: false,
}),
renderer: new Renderer(linkBaseUrl, false),
breaks,
}) as string,
);