-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make Remark rehype options available in astro config (#4138)
* make remark-rehype config available in astro.config.mjs * add test for remark-rehype config, checks that footnotes can be translated * update lockfile to take the added test into account * omit handlers and unkownHandler from the RemarkRehype type * define RemarkRehype with proper references to the handler and handlers types * formatting * changeset Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> Co-authored-by: Matthew Phillips <matthew@skypack.dev>
- Loading branch information
1 parent
b680c3e
commit 839097c
Showing
9 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'astro': minor | ||
'@astrojs/markdown-remark': minor | ||
--- | ||
|
||
Makes remark-rehype options available in astro.config.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Astro Markdown without remark-rehype config', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/astro-markdown-remarkRehype/', | ||
}); | ||
await fixture.build(); | ||
}); | ||
it('Renders footnotes with default English labels', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
expect($('#footnote-label').text()).to.equal('Footnotes'); | ||
expect($('.data-footnote-backref').first().attr('aria-label')).to.equal('Back to content'); | ||
}); | ||
}); | ||
|
||
describe('Astro Markdown with remark-rehype config', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/astro-markdown-remarkRehype/', | ||
markdown: { | ||
remarkRehype: { | ||
footnoteLabel: 'Catatan kaki', | ||
footnoteBackLabel: 'Kembali ke konten', | ||
}, | ||
}, | ||
}); | ||
await fixture.build(); | ||
}); | ||
it('Renders footnotes with values from the configuration', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
expect($('#footnote-label').text()).to.equal('Catatan kaki'); | ||
expect($('.data-footnote-backref').first().attr('aria-label')).to.equal('Kembali ke konten'); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
packages/astro/test/fixtures/astro-markdown-remarkRehype/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@test/astro-markdown-remarkRehype", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/astro/test/fixtures/astro-markdown-remarkRehype/src/pages/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
foo: bar | ||
--- | ||
|
||
# Hello world | ||
|
||
This[^1] should be visible. | ||
|
||
[^1]: And there would be a footnote. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.