Various AT Protocol integrations with obsidian

standard.site: Respect `path` field and normalize URLs (#15)

The `path` frontmatter field in notes being published is now passed on
to the resultant `site.standard.document` record, and the `url` field
written post-publish now uses that path and is sanitized to prevent
double slashes.

authored by isaaccorbrey.com and committed by

GitHub 4e3874bd 6d8ad789

+15 -2
+13
src/commands/publishDocument.ts
··· 43 43 } 44 44 } 45 45 46 + function normalizePath(raw: unknown): string | undefined { 47 + if (typeof raw !== "string") { 48 + return undefined; 49 + } 50 + const trimmed = raw.trim(); 51 + if (!trimmed) { 52 + return undefined; 53 + } 54 + const withoutLeading = trimmed.replace(/^\/+/, ""); 55 + return withoutLeading || undefined; 56 + } 57 + 46 58 async function updateFrontMatter( 47 59 plugin: AtmospherePlugin, 48 60 file: TFile, ··· 97 109 docUri = fm["atDocument"] as ResourceUri; 98 110 description = fm["description"]; 99 111 title = fm["title"]; 112 + path = normalizePath(fm["path"]); 100 113 tags = fm["tags"] && Array.isArray(fm["tags"]) ? fm["tags"] : undefined; 101 114 publishedAt = fm["publishedAt"]; // Preserve existing if updating 102 115 }
+2 -2
src/lib/standardsite/index.ts
··· 21 21 return "" 22 22 } 23 23 24 - return `${baseUrl}/${record.path}` 24 + const normalizedPath = record.path.replace(/^\/+/, ""); 25 + return `${baseUrl}/${normalizedPath}` 25 26 } 26 27 27 28 ··· 211 212 } 212 213 return pubs; 213 214 } 214 -