1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
export default {
contentDependencies: [
'linkAlbumCommentary',
'linkAlbumGallery',
'linkAlbum',
],
extraDependencies: ['html', 'pagePath'],
relations: (relation, album) => ({
galleryLink:
relation('linkAlbumGallery', album),
infoLink:
relation('linkAlbum', album),
commentaryLink:
relation('linkAlbumCommentary', album),
}),
data: (album) => ({
albumDirectory:
album.directory,
albumHasCommentary:
!!album.commentary,
}),
slots: {
linkCommentaryPages: {
type: 'boolean',
default: false,
},
},
generate: (data, relations, slots, {pagePath}) =>
// When linking to an album *from* an album commentary page,
// if the link is to the *same* album, then the effective target
// of the link is really the album's commentary, so scroll to it.
(pagePath[0] === 'albumCommentary' &&
pagePath[1] === data.albumDirectory &&
data.albumHasCommentary
? relations.infoLink.slots({
anchor: true,
hash: 'album-commentary',
})
// When linking to *another* album from an album commentary page,
// the target is (by default) still just the album (its info page).
// But this can be customized per-link!
: pagePath[0] === 'albumCommentary' &&
slots.linkCommentaryPages
? relations.commentaryLink
: pagePath[0] === 'albumGallery'
? relations.galleryLink
: relations.infoLink),
};
|