-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: expose headings on layout props * test: frontmatter AND content * test: headings in layouts * chore: changeset
- Loading branch information
1 parent
7bc75a0
commit 2968ba2
Showing
5 changed files
with
52 additions
and
31 deletions.
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,5 @@ | ||
--- | ||
'@astrojs/mdx': minor | ||
--- | ||
|
||
Add `headings` and `frontmatter` properties to layout props |
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
16 changes: 13 additions & 3 deletions
16
packages/integrations/mdx/test/fixtures/mdx-frontmatter/src/layouts/Base.astro
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 |
---|---|---|
@@ -1,18 +1,28 @@ | ||
--- | ||
const { content = { title: "Didn't work" } } = Astro.props; | ||
const { | ||
content = { title: "content didn't work" }, | ||
frontmatter = { title: "frontmatter didn't work" }, | ||
headings = [], | ||
} = Astro.props; | ||
--- | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>{content.title}</title> | ||
</head> | ||
|
||
<body> | ||
<h1>{content.title}</h1> | ||
<p data-content-title>{content.title}</p> | ||
<p data-frontmatter-title>{frontmatter.title}</p> | ||
<p data-layout-rendered>Layout rendered!</p> | ||
<ul data-headings> | ||
{headings.map(heading => <li>{heading.slug}</li>)} | ||
</ul> | ||
<slot /> | ||
</body> | ||
|
||
</html> |
7 changes: 7 additions & 0 deletions
7
...ages/integrations/mdx/test/fixtures/mdx-frontmatter/src/pages/with-headings.mdx
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,7 @@ | ||
--- | ||
layout: '../layouts/Base.astro' | ||
--- | ||
|
||
## Section 1 | ||
|
||
## Section 2 |
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