Add Apple Music embed

This commit is contained in:
Sam Samskies
2023-02-13 21:12:15 -06:00
parent 37ef874dc6
commit 68b5d9efcb
4 changed files with 29 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import {
MixCloudRegex,
SpotifyRegex,
TwitchRegex,
AppleMusicRegex,
} from "Const";
import { RootState } from "State/Store";
import SoundCloudEmbed from "Element/SoundCloudEmded";
@ -20,6 +21,7 @@ import TidalEmbed from "Element/TidalEmbed";
import { ProxyImg } from "Element/ProxyImg";
import { HexKey } from "Nostr";
import TwitchEmbed from "./TwitchEmbed";
import AppleMusicEmbed from "./AppleMusicEmbed";
export default function HyperText({ link, creator }: { link: string; creator: HexKey }) {
const pref = useSelector((s: RootState) => s.login.preferences);
@ -46,8 +48,9 @@ export default function HyperText({ link, creator }: { link: string; creator: He
const mixcloudId = MixCloudRegex.test(a) && RegExp.$1;
const spotifyId = SpotifyRegex.test(a);
const twitchId = TwitchRegex.test(a);
const appleMusicId = AppleMusicRegex.test(a);
const extension = FileExtensionRegex.test(url.pathname.toLowerCase()) && RegExp.$1;
if (extension) {
if (extension && !appleMusicId) {
switch (extension) {
case "gif":
case "jpg":
@ -114,6 +117,8 @@ export default function HyperText({ link, creator }: { link: string; creator: He
return <SpotifyEmbed link={a} />;
} else if (twitchId) {
return <TwitchEmbed link={a} />;
} else if (appleMusicId) {
return <AppleMusicEmbed link={a} />;
} else {
return (
<a href={a} onClick={e => e.stopPropagation()} target="_blank" rel="noreferrer" className="ext">