Skip to content

Commit 6fadc77

Browse files
committed
fix: author and publisher info
1 parent b3c0faa commit 6fadc77

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

src/data/resource.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export interface Resource {
2323
| ['languages', 'javascript', 'clientWebFrameworks', ClientWebFramework]
2424
>;
2525
name: string;
26+
author?: Resource.Entity;
27+
authorOrg?: Resource.Entity;
28+
publisher?: Resource.Entity;
2629
type: Resource.Type;
2730
kidOriented?: boolean;
2831
description: string;
@@ -39,6 +42,10 @@ export interface OrganizedResourceCategory {
3942

4043
// tslint:disable-next-line:no-namespace
4144
export declare namespace Resource {
45+
interface Entity {
46+
name: string;
47+
url?: string;
48+
}
4249
namespace Price {
4350
type Type = 'membership' | 'each';
4451
type Frequency = 'once' | 'year' | 'month';

src/data/sites/video-course/frontend-masters.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,16 @@ const NORMALIZED_DATA: Resource[] = SCRAPED_DATA.map(raw => {
10101010
frequency: 'month',
10111011
type: 'membership',
10121012
},
1013+
author: {
1014+
name: raw.instructor.name,
1015+
},
1016+
authorOrg: {
1017+
name: raw.instructor.organization,
1018+
},
1019+
publisher: {
1020+
name: 'Frontend Masters',
1021+
url: 'https://frontendmasters.com',
1022+
},
10131023
platforms: ['web', 'ios', 'android'],
10141024
type: 'video-course',
10151025
categoryIds: detectCategories(raw),

src/format/site.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,28 @@ const mdSiteIcons = (site: Resource): string => {
4343
return icons.join('');
4444
};
4545

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

54+
const mdSiteDetails = (site: Resource): string => {
55+
const parts = [mdSiteIcons(site), site.description];
56+
if (site.author) {
57+
const authorParts: string[] = [entityString(site.author)];
58+
if (site.authorOrg) {
59+
authorParts.push(' (', entityString(site.authorOrg), ')');
60+
}
61+
if (site.publisher) {
62+
authorParts.push(' via ', entityString(site.publisher));
63+
}
64+
parts.push(`*${authorParts.join('')}*`);
65+
}
4966
if (parts.length > 0) {
50-
return ` - ${parts}`;
67+
return ` - ${parts.filter(Boolean).join(' - ')}`;
5168
}
5269
return '';
5370
};

0 commit comments

Comments
 (0)