publishing: Allow setting target format#13
Conversation
| let textContent = stripMarkdown(content); | ||
|
|
||
| let richContent: PubLeafletContent.Main | BlogPcktContent.Main | null = null; | ||
| const publicationFormat = pubUri ? normalizeFormat(plugin.settings.publicationFormats?.[pubUri]) : undefined; |
There was a problem hiding this comment.
here we are choosing format based on pub URI, but below we are checking pub URL. I know you were testing with non leaflet/pckt publication so it likely works well in that case.
But If you try to use something like this in the settings (a leaflet pub mapped to pckt format)
"publicationFormats": {
"at://did:plc:sppiplftd2sxt3hbw7htj3b5/site.standard.publication/3mdmrc7ka4c2w": "pckt"
}
The mapping is overridden since the pub URL still contains leaflet. I'm aware that the pub url based selection is not great, and I intend to improve that. And I want to unblock you in the meantime.
There was a problem hiding this comment.
Don't worry too much about blocking me! I didn't think about URI vs URL here
| tags = fm["tags"] && Array.isArray(fm["tags"]) ? fm["tags"] : undefined; | ||
| publishedAt = fm["publishedAt"]; // Preserve existing if updating | ||
| } | ||
| format = normalizeFormat(fm?.["format"]); |
There was a problem hiding this comment.
same thing here, format property from the frontmatter is not respected if the publication has URL that matches leaflet or pckt.
I've thought that mapping a publication to a content type format might be better done via some type of UI interaction. But for now I think a frontmatter property is a good option.
Let's update this PR to remove the publicationFormats setting since:
- its not shown in the settings UI and is more verbose
- showing it in the settings may be confusing for people who don't need it
- frontmatter property is simpler and more explicit.
If the property is set, we should not even bother checking the pub url and only use the property's format.
In the future I think we'd want to use full lexicon name, but the short leaflet and pckt are good for now
However, lets rename the property to be docContentFormat
| publicationFormats: Record<string, ContentFormat>; | ||
| } | ||
|
|
||
| export type ContentFormat = "leaflet" | "pckt" | "plaintext"; |
There was a problem hiding this comment.
lets remove plaintext as an option, because the plaintext is always set for textContent regardless of the content field's format. If no content format is matched, then it can be left unset
2608b56 to
b867711
Compare
b867711 to
ae22f60
Compare
Adds the ability to choose a default publishing format (currently users can choose between Leaflet.pub, Pckt.blog, or plaintext), as well as adding a per-note override via the `format` frontmatter field.
ae22f60 to
b9047b2
Compare
Adds the ability to choose a default publishing format (currently users can choose between Leaflet.pub, Pckt.blog, or plaintext), as well as adding a per-note override via the
formatfrontmatter field.