Skip to content

Commit a975bb8

Browse files
committed
Fix title
1 parent 31ed35c commit a975bb8

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/remotes/notion/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,16 @@ export default async function createNotionSchema(token) {
124124
}
125125

126126
const fetchId = id || parentCache[parentSlug].find(p => p.slug === slug)?.id;
127-
if (!fetchId) return null;
127+
if (!fetchId) throw new Error('Page not found');
128128

129129
const allowedPages = Object.values(parentCache).flat().map(p => p.id.replace(/-/g, ''));
130130
if (!allowedPages.includes(fetchId.replace(/-/g, ''))) {
131-
return null;
131+
throw new Error ('Not allowed to fetch page');
132132
}
133133

134134
const title = (await notionClient.pages.retrieve({ page_id: fetchId }))
135-
.properties?.Title?.title?.[0]?.plain_text;
135+
.properties?.title?.title?.[0]?.plain_text || '';
136+
136137
const content = n2m.toMarkdownString(await n2m.pageToMarkdown(fetchId)).parent;
137138
return {
138139
title,

src/remotes/notion/schema.gql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type Query {
2-
page(id: String, parentSlug: String, slug: String): Page
2+
page(id: String, parentSlug: String, slug: String): Page!
33
pages(parentSlug: String!): [PageInfo!]!
44
parentSlugs: [String]!
55
}

0 commit comments

Comments
 (0)