From 5059c277d77d9d09e178166c23a2a364066c1d95 Mon Sep 17 00:00:00 2001 From: Hayk Martiros Date: Wed, 14 Dec 2022 23:24:18 -0800 Subject: [PATCH] Twitter card and metadata --- components/PageHead.tsx | 21 ++++++++++++++++++++- components/Share.tsx | 17 ++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/components/PageHead.tsx b/components/PageHead.tsx index 845fe38..2cc1bd2 100644 --- a/components/PageHead.tsx +++ b/components/PageHead.tsx @@ -4,10 +4,29 @@ export default function PageHead() { return ( Riffusion + + + + + + + + + + ); diff --git a/components/Share.tsx b/components/Share.tsx index 2a11659..a7411d5 100644 --- a/components/Share.tsx +++ b/components/Share.tsx @@ -174,6 +174,21 @@ export default function Share({ return `https://www.reddit.com/r/riffusion/submit?title=Prompt:+${encodedPrompt}&url=${encodedUrl}`; }, [nowPlayingResult, inferenceResults]); + const getTwitterLink = useCallback(() => { + if (inferenceResults.length == 0) { + return null; + } + + const result = nowPlayingResult ? nowPlayingResult : inferenceResults[0]; + + const encodedPrompt = encodeURIComponent(result.input.start.prompt); + const encodedUrl = encodeURIComponent(generateLink(0)); + + return `https://twitter.com/intent/tweet?&text=Check+out+this+prompt+on+%23riffusion:+${encodeURI( + '"' + )}${encodedPrompt}${encodeURI('"')}${encodeURI("\n\n")}${encodedUrl}`; + }, [nowPlayingResult, inferenceResults]); + return ( <>