update share tweet text

This commit is contained in:
Aman Varshney
2025-06-01 23:20:32 +05:30
parent 1bec912d85
commit 9dbeea8983
2 changed files with 50 additions and 2 deletions

View File

@@ -12,6 +12,6 @@ export default defineConfig({
env: {
POSTHOG_API_KEY: "phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs",
POSTHOG_HOST: "https://us.i.posthog.com",
MODE: process.env.MODE || "dev",
MODE: process.env.MODE || "dev", // wierd trick i know
},
});

View File

@@ -968,8 +968,56 @@ const StackBuilder = () => {
};
const shareToTwitter = () => {
const getStackSummary = (): string => {
const selectedTechs: string[] = [];
for (const category of CATEGORY_ORDER) {
const categoryKey = category as keyof StackState;
const options = TECH_OPTIONS[category as keyof typeof TECH_OPTIONS];
const selectedValue = stack[categoryKey];
if (!options) continue;
if (Array.isArray(selectedValue)) {
if (
selectedValue.length === 0 ||
(selectedValue.length === 1 && selectedValue[0] === "none")
) {
continue;
}
for (const id of selectedValue) {
if (id === "none") continue;
const tech = options.find((opt) => opt.id === id);
if (tech) {
selectedTechs.push(tech.name);
}
}
} else {
const tech = options.find((opt) => opt.id === selectedValue);
if (
!tech ||
tech.id === "none" ||
tech.id === "false" ||
((category === "git" ||
category === "install" ||
category === "auth") &&
tech.id === "true")
) {
continue;
}
selectedTechs.push(tech.name);
}
}
return selectedTechs.length > 0
? selectedTechs.join(" • ")
: "Custom stack";
};
const stackSummary = getStackSummary();
const text = encodeURIComponent(
"Check out this cool tech stack I configured with Create Better T Stack!\n\n",
`Check out this cool tech stack I configured with Create Better T Stack!\n\n🚀 ${stackSummary}\n\n`,
);
if (typeof window !== "undefined") {
const url = encodeURIComponent(window.location.href);