Skip to content

Commit

Permalink
content: generate{Artist,Group}InfoPage: alias links
Browse files Browse the repository at this point in the history
  • Loading branch information
towerofnix committed Nov 17, 2024
1 parent 0d74914 commit 1b38561
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 70 deletions.
87 changes: 56 additions & 31 deletions src/content/dependencies/generateArtistInfoPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export default {
hasGallery:
!empty(artist.albumCoverArtistContributions) ||
!empty(artist.trackCoverArtistContributions),

aliasLinkedGroups:
artist.closelyLinkedGroups
.filter(({annotation}) =>
annotation === 'alias'),

generalLinkedGroups:
artist.closelyLinkedGroups
.filter(({annotation}) =>
annotation !== 'alias'),
}),

relations: (relation, query, artist) => ({
Expand All @@ -70,7 +80,12 @@ export default {
relation('transformContent', artist.contextNotes),

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

aliasGroupLinks:
query.aliasLinkedGroups
.map(({thing: group}) =>
relation('linkGroup', group)),

Expand Down Expand Up @@ -118,7 +133,7 @@ export default {
: null),

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

totalTrackCount:
Expand Down Expand Up @@ -158,36 +173,46 @@ export default {

html.tag('p',
{[html.onlyIfContent]: true},
{[html.joinChildren]: html.tag('br')},

language.encapsulate(pageCapsule, 'closelyLinkedGroups', capsule => [
language.encapsulate(capsule, 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);
}))),
});
}),

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);
}))),
});
})),
language.$(capsule, 'alias', {
[language.onlyIfOptions]: ['groups'],

groups:
language.formatConjunctionList(relations.aliasGroupLinks),
}),
])),

html.tag('p',
{[html.onlyIfContent]: true},
Expand Down
109 changes: 70 additions & 39 deletions src/content/dependencies/generateGroupInfoPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ export default {
wikiInfo.color,
}),

relations: (relation, sprawl, group) => ({
query: (_sprawl, group) => ({
aliasLinkedArtists:
group.closelyLinkedArtists
.filter(({annotation}) =>
annotation === 'alias'),

generalLinkedArtists:
group.closelyLinkedArtists
.filter(({annotation}) =>
annotation !== 'alias'),
}),

relations: (relation, query, sprawl, group) => ({
layout:
relation('generatePageLayout'),

Expand All @@ -44,7 +56,12 @@ export default {
relation('generateColorStyleAttribute', sprawl.wikiColor),

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

aliasArtistLinks:
query.aliasLinkedArtists
.map(({thing: artist}) =>
relation('linkArtist', artist)),

Expand All @@ -59,15 +76,15 @@ export default {
relation('generateGroupInfoPageAlbumsSection', group),
}),

data: (_sprawl, group) => ({
data: (query, _sprawl, group) => ({
name:
group.name,

color:
group.color,

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

Expand All @@ -81,41 +98,55 @@ export default {
mainContent: [
html.tag('p',
{[html.onlyIfContent]: true},

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

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

return language.$(workingCapsule, {
[option]:
language.formatUnitList(
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);
}))),
});
})),
{[html.joinChildren]: html.tag('br')},

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

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

return language.$(workingCapsule, {
[option]:
language.formatUnitList(
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);
}))),
});
}),

language.$(capsule, 'aliases', {
[language.onlyIfOptions]: ['aliases'],

aliases:
language.formatConjunctionList(
relations.aliasArtistLinks.map(link =>
link.slots({
attributes: [relations.wikiColorAttribute],
}))),
}),
])),

html.tag('p',
{[html.onlyIfContent]: true},
Expand Down
4 changes: 4 additions & 0 deletions src/strings-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,8 @@ artistPage:
_: "{GROUP}"
withAnnotation: "{GROUP} ({ANNOTATION})"

alias: "This artist is an alias of {GROUPS}."

creditList:

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

aliases: "View alias pages: {ALIASES}."

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

0 comments on commit 1b38561

Please sign in to comment.