Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

feat(export): render guide description in html, markdown and pdf

Luis Ortizfa8b4272c1a0
diff --git a/src/core/export/__tests__/markdown-export.test.ts b/src/core/export/__tests__/markdown-export.test.ts
index 943f5d2..c37d1c8 100644
--- a/src/core/export/__tests__/markdown-export.test.ts
+++ b/src/core/export/__tests__/markdown-export.test.ts
@@ -105,6 +105,27 @@ describe('exportGuideAsMarkdown', () => {
expect(md).not.toContain('![');
});
+ it('includes the description under the title when present', async () => {
+ const guide = makeGuide({ description: 'Reset a locked-out user password.' });
+ const steps = [makeStep()];
+ const screenshots = new Map<string, Screenshot>();
+
+ const md = await exportGuideAsMarkdown(guide, steps, screenshots);
+ expect(md).toContain('# Test Guide\n\nReset a locked-out user password.\n\n');
+ });
+
+ it('omits the description block when absent', async () => {
+ const guide = makeGuide();
+ const steps = [makeStep()];
+ const screenshots = new Map<string, Screenshot>();
+
+ const md = await exportGuideAsMarkdown(guide, steps, screenshots);
+ const lines = md.split('\n');
+ expect(lines[1]).toBe('');
+ expect(lines[2].startsWith('*')).toBe(true);
+ expect(md).not.toContain('undefined');
+ });
+
it('embeds screenshot as base64 data URL in markdown image', async () => {
const guide = makeGuide();
const step = makeStep();
diff --git a/src/core/export/html-export.ts b/src/core/export/html-export.ts
index 3ecc1d9..f0f5aff 100644
--- a/src/core/export/html-export.ts
+++ b/src/core/export/html-export.ts
@@ -85,6 +85,7 @@ export async function exportGuideAsHTML(
<div style="flex:1;">
<div style="font-size:11px;font-weight:700;color:#6B7280;letter-spacing:0.08em;">${i18n.t('export.guideLabel')}</div>
<h1 style="font-size:38px;font-weight:700;line-height:1.15;margin-top:18px;">${escapeHtml(guide.title)}</h1>
+ ${guide.description ? `<p style="font-size:16px;color:#6B7280;line-height:1.6;margin-top:14px;max-width:60ch;">${escapeHtml(guide.description)}</p>` : ''}
</div>
${logoHtml}
</div>
@@ -115,6 +116,7 @@ export async function exportGuideAsHTML(
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${escapeHtml(guide.title)}</title>
+ ${guide.description ? `<meta name="description" content="${escapeHtml(guide.description)}">` : ''}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
diff --git a/src/core/export/markdown-export.ts b/src/core/export/markdown-export.ts
index add699f..d9fa6c2 100644
--- a/src/core/export/markdown-export.ts
+++ b/src/core/export/markdown-export.ts
@@ -15,7 +15,9 @@ export async function exportGuideAsMarkdown(
...(domain ? [i18n.t('export.sourceLabel', [domain])] : []),
].join(' Β· ');
- const lines: string[] = [`# ${guide.title}`, '', `*${meta}*`, '', '---', ''];
+ const lines: string[] = [`# ${guide.title}`, ''];
+ if (guide.description) lines.push(guide.description, '');
+ lines.push(`*${meta}*`, '', '---', '');
for (const step of steps) {
const num = String(step.index + 1).padStart(2, '0');
diff --git a/src/core/export/pdf-export.ts b/src/core/export/pdf-export.ts
index 8202eb8..0d9ca0b 100644
--- a/src/core/export/pdf-export.ts
+++ b/src/core/export/pdf-export.ts
@@ -69,7 +69,15 @@ export async function exportGuideAsPDF(
const titleLines = doc.splitTextToSize(guide.title, CONTENT_W * 0.82);
doc.text(titleLines, MARGIN, MARGIN + 26);
- const y = MARGIN + 26 + (titleLines.length - 1) * 11 + 8;
+ let y = MARGIN + 26 + (titleLines.length - 1) * 11 + 8;
+ if (guide.description) {
+ doc.setFontSize(11);
+ doc.setFont('helvetica', 'normal');
+ doc.setTextColor(...MUTED);
+ const descLines = doc.splitTextToSize(guide.description, CONTENT_W * 0.7);
+ doc.text(descLines, MARGIN, y + 4);
+ y += 4 + (descLines.length - 1) * 5 + 8;
+ }
doc.setDrawColor(...INK);
doc.setLineWidth(0.4);
doc.line(MARGIN, y, RIGHT, y);