๐ Patch Changes
- Updated dependencies [
240c317]:- @astrojs/internal-helpers@0.8.0-beta.0
240c317]:
cb99214 Thanks @ematipico! - Fixes an issue where the function createShikiHighlighter would always create a new Shiki highlighter instance. Now the function returns a cached version of the highlighter based on the Shiki options. This should improve the performance for sites that heavily rely on Shiki and code in their pages.11efb05]:
d8305f8 Thanks @tuyuritio! - Prevents HAST-only props from being directly converted into HTML attributesb8ca69b]:
1e2499e]:
4d16de7]:
0567fb7]:
f4e8889]:
#13941 6bd5f75 Thanks @aditsachde! - Adds support for TOML files to Astroโs built-in glob() and file() content loaders.
In Astro 5.2, Astro added support for using TOML frontmatter in Markdown files instead of YAML. However, if you wanted to use TOML files as local content collection entries themselves, you needed to write your own loader.
Astro 5.12 now directly supports loading data from TOML files in content collections in both the glob() and the file() loaders.
If you had added your own TOML content parser for the file() loader, you can now remove it as this functionality is now included:
import { defineCollection } from "astro:content";import { file } from "astro/loaders"; import { parse as parseToml } from "toml";const dogs = defineCollection({ loader: file("src/data/dogs.toml", { parser: (text) => parseToml(text) }), loader: file("src/data/dogs.toml") schema: /* ... */})Note that TOML does not support top-level arrays. Instead, the file() loader considers each top-level table to be an independent entry. The table header is populated in the id field of the entry object.
See Astroโs content collections guide for more information on using the built-in content loaders.
3c3b492]:
#13352 cb886dc Thanks @delucis! - Adds support for a new experimental.headingIdCompat flag
By default, Astro removes a trailing - from the end of IDs it generates for headings ending with
special characters. This differs from the behavior of common Markdown processors.
You can now disable this behavior with a new configuration flag:
import { defineConfig } from 'astro/config';
export default defineConfig({ experimental: { headingIdCompat: true, },});This can be useful when heading IDs and anchor links need to behave consistently across your site and other platforms such as GitHub and npm.
If you are using the rehypeHeadingIds plugin directly, you can also pass this new option:
import { defineConfig } from 'astro/config';import { rehypeHeadingIds } from '@astrojs/markdown-remark';import { otherPluginThatReliesOnHeadingIDs } from 'some/plugin/source';
export default defineConfig({ markdown: { rehypePlugins: [ [rehypeHeadingIds, { experimentalHeadingIdCompat: true }], otherPluginThatReliesOnHeadingIDs, ], },});#13311 a3327ff Thanks @chrisirhc! - Adds a new configuration option for Markdown syntax highlighting excludeLangs
This option provides better support for diagramming tools that rely on Markdown code blocks, such as Mermaid.js and D2 by allowing you to exclude specific languages from Astroโs default syntax highlighting.
This option allows you to avoid rendering conflicts with tools that depend on the code not being highlighted without forcing you to disable syntax highlighting for other code blocks.
The following example configuration will exclude highlighting for mermaid and math code blocks:
import { defineConfig } from 'astro/config';
export default defineConfig({ markdown: { syntaxHighlight: { type: 'shiki', excludeLangs: ['mermaid', 'math'], }, },});Read more about this new option in the Markdown syntax highlighting configuration docs.
042d1de]:
#13254 1e11f5e Thanks @p0lyw0lf! - Adds remote image optimization in Markdown
Previously, an internal remark plugin only looked for images in ![]() syntax that referred to a relative file path. This meant that only local images stored in src/ were passed through to an internal rehype plugin that would transform them for later processing by Astroโs image service.
Now, the plugins recognize and transform both local and remote images using this syntax. Only authorized remote images specified in your config are transformed; remote images from other sources will not be processed.
While not configurable at this time, this process outputs two separate metadata fields (localImagePaths and remoteImagePaths) which allow for the possibility of controlling the behavior of each type of image separately in the future.
1e11f5e]:
#12850 db252e0 Thanks @colinbate! - Adds support for TOML frontmatter in .md and .mdx files
Astro 5.2 automatically identifies the format of your Markdown and MDX frontmatter based on the delimiter used. With +++ as a delimiter (instead of the --- YAML code fence), your frontmatter will automatically be recognized and parsed as TOML.
This is useful for adding existing content files with TOML frontmatter to your project from another framework such as Hugo.
TOML frontmatter can also be used with content collections, and files with different frontmatter languages can live together in the same project.
No configuration is required to use TOML frontmatter in your content files. Your delimiter will indicate your chosen frontmatter language:
+++date = 2025-01-30title = 'Use TOML frontmatter in Astro!'[author]name = 'Colin Bate'+++
# Support for TOML frontmatter is here!3d89e62 Thanks @LunaticMuch! - Upgrades the esbuild version to match vite#12646 f13417b Thanks @bluwy! - Avoids parsing frontmatter that are not at the top of a file
#12570 87231b1 Thanks @GrimLink! - Removes trailing new line in code blocks to prevent generating a trailing empty <span /> tag
#12664 a71e9b9 Thanks @bluwy! - Fixes frontmatter parsing if file is encoded in UTF8 with BOM
#11861 3ab3b4e Thanks @bluwy! - Cleans up Astro-specfic metadata attached to vfile.data in Remark and Rehype plugins. Previously, the metadata was attached in different locations with inconsistent names. The metadata is now renamed as below:
vfile.data.__astroHeadings -> vfile.data.astro.headingsvfile.data.imagePaths -> vfile.data.astro.imagePathsThe types of imagePaths has also been updated from Set<string> to string[]. The vfile.data.astro.frontmatter metadata is left unchanged.
While we donโt consider these APIs public, they can be accessed by Remark and Rehype plugins that want to re-use Astroโs metadata. If you are using these APIs, make sure to access them in the new locations.
#12008 5608338 Thanks @Princesseuh! - Welcome to the Astro 5 beta! This release has no changes from the latest alpha of this package, but it does bring us one step closer to the final, stable release.
Starting from this release, no breaking changes will be introduced unless absolutely necessary.
To learn how to upgrade, check out the Astro v5.0 upgrade guide in our beta docs site.
#11825 560ef15 Thanks @bluwy! - Updates return object of createShikiHighlighter as codeToHast and codeToHtml to allow generating either the hast or html string directly
#11661 83a2a64 Thanks @bluwy! - Renames the following CSS variables theme color token names to better align with the Shiki v1 defaults:
--astro-code-color-text => --astro-code-foreground--astro-code-color-background => --astro-code-backgroundYou can perform a global find and replace in your project to migrate to the new token names.
#11861 3ab3b4e Thanks @bluwy! - Removes InvalidAstroDataError, safelyGetAstroData, and setVfileFrontmatter APIs in favour of isFrontmatterValid