Adapter and publisher registries with eight static-site adapters#7
Adapter and publisher registries with eight static-site adapters#7bnz183 wants to merge 1 commit into
Conversation
| article: Article, | ||
| config: DocusaurusMdxPathConfig, | ||
| ): string { | ||
| const contentDir = config.contentDir.replace(/\/+$/u, ""); |
| article: Article, | ||
| config: EleventyJekyllMarkdownPathConfig, | ||
| ): string { | ||
| const contentDir = config.contentDir.replace(/\/+$/u, ""); |
| article: Article, | ||
| config: HugoMarkdownPathConfig, | ||
| ): string { | ||
| const contentDir = config.contentDir.replace(/\/+$/u, ""); |
| article: Article, | ||
| config: MkdocsMarkdownPathConfig, | ||
| ): string { | ||
| const contentDir = config.contentDir.replace(/\/+$/u, ""); |
| article: Article, | ||
| config: NextjsMdxPathConfig, | ||
| ): string { | ||
| const contentDir = config.contentDir.replace(/\/+$/u, ""); |
| article: Article, | ||
| config: NuxtContentMarkdownPathConfig, | ||
| ): string { | ||
| const contentDir = config.contentDir.replace(/\/+$/u, ""); |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7bf79e14c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| `title: ${yamlScalar(article.title)}`, | ||
| `description: ${yamlScalar(article.description)}`, | ||
| `slug: ${yamlScalar(article.slug)}`, | ||
| ]; |
There was a problem hiding this comment.
Preserve required fields in Docusaurus output
When the Studio publishes with docusaurus-mdx, this frontmatter only persists title/description/slug; docusaurusMdxFromFrontmatter later reads date/pubDate, category, and draft only from frontmatter, and validateArticle requires those fields. A post created by this adapter therefore gets skipped by listPosts and fails loadPost validation immediately after publishing, so the adapter needs to emit or otherwise round-trip the required SourceDraft fields.
Useful? React with 👍 / 👎.
| `title: ${yamlScalar(article.title)}`, | ||
| `description: ${yamlScalar(article.description)}`, | ||
| `date: ${yamlScalar(article.pubDate)}`, | ||
| ...formatYamlTags(article.tags), |
There was a problem hiding this comment.
Persist category for MkDocs round-trips
For mkdocs-markdown, the rendered frontmatter omits category, but mkdocsMarkdownFromFrontmatter returns category: frontmatter.category and the Studio validates loaded posts with validateArticle, where category is required. Any post published through this adapter will be written successfully but then be omitted from the posts list and fail to reopen because its own output cannot validate.
Useful? React with 👍 / 👎.
| pushYamlOptional(frontmatter, "lastmod", article.updatedDate); | ||
| frontmatter.push(`draft: ${article.draft}`); | ||
| pushYamlOptional(frontmatter, "slug", article.slug); | ||
| frontmatter.push(...formatYamlCategories(article.category)); |
There was a problem hiding this comment.
Round-trip Hugo categories through the Studio parser
With the default Hugo YAML mode, the adapter writes the SourceDraft category as a categories: list, but the Studio frontmatter parser only has special handling for tags: lists before calling hugoMarkdownFromFrontmatter, which expects frontmatter.categories to be an array. As a result, Hugo posts created by SourceDraft reload with category undefined and fail validation/listing; either emit a scalar the parser already supports or teach the parser to read this array shape.
Useful? React with 👍 / 👎.
| const frontmatter = | ||
| resolved.frontmatterFormat === "toml" | ||
| ? renderTomlFrontmatter(article) | ||
| : renderYamlFrontmatter(article); |
There was a problem hiding this comment.
Parse Hugo TOML before enabling TOML output
When a user sets adapterOptions.frontmatterFormat to toml, this branch writes +++ TOML frontmatter, but the Studio load/list path still uses splitFrontmatter, which only accepts --- YAML delimiters. Posts published in this supported mode will be saved but then disappear from listing and return “frontmatter is missing or invalid” on load, so TOML parsing/delimiter support needs to land with the option.
Useful? React with 👍 / 👎.
| function defaultSlugFromPath(path: string): string { | ||
| const filename = path.split("/").pop() ?? ""; | ||
| return slugFromFilename(filename); |
There was a problem hiding this comment.
Derive slugs from index paths correctly
When filenameConvention: "index" is used for adapters that do not emit a slug field, such as MkDocs or Nuxt Content, publishing creates paths like content/blog/my-post/index.md, but loading calls this helper and first discards the parent directory, so the derived slug becomes index instead of my-post. That means newly published index-style posts reopen with the wrong slug and can later be republished to the wrong default path; preserve enough path context or use the adapter-specific slug parser for these conventions.
Useful? React with 👍 / 👎.
| author?: unknown; | ||
| metaTitle?: unknown; | ||
| metaDescription?: unknown; | ||
| canonicalUrl?: unknown; | ||
| socialImage?: unknown; |
There was a problem hiding this comment.
Persist new SEO fields in existing adapters
These fields are now accepted and normalized for all publish requests, but the existing astro-mdx and markdown renderers still omit author, metaTitle, metaDescription, canonicalUrl, and socialImage. With the default adapter, an API client can publish successfully with these values and have them silently dropped from the committed file, unlike the new adapters and the docs' compatibility matrix.
Useful? React with 👍 / 👎.
|
Closing retroactive split-stack review PR. Continuing from protected main with scoped feature PRs. |
PR 6 of 11. Adapter/publisher registries and eight static-site adapters with examples.