Skip to content

Commit 0a954af

Browse files
committed
refactor: use the universal property extractor to get the title
1 parent 8edd425 commit 0a954af

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

source/client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { dump } from 'js-yaml';
1717
import got from 'got';
1818

1919
import { markdown } from '#markdown';
20+
import { getPropertyContent } from '#property';
2021

2122
import type { Got, OptionsOfJSONResponseBody, Response } from 'got';
2223
import type {
@@ -28,7 +29,6 @@ import type {
2829
FullPage,
2930
List,
3031
Page,
31-
TitleValue,
3232
} from './types';
3333

3434
interface Pagination extends Record<string, number | string | undefined> {
@@ -178,11 +178,10 @@ export class Notion {
178178
private async normalisePage(page: Page): Promise<FullPage> {
179179
const blocks = await this.getBlocks(page.id);
180180
// Name for a page in a database, title for an ordinary page
181-
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */
182-
const titleBlock = (page.properties.Name ??
183-
page.properties.title) as TitleValue;
184-
185-
const title = titleBlock.title.map((text) => text.plain_text).join('');
181+
const title = getPropertyContent(
182+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */
183+
page.properties.Name ?? page.properties.title,
184+
) as string;
186185
const frontmatter = [
187186
'---',
188187
dump(

0 commit comments

Comments
 (0)