Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/integrations/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "astro-scripts test --timeout 70000 \"test/**/*.test.js\""
"test": "astro-scripts test --timeout 70000 \"test/**/*.test.ts\"",
"typecheck:tests": "tsc --build tsconfig.test.json"
},
"dependencies": {
"@astrojs/markdown-remark": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { before, describe, it } from 'node:test';
import mdx from '@astrojs/mdx';
import * as cheerio from 'cheerio';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';
import { loadFixture, type Fixture } from '../../../astro/test/test-utils.js';

describe('Head injection w/ MDX', () => {
let fixture;
let fixture: Fixture;

before(async () => {
fixture = await loadFixture({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { loadFixture } from '../../../astro/test/test-utils.js';
import { loadFixture, type Fixture } from '../../../astro/test/test-utils.js';
import mdx from '../dist/index.js';

const FIXTURE_ROOT = new URL('./fixtures/invalid-mdx-component/', import.meta.url);

describe('MDX component with runtime error', () => {
let fixture;
let fixture: Fixture;

before(async () => {
fixture = await loadFixture({
Expand All @@ -16,22 +16,21 @@ describe('MDX component with runtime error', () => {
});

describe('build', () => {
/** @type {Error | null} */
let error;
let error: Error | null = null;

before(async () => {
error = null;
try {
await fixture.build();
} catch (e) {
error = e;
error = e as Error;
}
});

it('Throws the right error', async () => {
assert.ok(error);
assert.match(
error?.hint,
(error as Error & { hint?: string })?.hint ?? '',
/This issue often occurs when your MDX component encounters runtime errors/,
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import { loadFixture } from '../../../astro/test/test-utils.js';
import { loadFixture, type Fixture } from '../../../astro/test/test-utils.js';

describe('MDX Component & Astro Container escape issue', () => {
let fixture;
let fixture: Fixture;

before(async () => {
fixture = await loadFixture({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ describe('MDX with Astro Markdown remark-rehype config', () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);

assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
assert.equal(document.querySelector('#footnote-label')!.textContent, 'Catatan kaki');
assert.equal(
document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
document.querySelector('.data-footnote-backref')!.getAttribute('aria-label'),
'Kembali ke konten',
);
});
Expand All @@ -50,9 +50,9 @@ describe('MDX with Astro Markdown remark-rehype config', () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);

assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
assert.equal(document.querySelector('#footnote-label')!.textContent, 'Catatan kaki');
assert.equal(
document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
document.querySelector('.data-footnote-backref')!.getAttribute('aria-label'),
'Kembali ke konten',
);
});
Expand All @@ -62,7 +62,6 @@ describe('MDX with Astro Markdown remark-rehype config', () => {
root: new URL('./fixtures/mdx-astro-markdown-remarkRehype/', import.meta.url),
integrations: [
mdx({
extendPlugins: 'astroDefaults',
remarkRehype: {
footnoteLabel: 'Catatan kaki',
Copy link
Copy Markdown
Contributor Author

@ocavue ocavue Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer:

This extendPlugins: '...' API seems to have been gone a long time ago. See the changelog link:

- Simplify `extendPlugins` to an `extendMarkdownConfig` option. MDX options will default to their equivalent in your Markdown config. By setting `extendMarkdownConfig` to false, you can "eject" to set your own syntax highlighting, plugins, and more.
- **Migrate MDX's `extendPlugins` to `extendMarkdownConfig`**
You may have used the `extendPlugins` option to manage plugin defaults in MDX. This has been replaced by 3 flags:
- `extendMarkdownConfig` (`true` by default) to toggle Markdown config inheritance. This replaces the `extendPlugins: 'markdown'` option.
- `gfm` (`true` by default) and `smartypants` (`true` by default) to toggle GitHub-Flavored Markdown and SmartyPants in MDX. This replaces the `extendPlugins: 'defaults'` option.

},
Expand All @@ -79,9 +78,9 @@ describe('MDX with Astro Markdown remark-rehype config', () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);

assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
assert.equal(document.querySelector('#footnote-label')!.textContent, 'Catatan kaki');
assert.equal(
document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
document.querySelector('.data-footnote-backref')!.getAttribute('aria-label'),
'Back to reference 1',
);
});
Expand Down
Loading
Loading