@ -165,3 +165,8 @@ export const NostrNestsRegex = /nostrnests\.com\/[a-zA-Z0-9]+/i;
|
||||
* Magnet link parser
|
||||
*/
|
||||
export const MagnetRegex = /(magnet:[\S]+)/i;
|
||||
|
||||
/**
|
||||
* Wavlake embed regex
|
||||
*/
|
||||
export const WavlakeRegex = /player\.wavlake\.com\/(track)\/([.a-zA-Z0-9-]+)/;
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
TwitchRegex,
|
||||
AppleMusicRegex,
|
||||
NostrNestsRegex,
|
||||
WavlakeRegex,
|
||||
} from "Const";
|
||||
import { RootState } from "State/Store";
|
||||
import SoundCloudEmbed from "Element/SoundCloudEmded";
|
||||
@ -25,6 +26,7 @@ import { ProxyImg } from "Element/ProxyImg";
|
||||
import TwitchEmbed from "Element/TwitchEmbed";
|
||||
import AppleMusicEmbed from "Element/AppleMusicEmbed";
|
||||
import NostrNestsEmbed from "Element/NostrNestsEmbed";
|
||||
import WavlakeEmbed from "Element/WavlakeEmbed";
|
||||
|
||||
export default function HyperText({ link, creator }: { link: string; creator: HexKey }) {
|
||||
const pref = useSelector((s: RootState) => s.login.preferences);
|
||||
@ -70,6 +72,7 @@ export default function HyperText({ link, creator }: { link: string; creator: He
|
||||
const isTwitchLink = TwitchRegex.test(a);
|
||||
const isAppleMusicLink = AppleMusicRegex.test(a);
|
||||
const isNostrNestsLink = NostrNestsRegex.test(a);
|
||||
const isWavlakeLink = WavlakeRegex.test(a);
|
||||
const extension = FileExtensionRegex.test(url.pathname.toLowerCase()) && RegExp.$1;
|
||||
if (extension && !isAppleMusicLink) {
|
||||
switch (extension) {
|
||||
@ -144,6 +147,8 @@ export default function HyperText({ link, creator }: { link: string; creator: He
|
||||
</a>,
|
||||
<NostrNestsEmbed link={a} />,
|
||||
];
|
||||
} else if (isWavlakeLink) {
|
||||
return <WavlakeEmbed link={a} />;
|
||||
} else {
|
||||
return (
|
||||
<a href={a} onClick={e => e.stopPropagation()} target="_blank" rel="noreferrer" className="ext">
|
||||
|
16
packages/app/src/Element/WavlakeEmbed.tsx
Normal file
16
packages/app/src/Element/WavlakeEmbed.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
const WavlakeEmbed = ({ link }: { link: string }) => {
|
||||
const convertedUrl = link.replace(/\/(track)\/([a-zA-Z0-9]+)/, "/embed/$1/$2");
|
||||
|
||||
return (
|
||||
<iframe
|
||||
style={{ borderRadius: 12 }}
|
||||
src={convertedUrl}
|
||||
width="100%"
|
||||
height="360"
|
||||
frameBorder="0"
|
||||
allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
|
||||
loading="lazy"></iframe>
|
||||
);
|
||||
};
|
||||
|
||||
export default WavlakeEmbed;
|
Reference in New Issue
Block a user