Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

feat: Add metadata to exported markdown content

Smaug6739d2f2d08640e3
diff --git a/frontend/app/helpers/node.ts b/frontend/app/helpers/node.ts
index dda51eb5..1a1fc668 100644
--- a/frontend/app/helpers/node.ts
+++ b/frontend/app/helpers/node.ts
@@ -32,3 +32,13 @@ export const resolveNodeType = (node: Node): string => {
const types: Record<number, string> = { 1: 'Workspace', 2: 'Category', 3: 'Document', 4: 'Resource' };
return types[node.role] || '';
};
+
+/* Generate markdown file with metadata from a node */
+export const generateMarkdownWithMetadata = (node: Node): string => {
+ const metadataLines = ['---', `title: "${node.name}"`];
+
+ if (node.description) metadataLines.push(`description: "${node.description}"`);
+ if (node.tags && node.tags.length > 0) metadataLines.push(`tags: ${node.tags}`);
+ metadataLines.push('---', '', '');
+ return metadataLines.join('\n') + (node.content || '');
+};
diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
index b274067b..82848ae4 100644
--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue
@@ -39,6 +39,7 @@ import DeleteNodeModal from '~/components/Node/DeleteNodeModal.vue';
import DocumentMeta from '~/components/Node/NodeMetadata.modal.vue';
import NodePermissions from '~/components/Node/NodePermissions.modal.vue';
import RemoveSharedNode from '~/components/Node/RemoveSharedNode.modal.vue';
+import { generateMarkdownWithMetadata } from '~/helpers/node';
import type { Node } from '~/stores';
const props = defineProps<{ doc: Node }>();
@@ -62,7 +63,7 @@ const openPermissionsModal = () => useModal().add(new Modal(shallowRef(NodePermi
const openRemoveShareModal = () => useModal().add(new Modal(shallowRef(RemoveSharedNode), { props: { nodeId: props.doc.id }, size: 'small' }));
function exportMarkdown() {
- const blob = new Blob([props.doc.content || ''], { type: 'text/markdown' });
+ const blob = new Blob([generateMarkdownWithMetadata(props.doc)], { type: 'text/markdown' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;