diff --git a/src/components/InlineMarkdown.svelte b/src/components/InlineMarkdown.svelte new file mode 100644 index 000000000..f9bcf2b2e --- /dev/null +++ b/src/components/InlineMarkdown.svelte @@ -0,0 +1,34 @@ + + + + + + {@html render(content)} + diff --git a/src/components/Markdown.svelte b/src/components/Markdown.svelte index 35bfb0692..37979c037 100644 --- a/src/components/Markdown.svelte +++ b/src/components/Markdown.svelte @@ -17,7 +17,7 @@ export let content: string; export let hash: string | null = null; export let path: string = "/"; - export let rawPath: string; + export let rawPath: string | undefined = undefined; $: doc = matter(content); $: frontMatter = Object.entries(doc.data).filter( @@ -57,16 +57,18 @@ // Iterate over all images, and replace the source with a canonicalized URL // pointing at the projects /raw endpoint. - for (const i of container.querySelectorAll("img")) { - const imagePath = i.getAttribute("src"); + if (rawPath) { + for (const i of container.querySelectorAll("img")) { + const imagePath = i.getAttribute("src"); - // Make sure the source isn't a URL before trying to fetch it from the repo - if ( - imagePath && - !isUrl(imagePath) && - !imagePath.startsWith(`${base}twemoji`) - ) { - i.setAttribute("src", `${rawPath}/${canonicalize(imagePath, path)}`); + // Make sure the source isn't a URL before trying to fetch it from the repo + if ( + imagePath && + !isUrl(imagePath) && + !imagePath.startsWith(`${base}twemoji`) + ) { + i.setAttribute("src", `${rawPath}/${canonicalize(imagePath, path)}`); + } } } diff --git a/src/views/projects/Cob/CobHeader.svelte b/src/views/projects/Cob/CobHeader.svelte index 8950bc0ec..d9bca5621 100644 --- a/src/views/projects/Cob/CobHeader.svelte +++ b/src/views/projects/Cob/CobHeader.svelte @@ -5,6 +5,7 @@ import Button from "@app/components/Button.svelte"; import Clipboard from "@app/components/Clipboard.svelte"; + import InlineMarkdown from "@app/components/InlineMarkdown.svelte"; import TextInput from "@app/components/TextInput.svelte"; export let action: "create" | "edit" | "view" = "view"; @@ -67,7 +68,9 @@ {:else} {#if title} - {title} +
+ +
{:else} No title {/if} diff --git a/src/views/projects/Commit.svelte b/src/views/projects/Commit.svelte index b6d4b89c6..e9e3c5281 100644 --- a/src/views/projects/Commit.svelte +++ b/src/views/projects/Commit.svelte @@ -1,23 +1,16 @@