refactor: adjust HTML mention microformat
Adjust the federated HTML microformat to the one that is documented at <https://docs.joinmastodon.org/spec/microformats/>, namely adding the missing surrounding tag with the class `h-card`.
This commit is contained in:
parent
f119914b98
commit
4f2a9f8911
1 changed files with 6 additions and 1 deletions
|
@ -106,13 +106,18 @@ export function toHtml(nodes: mfm.MfmNode[] | null, mentionedRemoteUsers: IMenti
|
|||
},
|
||||
|
||||
mention(node) {
|
||||
// Mastodon microformat: span.h-card > a.u-url.mention
|
||||
const a = doc.createElement('a');
|
||||
const { username, host, acct } = node.props;
|
||||
const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host);
|
||||
a.href = remoteUserInfo?.url ?? remoteUserInfo?.uri ?? `${config.url}/${acct}`;
|
||||
a.className = 'u-url mention';
|
||||
a.textContent = acct;
|
||||
return a;
|
||||
|
||||
const card = doc.createElement('span');
|
||||
card.className = 'h-card';
|
||||
card.appendChild(a);
|
||||
return card;
|
||||
},
|
||||
|
||||
quote(node) {
|
||||
|
|
Loading…
Reference in a new issue