~phw/discourse-listenbrainz

543be1693612ed65c154d42f881cea59df781aff — Philipp Wolfer 10 months ago fb76936
Use buildMbidUrl helper also for artist credits
A assets/javascripts/discourse/components/listenbrainz-linked-artist.js => assets/javascripts/discourse/components/listenbrainz-linked-artist.js +13 -0
@@ 0,0 1,13 @@
import Component from '@glimmer/component'
import { buildMbidUrl } from '../lib/listenbrainz-utils'

export default class ListenbrainzLinkedArtistComponent extends Component {
    constructor(owner, args) {
        super(owner, args)
        this.credits = args.credits
    }

    get artistUrl() {
        return buildMbidUrl('artist', this.credits?.artist_mbid)
    }
}

M assets/javascripts/discourse/templates/components/listenbrainz-artist-credits.hbs => assets/javascripts/discourse/templates/components/listenbrainz-artist-credits.hbs +1 -6
@@ 1,8 1,3 @@
{{#each @artists as |c|~}}
    {{#if c.artist_mbid~}}
        <a href="https://listenbrainz.org/artist/{{c.artist_mbid}}"
            target="_blank">{{c.artist_credit_name}}</a>
    {{~else~}}
        {{c.artist_credit_name}}
    {{~/if}}{{c.join_phrase}}
    {{listenbrainz-linked-artist credits=c~}}{{c.join_phrase}}
{{~/each}}

A assets/javascripts/discourse/templates/components/listenbrainz-linked-artist.hbs => assets/javascripts/discourse/templates/components/listenbrainz-linked-artist.hbs +5 -0
@@ 0,0 1,5 @@
{{#if credits.artist_mbid~}}
<a href="{{artistUrl}}" target="_blank">{{credits.artist_credit_name}}</a>
{{~else~}}
{{credits.artist_credit_name}}
{{~/if}}