Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
13 changes: 11 additions & 2 deletions app/[[...path]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import {DocPage} from 'sentry-docs/components/docPage';
import {Home} from 'sentry-docs/components/home';
import {Include} from 'sentry-docs/components/include';
import {PlatformContent} from 'sentry-docs/components/platformContent';
import {getDocsRootNode, nodeForPath} from 'sentry-docs/docTree';
import {
getCurrentPlatformOrGuide,
getDocsRootNode,
nodeForPath,
} from 'sentry-docs/docTree';
import {getDocsFrontMatter, getFileBySlug} from 'sentry-docs/mdx';
import {mdxComponents} from 'sentry-docs/mdxComponents';
import {setServerContext} from 'sentry-docs/serverContext';
import {capitilize} from 'sentry-docs/utils';

export async function generateStaticParams() {
const docs = await getDocsFrontMatter();
Expand Down Expand Up @@ -112,10 +117,14 @@ export async function generateMetadata({params}: MetadataProps): Promise<Metadat
const images = [{url: `${domain}/meta.png`, width: 1200, height: 630}];

const rootNode = await getDocsRootNode();

if (rootNode && params.path) {
const pageNode = nodeForPath(rootNode, params.path);
if (pageNode) {
title = pageNode.frontmatter.title;
const guideOrPlatform = getCurrentPlatformOrGuide(rootNode, params.path);
title =
pageNode.frontmatter.title +
(guideOrPlatform ? ` | Sentry for ${capitilize(guideOrPlatform.name)}` : '');
description = pageNode.frontmatter.description;
}
}
Expand Down
15 changes: 13 additions & 2 deletions src/remark-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function remarkVariables(options) {

const scope = await options.resolveScopeData();

const interplolationError = new Error(`Failed to interpolate expression: "${expr}"`);
visit(
markdownAST,
() => true,
Expand All @@ -59,11 +60,21 @@ export default function remarkVariables(options) {
try {
result = scopedEval(expr, {...scope, page});
} catch (err) {
console.error(`Failed to interpolate expression: "${expr}"`);
console.error(interplolationError);
throw err;
}

node.value = node.value.replace(match[0], result);
if (result) {
node.value = node.value.replace(match[0], result);
} else {
// fail the build process in production
if (process.env.NODE_ENV === 'production') {
console.error(interplolationError);
// this is probably the only way to foce the build to fail
process.exit(1);
}
throw interplolationError;
}
});
}
);
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export function sortBy<A>(arr: A[], comp: (v: A) => number): A[] {
});
}

export const capitilize = (str: string) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};

type Page = {
context: {
sidebar_order?: number;
Expand Down