Skip to content

Commit

Permalink
fix: author and publisher info
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-north committed Sep 1, 2018
1 parent b3c0faa commit 6fadc77
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/data/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export interface Resource {
| ['languages', 'javascript', 'clientWebFrameworks', ClientWebFramework]
>;
name: string;
author?: Resource.Entity;
authorOrg?: Resource.Entity;
publisher?: Resource.Entity;
type: Resource.Type;
kidOriented?: boolean;
description: string;
Expand All @@ -39,6 +42,10 @@ export interface OrganizedResourceCategory {

// tslint:disable-next-line:no-namespace
export declare namespace Resource {
interface Entity {
name: string;
url?: string;
}
namespace Price {
type Type = 'membership' | 'each';
type Frequency = 'once' | 'year' | 'month';
Expand Down
10 changes: 10 additions & 0 deletions src/data/sites/video-course/frontend-masters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,16 @@ const NORMALIZED_DATA: Resource[] = SCRAPED_DATA.map(raw => {
frequency: 'month',
type: 'membership',
},
author: {
name: raw.instructor.name,
},
authorOrg: {
name: raw.instructor.organization,
},
publisher: {
name: 'Frontend Masters',
url: 'https://frontendmasters.com',
},
platforms: ['web', 'ios', 'android'],
type: 'video-course',
categoryIds: detectCategories(raw),
Expand Down
23 changes: 20 additions & 3 deletions src/format/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,28 @@ const mdSiteIcons = (site: Resource): string => {
return icons.join('');
};

const mdSiteDetails = (site: Resource): string => {
const parts = [mdSiteIcons(site), site.description].filter(Boolean).join(' - ');
const entityString: (e: Resource.Entity) => string = e => {
if (!e.url) {
return e.name;
} else {
return `[${e.name}](${e.url})`;
}
};

const mdSiteDetails = (site: Resource): string => {
const parts = [mdSiteIcons(site), site.description];
if (site.author) {
const authorParts: string[] = [entityString(site.author)];
if (site.authorOrg) {
authorParts.push(' (', entityString(site.authorOrg), ')');
}
if (site.publisher) {
authorParts.push(' via ', entityString(site.publisher));
}
parts.push(`*${authorParts.join('')}*`);
}
if (parts.length > 0) {
return ` - ${parts}`;
return ` - ${parts.filter(Boolean).join(' - ')}`;
}
return '';
};
Expand Down

0 comments on commit 6fadc77

Please sign in to comment.