Skip to content

Commit

Permalink
data, content: closely linked artist annotations
Browse files Browse the repository at this point in the history
Basic implementation only here, nothing custom for particular
annotations for example.
  • Loading branch information
towerofnix committed Nov 17, 2024
1 parent 6bcbe4f commit 0d74914
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 26 deletions.
49 changes: 36 additions & 13 deletions src/content/dependencies/generateArtistInfoPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {empty, unique} from '#sugar';
import {empty, stitchArrays, unique} from '#sugar';

export default {
contentDependencies: [
Expand Down Expand Up @@ -71,7 +71,8 @@ export default {

closeGroupLinks:
artist.closelyLinkedGroups
.map(group => relation('linkGroup', group)),
.map(({thing: group}) =>
relation('linkGroup', group)),

visitLinks:
artist.urls
Expand Down Expand Up @@ -116,6 +117,10 @@ export default {
? artist.avatarFileExtension
: null),

closeGroupAnnotations:
artist.closelyLinkedGroups
.map(({annotation}) => annotation),

totalTrackCount:
query.allTracks.length,

Expand Down Expand Up @@ -154,17 +159,35 @@ export default {
html.tag('p',
{[html.onlyIfContent]: true},

language.encapsulate(pageCapsule, 'closelyLinkedGroups', capsule =>
(relations.closeGroupLinks.length === 0
? html.blank()
: relations.closeGroupLinks.length === 1
? language.$(capsule, 'one', {
group: relations.closeGroupLinks,
})
: language.$(capsule, 'multiple', {
groups:
language.formatUnitList(relations.closeGroupLinks),
})))),
language.encapsulate(pageCapsule, 'closelyLinkedGroups', capsule => {
const [workingCapsule, option] =
(relations.closeGroupLinks.length === 0
? [null, null]
: relations.closeGroupLinks.length === 1
? [language.encapsulate(capsule, 'one'), 'group']
: [language.encapsulate(capsule, 'multiple'), 'groups']);

if (!workingCapsule) return html.blank();

return language.$(workingCapsule, {
[option]:
language.formatUnitList(
stitchArrays({
link: relations.closeGroupLinks,
annotation: data.closeGroupAnnotations,
}).map(({link, annotation}) =>
language.encapsulate(capsule, 'group', workingCapsule => {
const workingOptions = {group: link};

if (annotation) {
workingCapsule += '.withAnnotation';
workingOptions.annotation = annotation;
}

return language.$(workingCapsule, workingOptions);
}))),
});
})),

html.tag('p',
{[html.onlyIfContent]: true},
Expand Down
39 changes: 30 additions & 9 deletions src/content/dependencies/generateGroupInfoPage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {stitchArrays} from '#sugar';

export default {
contentDependencies: [
'generateColorStyleAttribute',
Expand Down Expand Up @@ -43,7 +45,8 @@ export default {

closeArtistLinks:
group.closelyLinkedArtists
.map(artist => relation('linkArtist', artist)),
.map(({thing: artist}) =>
relation('linkArtist', artist)),

visitLinks:
group.urls
Expand All @@ -62,6 +65,10 @@ export default {

color:
group.color,

closeArtistAnnotations:
group.closelyLinkedArtists
.map(({annotation}) => annotation),
}),

generate: (data, relations, {html, language}) =>
Expand All @@ -76,23 +83,37 @@ export default {
{[html.onlyIfContent]: true},

language.encapsulate(pageCapsule, 'closelyLinkedArtists', capsule => {
let option;
[capsule, option] =
const [workingCapsule, option] =
(relations.closeArtistLinks.length === 0
? [null, null]
: relations.closeArtistLinks.length === 1
? [language.encapsulate(capsule, 'one'), 'artist']
: [language.encapsulate(capsule, 'multiple'), 'artists']);

if (!capsule) return html.blank();
if (!workingCapsule) return html.blank();

return language.$(capsule, {
return language.$(workingCapsule, {
[option]:
language.formatUnitList(
relations.closeArtistLinks
.map(link => link.slots({
attributes: [relations.wikiColorAttribute],
}))),
stitchArrays({
link: relations.closeArtistLinks,
annotation: data.closeArtistAnnotations,
}).map(({link, annotation}) =>
language.encapsulate(capsule, 'artist', workingCapsule => {
const workingOptions = {};

workingOptions.artist =
link.slots({
attributes: [relations.wikiColorAttribute],
});

if (annotation) {
workingCapsule += '.withAnnotation';
workingOptions.annotation = annotation;
}

return language.$(workingCapsule, workingOptions);
}))),
});
})),

Expand Down
3 changes: 2 additions & 1 deletion src/data/things/artist.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
fileExtension,
flag,
name,
reverseAnnotatedReferenceList,
reverseContributionList,
reverseReferenceList,
singleReference,
Expand Down Expand Up @@ -139,7 +140,7 @@ export class Artist extends Thing {
list: input.value('commentatorArtists'),
}),

closelyLinkedGroups: reverseReferenceList({
closelyLinkedGroups: reverseAnnotatedReferenceList({
data: 'groupData',
list: input.value('closelyLinkedArtists'),
}),
Expand Down
10 changes: 7 additions & 3 deletions src/data/things/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ export const GROUP_DATA_FILE = 'groups.yaml';
import {input} from '#composite';
import find from '#find';
import Thing from '#thing';
import {parseSerieses} from '#yaml';
import {parseAnnotatedReferences, parseSerieses} from '#yaml';

import {
annotatedReferenceList,
color,
contentString,
directory,
Expand All @@ -29,7 +30,7 @@ export class Group extends Thing {

urls: urls(),

closelyLinkedArtists: referenceList({
closelyLinkedArtists: annotatedReferenceList({
class: input.value(Artist),
find: input.value(find.artist),
data: 'artistData',
Expand Down Expand Up @@ -120,7 +121,10 @@ export class Group extends Thing {
'Description': {property: 'description'},
'URLs': {property: 'urls'},

'Closely Linked Artists': {property: 'closelyLinkedArtists'},
'Closely Linked Artists': {
property: 'closelyLinkedArtists',
transform: parseAnnotatedReferences,
},

'Featured Albums': {property: 'featuredAlbums'},

Expand Down
8 changes: 8 additions & 0 deletions src/strings-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,10 @@ artistPage:
one: "This artist has a group page: {GROUP}."
multiple: "This artist has group pages: {GROUPS}."

group:
_: "{GROUP}"
withAnnotation: "{GROUP} ({ANNOTATION})"

creditList:

# album:
Expand Down Expand Up @@ -1314,6 +1318,10 @@ groupInfoPage:
one: "View artist page: {ARTIST}."
multiple: "View artist pages: {ARTISTS}."

artist:
_: "{ARTIST}"
withAnnotation: "{ARTIST} ({ANNOTATION})"

viewAlbumGallery:
_: >-
View {LINK}! Or browse the list:
Expand Down

0 comments on commit 0d74914

Please sign in to comment.