Skip to content

Commit d7d6c20

Browse files
committed
Update to partially match #36's series list
1 parent 486b1df commit d7d6c20

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

src/series/getters.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ export const getSeriesDescription = (
6262
return description ? description.trim() : null;
6363
};
6464

65+
export const getSeriesNotes = ($seriesPage: SeriesPage): string | null => {
66+
const notes = $seriesPage("dl.series dd:nth-of-type(5)");
67+
console.log(notes.prevAll().first().text());
68+
if (notes.prevAll().first().text().trim() === "Notes:") {
69+
console.log("Yep");
70+
return notes.html().trim();
71+
} else {
72+
return null;
73+
}
74+
};
75+
6576
export const getSeriesPublishDate = ($seriesPage: SeriesPage): string => {
6677
return $seriesPage("dl.series > dd:nth-of-type(2)").text().trim();
6778
};

src/series/index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import {
55
getSeriesBookmarkCount,
66
getSeriesCompletionStatus,
77
getSeriesDescription,
8+
getSeriesNotes,
89
getSeriesPublishDate,
910
getSeriesTitle,
1011
getSeriesUpdateDate,
1112
getSeriesWordCount,
1213
getSeriesWorkCount,
1314
getSeriesWorks,
1415
} from "./getters";
16+
import { getWorkUrl } from "src/urls";
1517

1618
export const getSeries = async ({
1719
seriesId,
@@ -20,19 +22,22 @@ export const getSeries = async ({
2022
}): Promise<Series> => {
2123
const seriesPage = await loadSeriesPage(seriesId);
2224

25+
const seriesWorks = getSeriesWorks(seriesPage);
26+
2327
return {
2428
id: seriesId,
25-
title: getSeriesTitle(seriesPage),
29+
name: getSeriesTitle(seriesPage),
2630
begunAt: getSeriesPublishDate(seriesPage),
2731
updatedAt: getSeriesUpdateDate(seriesPage),
28-
authors: getSeriesAuthors(seriesPage),
32+
creators: getSeriesAuthors(seriesPage),
2933
description: getSeriesDescription(seriesPage),
34+
notes: getSeriesNotes(seriesPage),
3035
words: getSeriesWordCount(seriesPage),
31-
stats: {
32-
works: getSeriesWorkCount(seriesPage),
33-
bookmarks: getSeriesBookmarkCount(seriesPage),
34-
},
35-
completed: getSeriesCompletionStatus(seriesPage),
36-
works: getSeriesWorks(seriesPage),
36+
bookmarks: getSeriesBookmarkCount(seriesPage),
37+
complete: getSeriesCompletionStatus(seriesPage),
38+
workCount: getSeriesWorkCount(seriesPage),
39+
works: seriesWorks,
40+
workTitles: seriesWorks.map((work) => work.title),
41+
workUrls: seriesWorks.map((work) => getWorkUrl({ workId: work.id })),
3742
};
3843
};

types/entities.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,20 @@ export interface SeriesWorkSummary
4949

5050
export interface Series {
5151
id: string;
52-
title: string;
52+
name: string;
5353
begunAt: string;
5454
updatedAt: string;
55-
authors: WorkSummary["authors"];
55+
creators: WorkSummary["authors"];
5656
description: string | null;
57+
notes: string | null;
5758
words: number;
58-
stats: {
59-
works: number;
60-
bookmarks: number;
61-
};
62-
completed: boolean;
59+
bookmarks: number;
60+
complete: boolean;
6361

62+
workCount: number;
6463
works: SeriesWorkSummary[];
64+
workTitles: string[]
65+
workUrls: string[]
6566
}
6667

6768
export enum WorkRatings {

0 commit comments

Comments
 (0)