From c7953645eeaaf9e87c6db4494b0023d2c1878ff0 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 28 Nov 2023 00:32:39 +0800 Subject: [PATCH] Remove deprecated markdown-remark APIs (#9182) --- .changeset/shiny-trees-sip.md | 5 +++ .../remark/src/frontmatter-injection.ts | 16 -------- packages/markdown/remark/src/index.ts | 39 +------------------ packages/markdown/remark/src/internal.ts | 6 +-- 4 files changed, 7 insertions(+), 59 deletions(-) create mode 100644 .changeset/shiny-trees-sip.md diff --git a/.changeset/shiny-trees-sip.md b/.changeset/shiny-trees-sip.md new file mode 100644 index 000000000000..991c7aa92825 --- /dev/null +++ b/.changeset/shiny-trees-sip.md @@ -0,0 +1,5 @@ +--- +'@astrojs/markdown-remark': major +--- + +Removes deprecated APIs. All Astro packages had been refactored to not use these APIs. diff --git a/packages/markdown/remark/src/frontmatter-injection.ts b/packages/markdown/remark/src/frontmatter-injection.ts index 4828873fd2c1..91b98ebcba63 100644 --- a/packages/markdown/remark/src/frontmatter-injection.ts +++ b/packages/markdown/remark/src/frontmatter-injection.ts @@ -32,19 +32,3 @@ export function setVfileFrontmatter(vfile: VFile, frontmatter: Record; -}) { - return () => - function (tree: any, vfile: VFile) { - if (!vfile.data.astro) { - vfile.data.astro = { frontmatter: userFrontmatter }; - } - }; -} diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index d42ce480c308..bf70a368d274 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -1,10 +1,4 @@ -import type { - AstroMarkdownOptions, - MarkdownProcessor, - MarkdownRenderingOptions, - MarkdownRenderingResult, - MarkdownVFile, -} from './types.js'; +import type { AstroMarkdownOptions, MarkdownProcessor, MarkdownVFile } from './types.js'; import { InvalidAstroDataError, @@ -150,42 +144,11 @@ export async function createMarkdownProcessor( imagePaths: result.data.imagePaths ?? new Set(), frontmatter: astroData.frontmatter ?? {}, }, - // Compat for `renderMarkdown` only. Do not use! - __renderMarkdownCompat: { - result, - }, }; }, }; } -/** - * Shared utility for rendering markdown - * - * @deprecated Use `createMarkdownProcessor` instead for better performance - */ -export async function renderMarkdown( - content: string, - opts: MarkdownRenderingOptions -): Promise { - const processor = await createMarkdownProcessor(opts); - - const result = await processor.render(content, { - fileURL: opts.fileURL, - frontmatter: opts.frontmatter, - }); - - return { - code: result.code, - metadata: { - headings: result.metadata.headings, - source: content, - html: result.code, - }, - vfile: (result as any).__renderMarkdownCompat.result, - }; -} - function prefixError(err: any, prefix: string) { // If the error is an object with a `message` property, attempt to prefix the message if (err?.message) { diff --git a/packages/markdown/remark/src/internal.ts b/packages/markdown/remark/src/internal.ts index 0ab7e34bb394..6201ef62f48b 100644 --- a/packages/markdown/remark/src/internal.ts +++ b/packages/markdown/remark/src/internal.ts @@ -1,5 +1 @@ -export { - InvalidAstroDataError, - safelyGetAstroData, - toRemarkInitializeAstroData, -} from './frontmatter-injection.js'; +export { InvalidAstroDataError, safelyGetAstroData } from './frontmatter-injection.js';