summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/calm-emus-raise.md6
-rw-r--r--packages/astro/src/@types/astro.ts10
-rw-r--r--packages/astro/src/vite-plugin-markdown/index.ts20
-rw-r--r--packages/integrations/mdx/src/index.ts16
-rw-r--r--packages/integrations/mdx/src/plugins.ts16
5 files changed, 7 insertions, 61 deletions
diff --git a/.changeset/calm-emus-raise.md b/.changeset/calm-emus-raise.md
new file mode 100644
index 000000000..4e721aecf
--- /dev/null
+++ b/.changeset/calm-emus-raise.md
@@ -0,0 +1,6 @@
+---
+'astro': major
+'@astrojs/mdx': minor
+---
+
+Remove deprecated Markdown APIs from Astro v0.X. This includes `getHeaders()`, the `.astro` property for layouts, and the `rawContent()` and `compiledContent()` error messages for MDX.
diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts
index 75e75f6a3..b02da1c3a 100644
--- a/packages/astro/src/@types/astro.ts
+++ b/packages/astro/src/@types/astro.ts
@@ -1028,20 +1028,12 @@ export interface MarkdownInstance<T extends Record<string, any>> {
compiledContent(): string;
/** List of headings (h1 -> h6) with associated metadata */
getHeadings(): MarkdownHeading[];
- /** @deprecated Renamed to `getHeadings()` */
- getHeaders(): void;
default: AstroComponentFactory;
}
type MD = MarkdownInstance<Record<string, any>>;
-export interface MDXInstance<T extends Record<string, any>>
- extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> {
- /** MDX does not support rawContent! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
- rawContent: never;
- /** MDX does not support compiledContent! If you need to read the HTML contents to calculate values (ex. reading time), we suggest injecting frontmatter via rehype plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
- compiledContent: never;
-}
+export type MDXInstance<T extends Record<string, any>> = Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'>;
export interface MarkdownLayoutProps<T extends Record<string, any>> {
frontmatter: {
diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts
index 6891bc0d5..746bfde36 100644
--- a/packages/astro/src/vite-plugin-markdown/index.ts
+++ b/packages/astro/src/vite-plugin-markdown/index.ts
@@ -111,30 +111,10 @@ export default function markdown({ settings, logging }: AstroPluginOptions): Plu
export function getHeadings() {
return ${JSON.stringify(headings)};
}
- export function getHeaders() {
- console.warn('getHeaders() have been deprecated. Use getHeadings() function instead.');
- return getHeadings();
- };
export async function Content() {
const { layout, ...content } = frontmatter;
content.file = file;
content.url = url;
- content.astro = {};
- Object.defineProperty(content.astro, 'headings', {
- get() {
- throw new Error('The "astro" property is no longer supported! To access "headings" from your layout, try using "Astro.props.headings."')
- }
- });
- Object.defineProperty(content.astro, 'html', {
- get() {
- throw new Error('The "astro" property is no longer supported! To access "html" from your layout, try using "Astro.props.compiledContent()."')
- }
- });
- Object.defineProperty(content.astro, 'source', {
- get() {
- throw new Error('The "astro" property is no longer supported! To access "source" from your layout, try using "Astro.props.rawContent()."')
- }
- });
const contentFragment = h(Fragment, { 'set:html': html });
return ${
layout
diff --git a/packages/integrations/mdx/src/index.ts b/packages/integrations/mdx/src/index.ts
index 756e6d24f..577d073ee 100644
--- a/packages/integrations/mdx/src/index.ts
+++ b/packages/integrations/mdx/src/index.ts
@@ -12,12 +12,6 @@ import type { Plugin as VitePlugin } from 'vite';
import { getRehypePlugins, getRemarkPlugins, recmaInjectImportMetaEnvPlugin } from './plugins.js';
import { getFileInfo, parseFrontmatter } from './utils.js';
-const RAW_CONTENT_ERROR =
- 'MDX does not support rawContent()! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins';
-
-const COMPILED_CONTENT_ERROR =
- 'MDX does not support compiledContent()! If you need to read the HTML contents to calculate values (ex. reading time), we suggest injecting frontmatter via rehype plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins';
-
export type MdxOptions = Omit<typeof markdownConfigDefaults, 'remarkPlugins' | 'rehypePlugins'> & {
extendMarkdownConfig: boolean;
recmaPlugins: PluggableList;
@@ -123,16 +117,6 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
if (!moduleExports.includes('file')) {
code += `\nexport const file = ${JSON.stringify(fileId)};`;
}
- if (!moduleExports.includes('rawContent')) {
- code += `\nexport function rawContent() { throw new Error(${JSON.stringify(
- RAW_CONTENT_ERROR
- )}) };`;
- }
- if (!moduleExports.includes('compiledContent')) {
- code += `\nexport function compiledContent() { throw new Error(${JSON.stringify(
- COMPILED_CONTENT_ERROR
- )}) };`;
- }
if (!moduleExports.includes('Content')) {
// Make `Content` the default export so we can wrap `MDXContent` and pass in `Fragment`
code = code.replace('export default MDXContent;', '');
diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts
index 6b97bc77c..8c98e0016 100644
--- a/packages/integrations/mdx/src/plugins.ts
+++ b/packages/integrations/mdx/src/plugins.ts
@@ -79,22 +79,6 @@ export function rehypeApplyFrontmatterExport() {
const { layout, ...content } = frontmatter;
content.file = file;
content.url = url;
- content.astro = {};
- Object.defineProperty(content.astro, 'headings', {
- get() {
- throw new Error('The "astro" property is no longer supported! To access "headings" from your layout, try using "Astro.props.headings."')
- }
- });
- Object.defineProperty(content.astro, 'html', {
- get() {
- throw new Error('The "astro" property is no longer supported! To access "html" from your layout, try using "Astro.props.compiledContent()."')
- }
- });
- Object.defineProperty(content.astro, 'source', {
- get() {
- throw new Error('The "astro" property is no longer supported! To access "source" from your layout, try using "Astro.props.rawContent()."')
- }
- });
return layoutJsx(Layout, {
file,
url,