Skip to content

Commit

Permalink
Merge pull request #35 from curvenote/feat/frontmatter-subject
Browse files Browse the repository at this point in the history
Front Matter - Subject
  • Loading branch information
Yxwww authored May 27, 2022
2 parents 637694d + 57162ec commit 6c58384
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/blocks/types/frontMatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type FrontMatterProps = {
open_access: boolean | null;
github: string | null;
binder: string | null;
subject: string | null;
subtitle: string | null;
short_title: string | null;
venue: { title?: string; url?: string } | null;
Expand All @@ -24,7 +25,7 @@ export type FrontMatterProps = {

export type BlockFrontMatterProps = Partial<FrontMatterProps>;

export type ProjectFrontMatterProps = Omit<BlockFrontMatterProps, 'venue' | 'biblio'>;
export type ProjectFrontMatterProps = Omit<BlockFrontMatterProps, 'venue' | 'biblio' | 'subtitle'>;

// Exhausiveness is ensured in test
export const PROJECT_FRONT_MATTER_KEYS = [
Expand All @@ -35,12 +36,13 @@ export const PROJECT_FRONT_MATTER_KEYS = [
'open_access',
'github',
'binder',
'subtitle',
'subject',
'short_title',
] as (keyof ProjectFrontMatterProps)[];

export const BLOCK_FRONT_MATTER_KEYS = [
...PROJECT_FRONT_MATTER_KEYS,
'venue',
'biblio',
'subtitle',
] as (keyof BlockFrontMatterProps)[];
4 changes: 2 additions & 2 deletions src/blocks/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const TEST_PROJECT_FRONT_MATTER: ProjectFrontMatterProps = {
open_access: false,
github: '',
binder: '',
subtitle: '',
short_title: '',
};

Expand Down Expand Up @@ -39,14 +38,15 @@ describe('extractBlockFrontMatter', () => {
arxiv: 'arxiv',
binder: 'binder',
subtitle: 'subtitle',
subject: 'subject',
short_title: '',
open_access: false,
venue: {},
biblio: {},
};

expect(extractBlockFrontMatter(frontmatter)).toEqual(frontmatter);
const { venue, biblio, ...projectExtractionResult } = frontmatter;
const { venue, biblio, subtitle, ...projectExtractionResult } = frontmatter;
expect(extractProjectFrontMatter(frontmatter)).toEqual(projectExtractionResult);
});

Expand Down

0 comments on commit 6c58384

Please sign in to comment.