fix links

This commit is contained in:
2026-01-12 16:41:40 +00:00
parent 07da28634c
commit e756e160d7

View File

@@ -5,10 +5,17 @@ import axios from "axios";
const note = ref(null);
const fetchNote = async () => {
function fixContents(contents) {
// Obsidian notes have links in the form [[link|name]]
// contents so that they are rendered correctly
return contents.replace(/\[\[(.*?)\|(.*)\]\]/g, '<a href="/$1">$2</a>');
}
async function fetchNote() {
const response = await axios.get("/api/notes/Index");
response.data.contents = fixContents(response.data.contents);
note.value = response.data;
};
}
onMounted(fetchNote);
</script>