Skip to content

Commit

Permalink
fix: markdown broken links
Browse files Browse the repository at this point in the history
  • Loading branch information
axel7083 committed Jan 16, 2024
1 parent f0d65fe commit 1d15112
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
9 changes: 0 additions & 9 deletions packages/frontend/src/lib/MarkdownRenderer.svelte

This file was deleted.

13 changes: 13 additions & 0 deletions packages/frontend/src/lib/markdown/LinkComponent.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script lang="ts">
import { studioClient } from '/@/utils/client.js';
export let href: string = "";
export let title: string | undefined = undefined;
export let text: string = "";
const onClick = () => {
studioClient.openURL(href);
}
</script>
<!-- href set to void operator to avoid any redirect -->
<a href="{'javascript:void(0);'}" role="button" title="{title}" on:click={onClick}>{text}</a>
10 changes: 10 additions & 0 deletions packages/frontend/src/lib/markdown/MarkdownRenderer.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script lang="ts">
import SvelteMarkdown from 'svelte-markdown'
import LinkComponent from '/@/lib/markdown/LinkComponent.svelte';
export let source: string | undefined;
</script>

<article class="prose min-w-full">
<SvelteMarkdown {source} renderers="{{link: LinkComponent}}" />
</article>

2 changes: 1 addition & 1 deletion packages/frontend/src/pages/Model.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import NavPage from '/@/lib/NavPage.svelte';
import Tab from '/@/lib/Tab.svelte';
import Route from '/@/Route.svelte';
import MarkdownRenderer from '/@/lib/MarkdownRenderer.svelte';
import MarkdownRenderer from '/@/lib/markdown/MarkdownRenderer.svelte';
import type { ModelInfo } from '@shared/models/IModelInfo';
import { studioClient } from '../utils/client';
import { onMount } from 'svelte';
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/Recipe.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Tab from '/@/lib/Tab.svelte';
import Route from '/@/Route.svelte';
import type { Category } from '@shared/models/ICategory';
import Card from '/@/lib/Card.svelte';
import MarkdownRenderer from '/@/lib/MarkdownRenderer.svelte';
import MarkdownRenderer from '/@/lib/markdown/MarkdownRenderer.svelte';
import Fa from 'svelte-fa';
import { faGithub } from '@fortawesome/free-brands-svg-icons';
import { faDownload, faRefresh } from '@fortawesome/free-solid-svg-icons';
Expand Down

0 comments on commit 1d15112

Please sign in to comment.