Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: add support for markdown + frontmatter

Ammar Ahmedd71b9edc7f29
diff --git a/apps/mobile/app/components/sheets/export-notes/index.js b/apps/mobile/app/components/sheets/export-notes/index.js
index bf609c47d..01cc9e9a8 100644
--- a/apps/mobile/app/components/sheets/export-notes/index.js
+++ b/apps/mobile/app/components/sheets/export-notes/index.js
@@ -97,6 +97,16 @@ const ExportNotesSheet = ({ notes, update }) => {
id: notesnook.ids.dialogs.export.md,
pro: premium
},
+ {
+ title: "Markdown + Frontmatter",
+ func: async () => {
+ await save("md-frontmatter");
+ },
+ icon: "language-markdown",
+ desc: "View in any text or markdown editor",
+ id: notesnook.ids.dialogs.export.md,
+ pro: premium
+ },
{
title: "Plain Text",
func: async () => {
@@ -178,7 +188,9 @@ const ExportNotesSheet = ({ notes, update }) => {
>
<Icon
name={item.icon}
- color={item.pro ? colors.primary.accent : colors.primary.icon}
+ color={
+ item.pro ? colors.primary.accent : colors.primary.icon
+ }
size={SIZE.xxxl + 10}
/>
</View>
diff --git a/apps/mobile/app/services/exporter.js b/apps/mobile/app/services/exporter.js
index 4b4644a62..5182f747a 100644
--- a/apps/mobile/app/services/exporter.js
+++ b/apps/mobile/app/services/exporter.js
@@ -109,7 +109,7 @@ async function makeHtml(note) {
/**
*
- * @param {"txt" | "pdf" | "md" | "html"} type
+ * @param {"txt" | "pdf" | "md" | "html" | "md-frontmatter"} type
*/
async function exportAs(type, note, bulk) {
let data;
@@ -122,6 +122,9 @@ async function exportAs(type, note, bulk) {
case "md":
data = await db.notes.note(note.id).export("md");
break;
+ case "md-frontmatter":
+ data = await db.notes.note(note.id).export("md-frontmatter");
+ break;
case "pdf":
{
let html = await makeHtml(note);
@@ -159,7 +162,7 @@ async function exportAs(type, note, bulk) {
/**
*
- * @param {"txt" | "pdf" | "md" | "html"} type
+ * @param {"txt" | "pdf" | "md" | "html" | "md-frontmatter"} type
*/
async function exportNote(note, type) {
let path = await getPath(FolderNames[type]);
@@ -180,7 +183,7 @@ async function exportNote(note, type) {
filePath: path,
type: "text/plain",
name: "Text",
- fileName: fileName + `.${type}`
+ fileName: fileName + `.${type === "md-frontmatter" ? "md" : type}`
};
}
@@ -212,7 +215,7 @@ function getUniqueFileName(fileName, results) {
/**
*
- * @param {"txt" | "pdf" | "md" | "html"} type
+ * @param {"txt" | "pdf" | "md" | "html" | "md-frontmatter"} type
*/
async function bulkExport(notes, type, callback) {
let path = await getPath(FolderNames[type]);