Skip to content

Commit

Permalink
Rename commentary field on GithubRepo to exposition
Browse files Browse the repository at this point in the history
  • Loading branch information
jerboa88 committed Jul 29, 2024
1 parent c6e91f7 commit e56637f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 28 deletions.
10 changes: 5 additions & 5 deletions src/common/gatsby-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,10 @@ type GithubRepo = Node & {
readonly children: ReadonlyArray<Node>;
/** Returns all children nodes filtered by type MarkdownRemark */
readonly childrenMarkdownRemark: Maybe<ReadonlyArray<Maybe<MarkdownRemark>>>;
readonly commentary: Maybe<Scalars['String']>;
readonly createdAt: Scalars['Date'];
readonly description: Scalars['String'];
readonly descriptionHtml: Maybe<Scalars['String']>;
readonly exposition: Maybe<Scalars['String']>;
readonly forkCount: Scalars['Int'];
readonly homepageUrl: Maybe<Scalars['String']>;
readonly id: Scalars['ID'];
Expand Down Expand Up @@ -1456,10 +1456,10 @@ type GithubRepoFieldSelector = {
readonly childMarkdownRemark: InputMaybe<MarkdownRemarkFieldSelector>;
readonly children: InputMaybe<NodeFieldSelector>;
readonly childrenMarkdownRemark: InputMaybe<MarkdownRemarkFieldSelector>;
readonly commentary: InputMaybe<FieldSelectorEnum>;
readonly createdAt: InputMaybe<FieldSelectorEnum>;
readonly description: InputMaybe<FieldSelectorEnum>;
readonly descriptionHtml: InputMaybe<FieldSelectorEnum>;
readonly exposition: InputMaybe<FieldSelectorEnum>;
readonly forkCount: InputMaybe<FieldSelectorEnum>;
readonly homepageUrl: InputMaybe<FieldSelectorEnum>;
readonly id: InputMaybe<FieldSelectorEnum>;
Expand All @@ -1485,10 +1485,10 @@ type GithubRepoFilterInput = {
readonly childMarkdownRemark: InputMaybe<MarkdownRemarkFilterInput>;
readonly children: InputMaybe<NodeFilterListInput>;
readonly childrenMarkdownRemark: InputMaybe<MarkdownRemarkFilterListInput>;
readonly commentary: InputMaybe<StringQueryOperatorInput>;
readonly createdAt: InputMaybe<DateQueryOperatorInput>;
readonly description: InputMaybe<StringQueryOperatorInput>;
readonly descriptionHtml: InputMaybe<StringQueryOperatorInput>;
readonly exposition: InputMaybe<StringQueryOperatorInput>;
readonly forkCount: InputMaybe<IntQueryOperatorInput>;
readonly homepageUrl: InputMaybe<StringQueryOperatorInput>;
readonly id: InputMaybe<StringQueryOperatorInput>;
Expand Down Expand Up @@ -1555,10 +1555,10 @@ type GithubRepoSortInput = {
readonly childMarkdownRemark: InputMaybe<MarkdownRemarkSortInput>;
readonly children: InputMaybe<NodeSortInput>;
readonly childrenMarkdownRemark: InputMaybe<MarkdownRemarkSortInput>;
readonly commentary: InputMaybe<SortOrderEnum>;
readonly createdAt: InputMaybe<SortOrderEnum>;
readonly description: InputMaybe<SortOrderEnum>;
readonly descriptionHtml: InputMaybe<SortOrderEnum>;
readonly exposition: InputMaybe<SortOrderEnum>;
readonly forkCount: InputMaybe<SortOrderEnum>;
readonly homepageUrl: InputMaybe<SortOrderEnum>;
readonly id: InputMaybe<SortOrderEnum>;
Expand Down Expand Up @@ -2181,10 +2181,10 @@ type Query_githubRepoArgs = {
childMarkdownRemark: InputMaybe<MarkdownRemarkFilterInput>;
children: InputMaybe<NodeFilterListInput>;
childrenMarkdownRemark: InputMaybe<MarkdownRemarkFilterListInput>;
commentary: InputMaybe<StringQueryOperatorInput>;
createdAt: InputMaybe<DateQueryOperatorInput>;
description: InputMaybe<StringQueryOperatorInput>;
descriptionHtml: InputMaybe<StringQueryOperatorInput>;
exposition: InputMaybe<StringQueryOperatorInput>;
forkCount: InputMaybe<IntQueryOperatorInput>;
homepageUrl: InputMaybe<StringQueryOperatorInput>;
id: InputMaybe<StringQueryOperatorInput>;
Expand Down
2 changes: 1 addition & 1 deletion src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ export type GithubReposConfig = {

// GitHub repo fields used to create a GithubRepo node
export type GithubRepo = {
commentary: string | null;
createdAt: Date;
description: string;
descriptionHtml: string | null;
exposition: string | null;
forkCount: number;
homepageUrl: string | null;
isFork: boolean;
Expand Down
14 changes: 5 additions & 9 deletions src/components/resume-project-entries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-------------------------------------------
*/

import type { SentenceString } from '../common/types';
import { toSentence } from '../common/utils';
import { ResumeEntry } from './resume-entry';

Expand All @@ -15,13 +14,10 @@ export function ResumeProjectEntries({ githubRepos }: Props) {
return (
<div className="flex flex-col gap-4">
{githubRepos.map((githubRepo) => {
const descriptionSentences: SentenceString[] = [
toSentence(githubRepo.description),
];

if (githubRepo.commentary) {
descriptionSentences.push(toSentence(githubRepo.commentary));
}
const expositionSentence = githubRepo.exposition
? toSentence(githubRepo.exposition)
: null;
const descriptionSentence = toSentence(githubRepo.description);

return (
<ResumeEntry
Expand All @@ -30,7 +26,7 @@ export function ResumeProjectEntries({ githubRepos }: Props) {
titleUrl={githubRepo.url}
titleTooltip="View project on GitHub"
tagline={githubRepo.languages.join(', ')}
bullets={[descriptionSentences.join(' ') as SentenceString]}
bullets={[expositionSentence ?? descriptionSentence]}
endDate={new Date(githubRepo.createdAt)}
/>
);
Expand Down
22 changes: 11 additions & 11 deletions src/node/github-response-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { group, groupEnd, info, panic, warn } from './logger';

type ParseReadmeDescriptionReturnValue = {
descriptionHtml: string | null;
commentary: string | null;
exposition: string | null;
};

type TransformReadmeReturnValue = ParseReadmeDescriptionReturnValue & {
Expand Down Expand Up @@ -68,26 +68,26 @@ function parseReadmeName(
return null;
}

// Extract a project's commentary and description from its README
// Extract a project's exposition and description from its README
function parseReadmeDescription(
fragment: DocumentFragment,
): ParseReadmeDescriptionReturnValue {
const descriptionElement = fragment.querySelector('.projectDesc');
const descriptionHtml = descriptionElement?.innerHTML?.trim() ?? null;
const commentary =
descriptionElement?.getAttribute('data-commentary')?.trim() ?? null;
const exposition =
descriptionElement?.getAttribute('data-exposition')?.trim() ?? null;

if (!isDefined(descriptionHtml)) {
warn('README description not found');
}

if (!isDefined(commentary)) {
warn('README commentary not found');
if (!isDefined(exposition)) {
warn('README exposition not found');
}

return {
descriptionHtml,
commentary,
exposition,
};
}

Expand Down Expand Up @@ -147,19 +147,19 @@ function transformReadme(
return {
name: null,
descriptionHtml: null,
commentary: null,
exposition: null,
logoUrl: null,
type: null,
};
}

const fragment = JSDOM.fragment(readmeResponse.text);
const { descriptionHtml, commentary } = parseReadmeDescription(fragment);
const { descriptionHtml, exposition } = parseReadmeDescription(fragment);

return {
name: parseReadmeName(fragment),
descriptionHtml,
commentary,
exposition,
logoUrl: parseReadmeLogoUrl(slug, owner, fragment),
type: parseReadmeType(fragment),
};
Expand Down Expand Up @@ -271,7 +271,7 @@ function transformGithubRepoNode(
const description: string = githubRepoNode.description as string;

const githubRepo = {
commentary: readmeInfo.commentary,
exposition: readmeInfo.exposition,
createdAt: createdAt,
description: description,
descriptionHtml: readmeInfo.descriptionHtml,
Expand Down
4 changes: 2 additions & 2 deletions src/node/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ Define schema for custom GithubRepo nodes
"""
type GithubRepo implements Node {
childMarkdownRemark: MarkdownRemark
commentary: String
createdAt: Date!
description: String!
descriptionHtml: String
exposition: String
forkCount: Int!
homepageUrl: String
isFork: Boolean!
Expand All @@ -91,10 +91,10 @@ query GithubRepos {
childMarkdownRemark {
html
}
commentary
createdAt
description
descriptionHtml
exposition
forkCount
homepageUrl
isFork
Expand Down

0 comments on commit e56637f

Please sign in to comment.