mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Remove deprecated markdown-remark APIs (#9182)
This commit is contained in:
parent
88f40846d4
commit
c7953645ee
4 changed files with 7 additions and 59 deletions
5
.changeset/shiny-trees-sip.md
Normal file
5
.changeset/shiny-trees-sip.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/markdown-remark': major
|
||||
---
|
||||
|
||||
Removes deprecated APIs. All Astro packages had been refactored to not use these APIs.
|
|
@ -32,19 +32,3 @@ export function setVfileFrontmatter(vfile: VFile, frontmatter: Record<string, an
|
|||
vfile.data.astro ??= {};
|
||||
(vfile.data.astro as any).frontmatter = frontmatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `setVfileFrontmatter` instead
|
||||
*/
|
||||
export function toRemarkInitializeAstroData({
|
||||
userFrontmatter,
|
||||
}: {
|
||||
userFrontmatter: Record<string, any>;
|
||||
}) {
|
||||
return () =>
|
||||
function (tree: any, vfile: VFile) {
|
||||
if (!vfile.data.astro) {
|
||||
vfile.data.astro = { frontmatter: userFrontmatter };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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<MarkdownRenderingResult> {
|
||||
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) {
|
||||
|
|
|
@ -1,5 +1 @@
|
|||
export {
|
||||
InvalidAstroDataError,
|
||||
safelyGetAstroData,
|
||||
toRemarkInitializeAstroData,
|
||||
} from './frontmatter-injection.js';
|
||||
export { InvalidAstroDataError, safelyGetAstroData } from './frontmatter-injection.js';
|
||||
|
|
Loading…
Reference in a new issue