mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-18 21:07:44 +03:00
Fix external link for artist page if LastFM is missinb but Musicbrainz is not (#2533)
* fix mbz link if lastfm does not exist * use lastfmUrl field * fix artist info undefined
This commit is contained in:
parent
9cefaf66a4
commit
7a858a2db3
@ -9,19 +9,11 @@ import config from '../config'
|
|||||||
|
|
||||||
const ArtistExternalLinks = ({ artistInfo, record }) => {
|
const ArtistExternalLinks = ({ artistInfo, record }) => {
|
||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
let links = []
|
|
||||||
let linkButtons = []
|
let linkButtons = []
|
||||||
const lastFMlink = artistInfo?.biography?.match(
|
const lastFMlink = artistInfo?.biography?.match(
|
||||||
/<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/
|
/<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/
|
||||||
)
|
)
|
||||||
|
|
||||||
if (lastFMlink) {
|
|
||||||
links.push(lastFMlink[2])
|
|
||||||
}
|
|
||||||
if (artistInfo && artistInfo.musicBrainzId) {
|
|
||||||
links.push(`https://musicbrainz.org/artist/${artistInfo.musicBrainzId}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const addLink = (url, title, icon) => {
|
const addLink = (url, title, icon) => {
|
||||||
const translatedTitle = translate(title)
|
const translatedTitle = translate(title)
|
||||||
const link = (
|
const link = (
|
||||||
@ -38,16 +30,24 @@ const ArtistExternalLinks = ({ artistInfo, record }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.lastFMEnabled) {
|
if (config.lastFMEnabled) {
|
||||||
addLink(
|
if (lastFMlink) {
|
||||||
links[0],
|
addLink(
|
||||||
'message.openIn.lastfm',
|
lastFMlink[2],
|
||||||
<ImLastfm2 className="lastfm-icon" />
|
'message.openIn.lastfm',
|
||||||
)
|
<ImLastfm2 className="lastfm-icon" />
|
||||||
|
)
|
||||||
|
} else if (artistInfo?.lastFmUrl) {
|
||||||
|
addLink(
|
||||||
|
artistInfo?.lastFmUrl,
|
||||||
|
'message.openIn.lastfm',
|
||||||
|
<ImLastfm2 className="lastfm-icon" />
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
artistInfo?.musicBrainzId &&
|
artistInfo?.musicBrainzId &&
|
||||||
addLink(
|
addLink(
|
||||||
links[1],
|
`https://musicbrainz.org/artist/${artistInfo.musicBrainzId}`,
|
||||||
'message.openIn.musicbrainz',
|
'message.openIn.musicbrainz',
|
||||||
<MusicBrainz className="musicbrainz-icon" />
|
<MusicBrainz className="musicbrainz-icon" />
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user