Skip to content

Commit 9836b4e

Browse files
committed
feat: add withGenerals option to getDocument, fixed og image for homepage
1 parent 8f44b96 commit 9836b4e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

apps/website/src/app/api/docs/og/route.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export async function GET(request: Request) {
2727
const docData = getDocument({
2828
folder: folder,
2929
document: document,
30+
withGenerals: true,
3031
});
3132

3233
if (!docData) {

apps/website/src/utils/docs.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Doc = Document &
2828
interface GetDocument {
2929
folder: string;
3030
document: string;
31+
withGenerals?: boolean;
3132
}
3233

3334
const normalizePath = (path: string): string => {
@@ -42,12 +43,19 @@ const allDocs = allDocsArray.filter(
4243
),
4344
);
4445

45-
const getDocument = ({ folder, document }: GetDocument): Doc | undefined => {
46+
const getDocument = ({
47+
folder,
48+
document,
49+
withGenerals,
50+
}: GetDocument): Doc | undefined => {
4651
const normalizedDocument = normalizePath(document);
4752
const doc = allDocs.find((doc) => {
4853
const normalizedPath = normalizePath(doc._meta.path);
4954
return doc.folder === folder && normalizedPath === normalizedDocument;
5055
});
56+
if (!doc && withGenerals) {
57+
return getGeneralDocument(document);
58+
}
5159
if (!doc) {
5260
return undefined;
5361
}

0 commit comments

Comments
 (0)