Skip to content

Instantly share code, notes, and snippets.

@at-the-vr
Last active July 7, 2024 03:20
Show Gist options
  • Save at-the-vr/0804e66dec425df701f23f7b7be7a909 to your computer and use it in GitHub Desktop.
Save at-the-vr/0804e66dec425df701f23f7b7be7a909 to your computer and use it in GitHub Desktop.
Docs Issue #8692

Link: withastro/docs#8692

For 2nd Code Snippet - followed by So then I tried this, but that doesn't work either:

---
import type { MarkdownLayoutProps } from 'astro';

type LayoutProps = {
  title: string;
}

type CustomProps = MarkdownLayoutProps<LayoutProps> & LayoutProps; 
//notice union changed to intersection because TypeScript complains about `title` not existing

const { title } : CustomProps = Astro.props.frontmatter || Astro.props;
---
<html>
  <head></head>
  <body>
    <h1>{title}</h1>
    <slot />
  </body>
</html>

For 3rd Code Snippet - followed by Finally, I also tried:

Note

This is an exact replica of https://docs.astro.build/en/basics/layouts/#markdownmdx-layouts because Astro.props.frontmatter was giving a hard time

---
import type { MarkdownLayoutProps } from "astro";
type Props = MarkdownLayoutProps<{ title: string }>;
const { frontmatter } = Astro.props;
---

<html>
  <head>
  </head>
  <body>
    <h1>{frontmatter.title}</h1>
    <slot />
  </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment