Skip to content

Commit

Permalink
fix: Improved robustness of the site
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-coster committed Jul 10, 2023
1 parent 35e8f04 commit 11c2102
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/site/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@
</head>

<body>
%sveltekit.body%
<div style="display: contents">
%sveltekit.body%
</div>
</body>

</html>
30 changes: 26 additions & 4 deletions packages/site/src/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
export function toDateIso(date: string | Date) {
return new Date(date).toISOString();
function assert(condition: any, msg?: string): asserts condition {
if (!condition) {
throw new Error(msg);
}
}

export function toDateLocal(date: string | Date) {
return new Date(date).toLocaleDateString();
export function toDateIso(date: string | Date): string {
try {
const asDate = new Date(date);
assert(!isNaN(asDate.getTime()), 'Invalid date');
return asDate.toISOString();
} catch (err) {
console.error(err);
console.error(date);
}
return '';
}

export function toDateLocal(date: string | Date): string {
try {
const asDate = new Date(date);
assert(!isNaN(asDate.getTime()), 'Invalid date');
return asDate.toLocaleDateString();
} catch (err) {
console.error(err);
console.error(date);
}
return '';
}

export function saveProperty(name: string, value: any) {
Expand Down
2 changes: 1 addition & 1 deletion packages/site/src/routes/gamemaker/releases/+page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GameMakerReleaseWithNotes } from '@bscotch/gamemaker-releases';
import type { PageLoad } from './$types';

export const load = (async () => {
export const load = (async ({ fetch }) => {
const releases: GameMakerReleaseWithNotes[] = await (
await fetch('../artifacts/gamemaker/releases-summary.json')
).json();
Expand Down

0 comments on commit 11c2102

Please sign in to comment.