feat(export/single): mermaid with right extension and MIME

This commit is contained in:
Elian Doran 2025-03-22 15:22:55 +02:00
parent 6ab820f172
commit 16cbd2f793
No known key found for this signature in database
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import { describe, expect, it } from "vitest";
import BNote from "../../becca/entities/bnote.js";
import { mapByNoteType } from "./single.js";
describe("Note type mappings", () => {
it("supports mermaid note", () => {
const note = new BNote({
type: "mermaid",
title: "New note"
});
expect(mapByNoteType(note, "", "html")).toMatchObject({
extension: "mermaid",
mime: "text/vnd.mermaid"
});
});
});

View File

@ -65,6 +65,10 @@ export function mapByNoteType(note: BNote, content: string | Buffer<ArrayBufferL
payload = content;
extension = "excalidraw";
mime = "application/json";
} else if (note.type === "mermaid") {
payload = content;
extension = "mermaid";
mime = "text/vnd.mermaid";
} else if (note.type === "relationMap" || note.type === "search") {
payload = content;
extension = "json";