diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-02-05 09:35:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-05 09:35:20 -0400 |
commit | f71136f0a03d7f3c36651918af2dc18527dd47be (patch) | |
tree | 6df9bba79901eed7cc7d1f16eba0375a21f10280 /src/page | |
parent | f0af4edfa87e9518703b7c9ab35244911f0a3ac2 (diff) | |
parent | 7c668d5cc6a107b3613e6bc1ab20c9005590b3cf (diff) |
Merge pull request #152 from hsmusic/skeleton-support
Better support "skeleton" and minimal-content wikis
Diffstat (limited to 'src/page')
-rw-r--r-- | src/page/album.js | 8 | ||||
-rw-r--r-- | src/page/group.js | 25 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/page/album.js b/src/page/album.js index 1fc74520..80397065 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -53,7 +53,7 @@ export function write(album, {wikiData}) { const displayTrackGroups = album.trackGroups && (album.trackGroups.length > 1 || - !album.trackGroups[0].isDefaultTrackGroup); + !album.trackGroups[0]?.isDefaultTrackGroup); const listTag = getAlbumListTag(album); @@ -301,6 +301,7 @@ export function write(album, {wikiData}) { })), displayTrackGroups && + !empty(album.trackGroups) && html.tag('dl', {class: 'album-group-list'}, album.trackGroups.flatMap(({ @@ -323,6 +324,7 @@ export function write(album, {wikiData}) { ])), !displayTrackGroups && + !empty(album.tracks) && html.tag(listTag, album.tracks.map(trackToListItem)), @@ -759,6 +761,10 @@ export function generateAlbumNavLinks(album, currentTrack, { randomLink, ].filter(Boolean); + if (empty(allLinks)) { + return ''; + } + return `(${language.formatUnitList(allLinks)})`; } diff --git a/src/page/group.js b/src/page/group.js index 6bfd1532..f9af8e80 100644 --- a/src/page/group.js +++ b/src/page/group.js @@ -16,8 +16,7 @@ export function targets({wikiData}) { export function write(group, {wikiData}) { const {listingSpec, wikiInfo} = wikiData; - const {albums} = group; - const tracks = albums.flatMap((album) => album.tracks); + const tracks = group.albums.flatMap((album) => album.tracks); const totalDuration = getTotalDuration(tracks, {originalReleasesOnly: true}); const albumLines = group.albums.map((album) => ({ @@ -65,7 +64,7 @@ export function write(group, {wikiData}) { transformMultiline(group.description)), ...html.fragment( - group.albums && [ + !empty(group.albums) && [ html.tag('h2', {class: ['content-heading']}, language.$('groupInfoPage.albumList.title')), @@ -123,7 +122,7 @@ export function write(group, {wikiData}) { }), }; - const galleryPage = { + const galleryPage = !empty(group.albums) && { type: 'page', path: ['groupGallery', group.directory], page: ({ @@ -165,7 +164,7 @@ export function write(group, {wikiData}) { unit: true, })), albums: html.tag('b', - language.countAlbums(albums.length, { + language.countAlbums(group.albums.length, { unit: true, })), time: html.tag('b', @@ -222,7 +221,7 @@ export function write(group, {wikiData}) { }), }; - return [infoPage, galleryPage]; + return [infoPage, galleryPage].filter(Boolean); } // Utility functions @@ -240,8 +239,6 @@ function generateGroupSidebar(currentGroup, isGallery, { return null; } - const linkKey = isGallery ? 'groupGallery' : 'groupInfo'; - return { content: [ html.tag('h1', @@ -260,15 +257,21 @@ function generateGroupSidebar(currentGroup, isGallery, { category: `<span class="group-name">${category.name}</span>`, })), html.tag('ul', - category.groups.map((group) => - html.tag('li', + category.groups.map((group) => { + const linkKey = ( + isGallery && !empty(group.albums) + ? 'groupGallery' + : 'groupInfo'); + + return html.tag('li', { class: group === currentGroup && 'current', style: getLinkThemeString(group.color), }, language.$('groupSidebar.groupList.item', { group: link[linkKey](group), - })))), + })); + })), ])), ], }; |