mirror of
https://github.com/meld-cp/obsidian-build.git
synced 2026-07-22 07:30:25 +00:00
add jpeg to mimetypes, move mimetypes to constants, update docs
This commit is contained in:
parent
2731c96c83
commit
f812dcef2a
3 changed files with 17 additions and 9 deletions
|
|
@ -97,7 +97,7 @@ Read and write vault files.
|
|||
- `const dataurl = await $.io.load_data_url( path, mimetype? )`
|
||||
- Encode the contents of a file into a dataurl for use in a template
|
||||
- Optionaly specify the mime type.
|
||||
- Auto mime type mappings are available for the following file extensions: `.jpg`, `.png`, `.gif`, `.svg`, `.css`
|
||||
- Auto mime type mappings are available for the following common file extensions: `.jpeg`, `.jpg`, `.png`, `.gif`, `.svg`, `.css`
|
||||
- `await $.io.output( file, content, open? )`
|
||||
- (Over)Writes the `file` with given `content`
|
||||
- Tries to open the `file` if `open` is true (false by default)
|
||||
|
|
|
|||
|
|
@ -1,2 +1,12 @@
|
|||
export const CODE_BLOCK_LANG_TOOLBAR = 'meld-build-toolbar';
|
||||
export const URL_HELP = 'https://github.com/meld-cp/obsidian-build/blob/master/docs/user-guide.md';
|
||||
|
||||
export const URL_HELP = 'https://github.com/meld-cp/obsidian-build/blob/master/docs/user-guide.md';
|
||||
|
||||
export const EXTENSION_MIMETYPE_MAP = new Map<string,string>([
|
||||
['jpeg', 'image/jpeg'],
|
||||
['jpg', 'image/jpeg'],
|
||||
['png', 'image/png'],
|
||||
['gif', 'image/gif'],
|
||||
['svg', 'image/svg+xml'],
|
||||
['css', 'text/css'],
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { normalizePath, TFile } from "obsidian";
|
||||
import { EXTENSION_MIMETYPE_MAP } from "./constants";
|
||||
import { DataSet, IDataSetCollection } from "./data-set";
|
||||
import { NamedCodeBlock } from "./named-code-block";
|
||||
import { Parser } from "./parser";
|
||||
|
|
@ -103,13 +104,10 @@ export class IoRunContextImplemention implements TIoRunContext {
|
|||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
const finalMimeType = mimetype ?? {
|
||||
'jpg':'image/jpeg',
|
||||
'png':'image/png',
|
||||
'gif':'image/gif',
|
||||
'svg':'image/svg+xml',
|
||||
'css':'text/css'
|
||||
}[af.extension] ?? '';
|
||||
const finalMimeType = mimetype
|
||||
?? EXTENSION_MIMETYPE_MAP.get(af.extension)
|
||||
?? ''
|
||||
;
|
||||
|
||||
const base64Data = Utils.toBase64( await app.vault.readBinary(af) );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue