Skip to content

Commit

Permalink
read somewhere to stick to undefined instead of null
Browse files Browse the repository at this point in the history
  • Loading branch information
shyakadavis committed Jul 16, 2024
1 parent 6c2dbea commit 0c10ca0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/routes/footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
import { aside_items, type Link } from './sitemap';
function generate_prev_next_links(current_href: string): {
prev: Link | null;
next: Link | null;
prev: Link | undefined;
next: Link | undefined;
} {
const all_links: Link[] = Object.values(aside_items)
.flat()
.filter((link) => link.status !== 'soon');
const current_index = all_links.findIndex((link) => link.href === current_href);
if (current_index === -1) {
return { prev: null, next: null };
return { prev: undefined, next: undefined };
}
const prev = current_index > 0 ? all_links[current_index - 1] : null;
const next = current_index < all_links.length - 1 ? all_links[current_index + 1] : null;
const prev = current_index > 0 ? all_links[current_index - 1] : undefined;
const next = current_index < all_links.length - 1 ? all_links[current_index + 1] : undefined;
return { prev, next };
}
Expand Down

0 comments on commit 0c10ca0

Please sign in to comment.