Skip to content

Commit c35f694

Browse files
feat: allow adding additional frontmatter via db config
this is useful e.g. to override layout of pages
1 parent 18fa16f commit c35f694

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

src/PageMeta.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Conventional selection of meta information about a Notion API page.
3+
* Made availabel as top-level frontmatter on rendered markdown pages
4+
*/
5+
export interface PageMeta {
6+
id: string;
7+
url: string;
8+
title: string;
9+
category: string;
10+
order?: number;
11+
layout?: string;
12+
}

src/PageProperties.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
export interface PageMeta {
2-
id: string;
3-
url: string;
4-
title: string;
5-
category: string;
6-
order?: number;
7-
}
1+
import { PageMeta } from "./PageMeta";
82

93
export interface PageProperties {
4+
/**
5+
* Meta information about a Notion API page
6+
*/
107
meta: PageMeta;
118

129
/**
1310
* A mapping of property object keys -> property values
1411
*/
1512
values: Record<string, any>;
16-
13+
1714
/**
1815
* A mapping of Notion API property names -> property object keys
1916
*/
2017
keys: Map<string, string>;
2118
}
22-
23-
export interface PagePropertiesWithMeta extends PageProperties {}
19+

src/PropertiesParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class PropertiesParser {
5959
title: title, // notion API always calls it name
6060
category: category,
6161
order: order,
62+
...config.additionalPageFrontmatter
6263
},
6364
values: properties,
6465
keys: this.sortKeys(config, keys),

src/RenderedPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PageMeta } from "./PageProperties";
1+
import { PageMeta } from "./PageMeta";
22

33
export interface RenderedPage {
44
file: string;

src/SyncConfig.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export interface DatabaseConfig {
4848

4949
skipMarkdownTable?: boolean;
5050

51+
/**
52+
* Add custom data to the page frontmatter
53+
*/
54+
additionalPageFrontmatter?: Record<string, any>;
55+
5156
/**
5257
* Configuration options for Notion API page properties
5358
*/

0 commit comments

Comments
 (0)