feat(export): add .toml source download and shared slugify helper

This commit is contained in:
Julien Calixte
2026-06-17 09:32:07 +02:00
parent 35c84cf943
commit 3c32542a76
3 changed files with 38 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
import { slugify } from './usePngExport'
/** Slugified, stable download name for a plan's TOML source. */
export function sourceFilename(title: string): string {
return `macroplan-${slugify(title) || 'plan'}.toml`
}
/** Download a plan's TOML source as a .toml file (client-side, no backend). */
export function downloadSource(source: string, filename: string): void {
const blob = new Blob([source], { type: 'text/plain;charset=utf-8' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = filename
a.click()
URL.revokeObjectURL(url)
}