diff options
author | 2025-02-26 05:15:35 -0500 | |
---|---|---|
committer | 2025-02-26 10:15:35 +0000 | |
commit | 1e11f5e8b722b179e382f3c792cd961b2b51f61b (patch) | |
tree | 32671113f3e93c92e4c3462f89298352b31c3e3f /packages/markdown/remark/src/index.ts | |
parent | 797a9480b23303329dd618633194cbfb3dccb459 (diff) | |
download | astro-1e11f5e8b722b179e382f3c792cd961b2b51f61b.tar.gz astro-1e11f5e8b722b179e382f3c792cd961b2b51f61b.tar.zst astro-1e11f5e8b722b179e382f3c792cd961b2b51f61b.zip |
feat: Pass remote Markdown images through image service (#13254)
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: ematipico <602478+ematipico@users.noreply.github.com>
Co-authored-by: sarah11918 <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: ascorbic <213306+ascorbic@users.noreply.github.com>
Diffstat (limited to 'packages/markdown/remark/src/index.ts')
-rw-r--r-- | packages/markdown/remark/src/index.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index de13523fe..d1b6035e4 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -1,4 +1,8 @@ -import type { AstroMarkdownOptions, MarkdownProcessor } from './types.js'; +import type { + AstroMarkdownOptions, + AstroMarkdownProcessorOptions, + MarkdownProcessor, +} from './types.js'; import { loadPlugins } from './load-plugins.js'; import { rehypeHeadingIds } from './rehype-collect-headings.js'; @@ -59,7 +63,7 @@ const isPerformanceBenchmark = Boolean(process.env.ASTRO_PERFORMANCE_BENCHMARK); * Create a markdown preprocessor to render multiple markdown files */ export async function createMarkdownProcessor( - opts?: AstroMarkdownOptions, + opts?: AstroMarkdownProcessorOptions, ): Promise<MarkdownProcessor> { const { syntaxHighlight = markdownConfigDefaults.syntaxHighlight, @@ -93,7 +97,7 @@ export async function createMarkdownProcessor( if (!isPerformanceBenchmark) { // Apply later in case user plugins resolve relative image paths - parser.use(remarkCollectImages); + parser.use(remarkCollectImages, opts?.image); } // Remark -> Rehype @@ -118,7 +122,7 @@ export async function createMarkdownProcessor( } // Images / Assets support - parser.use(rehypeImages()); + parser.use(rehypeImages); // Headings if (!isPerformanceBenchmark) { @@ -152,7 +156,8 @@ export async function createMarkdownProcessor( code: String(result.value), metadata: { headings: result.data.astro?.headings ?? [], - imagePaths: result.data.astro?.imagePaths ?? [], + localImagePaths: result.data.astro?.localImagePaths ?? [], + remoteImagePaths: result.data.astro?.remoteImagePaths ?? [], frontmatter: result.data.astro?.frontmatter ?? {}, }, }; |