Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public/mdx-images/*
public/og-images/*
!public/og-images/README.md

# Ignore LLM plans
/docs/plans/

# yalc
.yalc
yalc.lock
Expand Down
62 changes: 48 additions & 14 deletions app/[[...path]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {Home} from 'sentry-docs/components/home';
import {Include} from 'sentry-docs/components/include';
import {PageLoadMetrics} from 'sentry-docs/components/pageLoadMetrics';
import {PlatformContent} from 'sentry-docs/components/platformContent';
import {SpecChangelog} from 'sentry-docs/components/specChangelog';
import {isSpecStatus} from 'sentry-docs/components/specConstants';
import {SpecMeta} from 'sentry-docs/components/specMeta';
import {
DocNode,
getCurrentPlatformOrGuide,
Expand Down Expand Up @@ -47,23 +50,54 @@ export async function generateStaticParams() {
export const dynamicParams = false;
export const dynamic = 'force-static';

const mdxComponentsWithWrapper = mdxComponents(
{Include, PlatformContent},
({children, frontMatter, nextPage, previousPage}) => (
<DocPage
frontMatter={frontMatter}
nextPage={nextPage}
previousPage={previousPage}
fullWidth={frontMatter.fullWidth}
>
{children}
</DocPage>
)
);
function mdxComponentsForFrontMatter(frontMatter: Record<string, unknown>) {
const specOverrides: Record<string, unknown> = {};
const changelog = Array.isArray(frontMatter.spec_changelog)
? (frontMatter.spec_changelog as Array<Record<string, unknown>>).map(entry => ({
version: String(entry.version),
date:
entry.date instanceof Date
? entry.date.toISOString().split('T')[0]
: String(entry.date),
summary: String(entry.summary),
}))
Comment thread
sentry[bot] marked this conversation as resolved.
Outdated
: undefined;
if (changelog) {
specOverrides.SpecChangelog = function () {
return <SpecChangelog changelog={changelog} />;
};
}
if (frontMatter.spec_version && isSpecStatus(frontMatter.spec_status)) {
const boundProps = {
version: String(frontMatter.spec_version),
status: frontMatter.spec_status,
};
specOverrides.SpecMeta = function () {
return <SpecMeta {...boundProps} />;
};
}
return mdxComponents(
{Include, PlatformContent, ...specOverrides},
({children, frontMatter: fm, nextPage, previousPage}) => (
<DocPage
frontMatter={fm}
nextPage={nextPage}
previousPage={previousPage}
fullWidth={fm.fullWidth}
>
{children}
</DocPage>
)
);
}

function MDXLayoutRenderer({mdxSource, ...rest}) {
const MDXLayout = useMemo(() => getMDXComponent(mdxSource), [mdxSource]);
return <MDXLayout components={mdxComponentsWithWrapper} {...rest} />;
const components = useMemo(
() => mdxComponentsForFrontMatter(rest.frontMatter || {}),
[rest.frontMatter]
);
return <MDXLayout components={components} {...rest} />;
}

export default async function Page(props: {params: Promise<{path?: string[]}>}) {
Expand Down
Loading
Loading