Open dsebastien opened 3 months ago
Download image:
export async function downloadImage(url: string): Promise<ArrayBuffer> {
const res = await got(url, { responseType: "buffer" });
return res.body;
}
Clean file name:
export const FORBIDDEN_SYMBOLS_FILENAME_PATTERN = /\s+/g;
export function cleanFileName(name: string) {
const cleanedName = filenamify(name).replace(
FORBIDDEN_SYMBOLS_FILENAME_PATTERN,
"_"
);
return cleanedName;
}
Create image tag:
function createImageTag(anchor: string, link: string) {
return `![${anchor}](${link})`;
}
Reference: https://github.com/aleksey-rezvov/obsidian-local-images/tree/master/src
Goal: directly save the generated images locally