@rr0/cms 0.3.64 → 0.3.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,11 @@ export declare class PeopleDirectoryStep extends DirectoryStep {
14
14
  protected filter: PeopleFilter;
15
15
  constructor(name: string, rootDirs: string[], excludedDirs: string[], templateFileName: string, outputFunc: OutputFunc, config: FileWriteConfig, service: PeopleService, renderer: PeopleHtmlRenderer, filter?: PeopleFilter);
16
16
  protected processDirs(context: HtmlRR0Context, dirNames: string[]): Promise<void>;
17
+ /**
18
+ * An extra directory entry for another name the same people is known by (a pseudonym, a surname), pointing at that
19
+ * same people's page.
20
+ */
21
+ protected alsoKnownAs(people: People, name: string): People;
17
22
  protected toList(context: HtmlRR0Context, peopleList: People[], pseudoPeopleList: People[], allCountries: Set<CountryCode>, occupations: Set<Occupation>): HTMLUListElement;
18
23
  protected toListItem(context: HtmlRR0Context, people: People, pseudoPeopleList: People[], allCountries: Set<CountryCode>, occupations: Set<Occupation>): HTMLLIElement;
19
24
  }
@@ -24,17 +24,21 @@ export class PeopleDirectoryStep extends DirectoryStep {
24
24
  const outputPath = config.getOutputPath(context);
25
25
  const output = context.newOutput(outputPath);
26
26
  const pseudoPeopleList = peopleList.reduce((prevPeopleList, peopleInfo) => {
27
- var _a;
28
- if (((_a = peopleInfo.pseudonyms) === null || _a === void 0 ? void 0 : _a.length) > 0) {
29
- for (const pseudonym of peopleInfo.pseudonyms) {
30
- const pseudo = new People(peopleInfo.firstNames, peopleInfo.lastName, peopleInfo.pseudonyms, peopleInfo.occupations, peopleInfo.countries, peopleInfo.discredited, peopleInfo.gender, peopleInfo.id, peopleInfo.dirName, peopleInfo.image);
31
- pseudo.lastAndFirstName = pseudonym;
32
- prevPeopleList.push(pseudo);
27
+ for (const pseudonym of peopleInfo.pseudonyms || []) {
28
+ prevPeopleList.push(this.alsoKnownAs(peopleInfo, pseudonym));
29
+ }
30
+ return prevPeopleList;
31
+ }, []);
32
+ const surnamePeopleList = peopleList.reduce((prevPeopleList, peopleInfo) => {
33
+ const lastName = peopleInfo.lastName;
34
+ if (lastName) { // A surname alone would say nothing about who it belongs to
35
+ for (const surname of peopleInfo.surnames) {
36
+ prevPeopleList.push(this.alsoKnownAs(peopleInfo, `${surname} ${lastName}`));
33
37
  }
34
38
  }
35
39
  return prevPeopleList;
36
40
  }, []);
37
- peopleList = peopleList.concat(pseudoPeopleList).sort((p1, p2) => p1.lastAndFirstName.localeCompare(p2.lastAndFirstName));
41
+ peopleList = peopleList.concat(pseudoPeopleList, surnamePeopleList).sort((p1, p2) => p1.lastAndFirstName.localeCompare(p2.lastAndFirstName));
38
42
  const allCountries = new Set();
39
43
  const occupations = new Set();
40
44
  const ul = this.toList(context, peopleList, pseudoPeopleList, allCountries, occupations);
@@ -63,6 +67,15 @@ export class PeopleDirectoryStep extends DirectoryStep {
63
67
  }
64
68
  await this.outputFunc(context, output);
65
69
  }
70
+ /**
71
+ * An extra directory entry for another name the same people is known by (a pseudonym, a surname), pointing at that
72
+ * same people's page.
73
+ */
74
+ alsoKnownAs(people, name) {
75
+ const alias = new People(people.firstNames, people.lastName, people.pseudonyms, people.occupations, people.countries, people.discredited, people.gender, people.id, people.dirName, people.image);
76
+ alias.lastAndFirstName = name; // Which is both what the entry displays and where it sorts
77
+ return alias;
78
+ }
66
79
  toList(context, peopleList, pseudoPeopleList, allCountries, occupations) {
67
80
  const file = context.file;
68
81
  const listItems = peopleList.map(people => this.toListItem(context, people, pseudoPeopleList, allCountries, occupations));
@@ -10,7 +10,7 @@ export class PeopleHtmlRenderer {
10
10
  const classList = ["data-resolved", "people-resolved"];
11
11
  if (pseudoPeopleList.indexOf(people) >= 0 || people.pseudonyms.includes(content)) {
12
12
  classList.push("pseudonym");
13
- titles.push(`(pseudonyme de ${people.firstAndLastName})`);
13
+ titles.push(`(pseudonyme de ${people.titleOverride || people.firstAndLastName})`);
14
14
  }
15
15
  if (people.hoax) {
16
16
  classList.push("canular");
@@ -52,7 +52,7 @@ export class PeopleHtmlRenderer {
52
52
  titles.push(occupationMsg(gender));
53
53
  }
54
54
  }
55
- const text = content || people.lastAndFirstName || people.title;
55
+ const text = content || people.titleOverride || people.lastAndFirstName || people.title;
56
56
  const doc = context.file.document;
57
57
  const link = doc.createElement("a");
58
58
  link.innerHTML = text;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@rr0/cms",
3
3
  "type": "module",
4
4
  "author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
5
- "version": "0.3.64",
5
+ "version": "0.3.65",
6
6
  "description": "RR0 Content Management System (CMS)",
7
7
  "exports": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@javarome/fileutil": "^0.3.7",
33
33
  "@rr0/common": "^1.1.5",
34
- "@rr0/data": "^0.3.41",
34
+ "@rr0/data": "^0.3.43",
35
35
  "@rr0/lang": "^0.1.13",
36
36
  "@rr0/place": "^0.5.4",
37
37
  "@rr0/time": "^0.11.2",