feat(ssr): add song sub name to youtube link
All checks were successful
deploy / deploy (push) Successful in 1m11s
All checks were successful
deploy / deploy (push) Successful in 1m11s
This commit is contained in:
parent
ef7c6f4878
commit
925e423955
@ -153,6 +153,7 @@ export default function Score({
|
|||||||
<Link
|
<Link
|
||||||
href={`${songNameToYouTubeLink(
|
href={`${songNameToYouTubeLink(
|
||||||
leaderboard.songName,
|
leaderboard.songName,
|
||||||
|
leaderboard.songSubName,
|
||||||
leaderboard.songAuthorName,
|
leaderboard.songAuthorName,
|
||||||
)}`}
|
)}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
@ -53,14 +53,25 @@ export function scoresaberDifficultyNumberToName(
|
|||||||
* Turns a song name and author into a YouTube link
|
* Turns a song name and author into a YouTube link
|
||||||
*
|
*
|
||||||
* @param name the name of the song
|
* @param name the name of the song
|
||||||
|
* @param songSubName the sub name of the song
|
||||||
* @param author the author of the song
|
* @param author the author of the song
|
||||||
* @returns the YouTube link for the song
|
* @returns the YouTube link for the song
|
||||||
*/
|
*/
|
||||||
export function songNameToYouTubeLink(name: string, author: string) {
|
export function songNameToYouTubeLink(
|
||||||
return encodeURI(
|
name: string,
|
||||||
`https://www.youtube.com/results?search_query=${name} ${author}`.replaceAll(
|
songSubName: string,
|
||||||
" ",
|
author: string,
|
||||||
"+",
|
) {
|
||||||
),
|
const baseUrl = "https://www.youtube.com/results?search_query=";
|
||||||
);
|
let query = "";
|
||||||
|
if (name) {
|
||||||
|
query += `${name} `;
|
||||||
|
}
|
||||||
|
if (songSubName) {
|
||||||
|
query += `${songSubName} `;
|
||||||
|
}
|
||||||
|
if (author) {
|
||||||
|
query += `${author} `;
|
||||||
|
}
|
||||||
|
return encodeURI(baseUrl + query.trim().replaceAll(" ", "+"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user