2 Commits

Author SHA1 Message Date
fb0629a58f more sitemap stuff
All checks were successful
deploy / deploy (push) Successful in 1m14s
2023-11-08 00:49:43 +00:00
7259ffb3de add comments in overlay page 2023-11-08 00:29:22 +00:00
2 changed files with 16 additions and 6 deletions

View File

@ -4,10 +4,11 @@ const { getCodeList } = require("country-list");
const SS_API_URL = ssrSettings.proxy + "/https://scoresaber.com/api"; const SS_API_URL = ssrSettings.proxy + "/https://scoresaber.com/api";
const SS_GET_PLAYERS_URL = SS_API_URL + "/players?page={}"; const SS_GET_PLAYERS_URL = SS_API_URL + "/players?page={}";
// todo: cache this somehow?
async function getTopPlayers() { async function getTopPlayers() {
console.log("Fetching top players..."); console.log("Fetching top players...");
const players = []; const players = [];
const pagesToFetch = 25; const pagesToFetch = 30;
for (let i = 0; i < pagesToFetch; i++) { for (let i = 0; i < pagesToFetch; i++) {
console.log(`Fetching page ${i + 1} of ${pagesToFetch}...`); console.log(`Fetching page ${i + 1} of ${pagesToFetch}...`);
const response = await fetch(SS_GET_PLAYERS_URL.replace("{}", i)); const response = await fetch(SS_GET_PLAYERS_URL.replace("{}", i));
@ -49,13 +50,19 @@ module.exports = {
} }
} }
const sortTypes = ["top", "recent"];
// Add top players // Add top players
const players = await getTopPlayers(); const players = await getTopPlayers();
for (const player of players) { for (const sortType of sortTypes) {
paths.push({ for (const player of players) {
loc: `/player/${player.id}/top/1`, for (let i = 0; i < 5; i++) {
...additionalData, paths.push({
}); loc: `/player/${player.id}/${sortType}/${i + 1}`,
...additionalData,
});
}
}
} }
return paths; return paths;

View File

@ -102,11 +102,13 @@ export default class Overlay extends Component<OverlayProps, OverlayState> {
render() { render() {
const { player, config, mounted } = this.state; const { player, config, mounted } = this.state;
// Redirect to builder if no config is set
if (mounted && !config) { if (mounted && !config) {
window.location.href = "/overlay/builder"; window.location.href = "/overlay/builder";
return null; return null;
} }
// Show loading screen if player stats are enabled and not loaded yet
if (!mounted || (!player && config.settings.showPlayerStats)) { if (!mounted || (!player && config.settings.showPlayerStats)) {
return ( return (
<main className="flex items-center !bg-transparent p-3"> <main className="flex items-center !bg-transparent p-3">
@ -116,6 +118,7 @@ export default class Overlay extends Component<OverlayProps, OverlayState> {
); );
} }
// The overlay
return ( return (
<main> <main>
<div> <div>