aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/main.ts')
-rw-r--r--frontend/src/main.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 4868365..302fce0 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -1,7 +1,9 @@
import { marked } from 'marked';
import './style.css'
-function renderTextWithFacets(text: string, facets: any[]): string {
+// Since we parse Markdown after Facets, convert Facets to Markdown and let the Markdown parser create the proper HTML code
+// Avoiding partial HTML code possibly interferring with Markdown parsing this way
+function convertFacetsToMarkdown(text: string, facets: any[]): string {
if (!facets || facets.length === 0) {
return text;
}
@@ -28,13 +30,13 @@ function renderTextWithFacets(text: string, facets: any[]): string {
switch (facet.type) {
case 'link':
- result += `<a href="${facet.value}" target="_blank">${facetText}</a>`;
+ result += `[${facetText}](${facet.value})`;
break;
case 'mention':
- result += `<a href="https://bsky.app/profile/${facet.value}" target="_blank">${facetText}</a>`;
+ result += `[@${facetText}](https://bsky.app/profile/${facet.value})`;
break;
case 'tag':
- result += `<a href="https://bsky.app/hashtag/${facet.value}" target="_blank">#${facetText}</a>`;
+ result += `[#${facetText}](https://bsky.app/hashtag/${facet.value})`;
break;
default: // in case Bluesky ever adds other facet types
result += facetText; // if we don't recognize the type, just add it as plain text
@@ -96,7 +98,7 @@ async function main() {
for (const note of notes) {
let parsedText = '';
if(note.facets && note.facets.length > 0) {
- parsedText = renderTextWithFacets(note.text || '', note.facets || []);
+ parsedText = convertFacetsToMarkdown(note.text || '', note.facets || []);
} else {
parsedText = note.text;
}