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>