Add genre/special-specific URLs to share functionality

This commit is contained in:
Hördle Bot
2025-11-22 19:30:49 +01:00
parent 7fc1c2c201
commit 5d5a75a735
2 changed files with 15 additions and 2 deletions

View File

@@ -62,6 +62,7 @@ export default async function SpecialPage({ params }: PageProps) {
<Game <Game
dailyPuzzle={dailyPuzzle} dailyPuzzle={dailyPuzzle}
genre={decodedName} genre={decodedName}
isSpecial={true}
maxAttempts={dailyPuzzle?.maxAttempts} maxAttempts={dailyPuzzle?.maxAttempts}
unlockSteps={dailyPuzzle?.unlockSteps} unlockSteps={dailyPuzzle?.unlockSteps}
/> />

View File

@@ -17,13 +17,14 @@ interface GameProps {
coverImage: string | null; coverImage: string | null;
} | null; } | null;
genre?: string | null; genre?: string | null;
isSpecial?: boolean;
maxAttempts?: number; maxAttempts?: number;
unlockSteps?: number[]; unlockSteps?: number[];
} }
const DEFAULT_UNLOCK_STEPS = [2, 4, 7, 11, 16, 30, 60]; const DEFAULT_UNLOCK_STEPS = [2, 4, 7, 11, 16, 30, 60];
export default function Game({ dailyPuzzle, genre = null, maxAttempts = 7, unlockSteps = DEFAULT_UNLOCK_STEPS }: GameProps) { export default function Game({ dailyPuzzle, genre = null, isSpecial = false, maxAttempts = 7, unlockSteps = DEFAULT_UNLOCK_STEPS }: GameProps) {
const { gameState, statistics, addGuess } = useGameState(genre, maxAttempts); const { gameState, statistics, addGuess } = useGameState(genre, maxAttempts);
const [hasWon, setHasWon] = useState(false); const [hasWon, setHasWon] = useState(false);
const [hasLost, setHasLost] = useState(false); const [hasLost, setHasLost] = useState(false);
@@ -104,7 +105,18 @@ export default function Game({ dailyPuzzle, genre = null, maxAttempts = 7, unloc
const speaker = hasWon ? '🔉' : '🔇'; const speaker = hasWon ? '🔉' : '🔇';
const genreText = genre ? `Genre: ${genre}\n` : ''; const genreText = genre ? `Genre: ${genre}\n` : '';
const text = `Hördle #${dailyPuzzle.id}\n${genreText}\n${speaker}${emojiGrid}\n\n#Hördle #Music\n\nhttps://hoerdle.elpatron.me`;
// Generate URL with genre/special path
let shareUrl = 'https://hoerdle.elpatron.me';
if (genre) {
if (isSpecial) {
shareUrl += `/special/${encodeURIComponent(genre)}`;
} else {
shareUrl += `/${encodeURIComponent(genre)}`;
}
}
const text = `Hördle #${dailyPuzzle.id}\n${genreText}\n${speaker}${emojiGrid}\n\n#Hördle #Music\n\n${shareUrl}`;
// Fallback method for copying to clipboard // Fallback method for copying to clipboard
const textarea = document.createElement('textarea'); const textarea = document.createElement('textarea');