Skip to content

Add a Sätteri tab in the remark/rehype recipes - #14277

Merged
ArmandPhilippot merged 20 commits into
mainfrom
armand/satteri-recipes
Aug 19, 2026
Merged

ArmandPhilippot merged 20 commits into
mainfrom
armand/satteri-recipes

Conversation

@ArmandPhilippot

@ArmandPhilippot ArmandPhilippot commented Jul 18, 2026 •

Copy link
Copy Markdown
Member

Description (required)

Since Astro 7, Sätteri is the default Markdown processor, but our recipes were still using remark/rehype. This adds Sätteri/Unified tabs to them!

  • external-links.mdx: <Steps /> nested inside <Tabs /> as the content is different enough
  • modified-time.mdx and reading-time.mdx: <Tabs /> nested inside <Steps /> as the content is pretty similar
  • Sätteri doesn't have a root visitor, so I worked around that. But, we might be able to use something else in the future: in Support root visitor on plugins bruits/satteri#164 Erika said a root visitor is planned for the next Sätteri minor!

If you want to check/play with the plugins:

Note that git is not available on Stackblitz, so you'll need to download the repro, init Git, and make an initial commit.

In addition, I updated a few other things:

  • external-links.mdx: Removes the callout at the end as the statement is wrong. rehype-external-links does not use the CSS content property but a <span /> to inject the content (see https://www.npmjs.com/package/rehype-external-links#fields). So, the icon is in the accessibility tree. Now, I agree this is not the best for accessibility but it doesn't seem like we have control on the <span> (e.g. to set aria-hidden: true).
  • modified-time.mdx and reading-time.mdx, continuing my series on fixing code snippets issues:
    • <head>...</head> is formatted to <head></head>... so I added some content in there instead.
    • In "If you’re using a Markdown layout", <meta charset="utf-8" / > is expected since v5

@ArmandPhilippot ArmandPhilippot added the add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. label Jul 18, 2026
@astrobot-houston

astrobot-houston commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/recipes/external-links.mdx Source changed, localizations will be marked as outdated.
en/recipes/modified-time.mdx Source changed, localizations will be marked as outdated.
en/recipes/reading-time.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@github-actions

github-actions Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Preview deployment

✅ Deployment complete!

import getReadingTime from 'reading-time';
import { defineMdastPlugin, type MdastNode } from 'satteri';

const findRoot = (

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is verbose compared to the remark version but, AFAIK, this is the best way in Sätteri; I've done the same thing when porting my website. Parsing ctx.source instead seems to work with Markdown files but this is not reliable with MDX (components, custom plugins).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now yeah, next minor will include a way to get the root before and after mutations, which should work for this usecase


export const mdastReadingTimePlugin = defineMdastPlugin({
name: "mdast-reading-time",
text(node, context) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there is something better than the text() visitor here. Because it runs multiple times for the same file, we need to check if the frontmatter property is set to return early.

@ArmandPhilippot
ArmandPhilippot marked this pull request as ready for review July 21, 2026 13:37
element: {
filter: ["a"],
visit(node, context) {
if (node.properties.href?.startsWith("http")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will result in a type error, but it's honestly Sätteri's fault, I'll fix it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't noticed anything locally, and astro check reports nothing. 👀

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that if you have the latest version of @types/hast it's okay, but Sätteri itself peer deps isn't on latest

@ArmandPhilippot

Copy link
Copy Markdown
Member Author

I see that the root visitor is almost there (withastro/astro#17731). @Princesseuh Would you prefer to wait for it, or does a later update of the recipe work for you? If it's the latter, can I get an explicit approval before merging this? 😄

@Princesseuh

Copy link
Copy Markdown
Member

I merged the root visitor (note that it's a before / after hooks, but this should work for this use case). If you have the motivation, I'd say to rewrite these docs for the new hooks just to avoid people ruining their performance and never updating after

BUT, I'll approve nonetheless, because at the end of the day, the world is infinite, so is our ambition and this is still better than current.

@ArmandPhilippot

Copy link
Copy Markdown
Member Author

Thank you! 🙌🏽 So, I'm going to merge this and I'll try to quickly update that recipe once withastro/astro#17739 is released. As you said, it's best to showcase best practices with Sätteri for performance!

@ArmandPhilippot
ArmandPhilippot merged commit 57ec237 into main Aug 19, 2026
9 checks passed
@ArmandPhilippot
ArmandPhilippot deleted the armand/satteri-recipes branch August 19, 2026 10:04
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Aug 19, 2026
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Aug 19, 2026
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add new content Document something that is not in docs. May require testing, confirmation, or affect other pages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants