Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

updated testimonials + static tweet component

Steven Tey161aa3808e06
diff --git a/components/home/testimonials.tsx b/components/home/testimonials.tsx
index 3d6cbda7fc..f1a78a40a1 100644
--- a/components/home/testimonials.tsx
+++ b/components/home/testimonials.tsx
@@ -26,11 +26,12 @@ export default function Testimonials({
{tweets.map((tweet, idx) => (
<Tweet
key={idx}
- id={idx.toString()}
metadata={JSON.stringify(tweet)}
className={
+ // this is a bit hacky but it allows us to have a 3-column mosaic layout on desktop
+ // it basically says "if the card is NOT in the middle column, push it down by 4rem
idx < Math.floor(tweets.length / 3) ||
- idx >= Math.floor(tweets.length / 3) * 2
+ idx >= Math.floor(tweets.length / 3) * 2 + 1
? "relative lg:top-16"
: ""
}
diff --git a/components/shared/tweet.tsx b/components/shared/tweet.tsx
index c56bc4d44f..f6933e7eca 100644
--- a/components/shared/tweet.tsx
+++ b/components/shared/tweet.tsx
@@ -21,11 +21,9 @@ function getRemainingTime(ISOString: Date) {
}
export default function Tweet({
- id,
metadata,
className,
}: {
- id: string;
metadata: any;
className?: string;
}) {
@@ -47,6 +45,7 @@ export default function Tweet({
const parsedMetadata = JSON.parse(metadata.replace(/\n/g, "\\n"));
+ const id = parsedMetadata.id;
const text = parsedMetadata.text;
const author = parsedMetadata.author;
const media = parsedMetadata.media;
@@ -65,6 +64,20 @@ export default function Tweet({
const createdAt = new Date(created_at);
const formattedText = text
+ // remove hyperlink if it's present at the end of the tweet (similar to how Twitter does it)
+ .replace(/https?:\/\/\S+$/, () => {
+ return "";
+ })
+ // format all hyperlinks
+ .replace(/https?:\/\/\S+(?=\s)/g, (match) => {
+ return `<a style="color: rgb(29,161,242); font-weight:normal; text-decoration: none" href="${match}" target="_blank">${match
+ .replace(/^https?:\/\//i, "")
+ .replace(/\/+$/, "")}</a>`;
+ })
+ // if @ mention is at the front of the tweet, remove it completely,
+ .replace(/^(@\w+\s+)+/, () => {
+ return "";
+ })
.replace(/\B\@([\w\-]+)/gim, (match) => {
// format all @ mentions
return `<a style="color: rgb(29,161,242); font-weight:normal; text-decoration: none" href="https://twitter.com/${match.replace(
@@ -319,7 +332,7 @@ export default function Tweet({
</div>
)}
{quoteTweet && quoteTweet.author && (
- <Tweet id={quoteTweet.id} metadata={JSON.stringify(quoteTweet)} />
+ <Tweet metadata={JSON.stringify(quoteTweet)} />
)}
</div>
diff --git a/lib/twitter/index.ts b/lib/twitter/index.ts
index c0ba80a7d3..858cb559f9 100644
--- a/lib/twitter/index.ts
+++ b/lib/twitter/index.ts
@@ -6,12 +6,13 @@ export default function getTweetsMetadata(ids: string[]) {
export const homepageTweets = [
"1574639172605816832",
+ "1631671657617059842",
"1573744854655533069",
- "1585994819146391553",
"1586745532386578433",
"1582956754425421825",
- "1580891783277395970",
"1581017931043196928",
- "1586262340949139456",
"1580479816071270401",
+ "1632125000386854912",
+ "1586262340949139456",
+ "1626946633207357440",
];