Skip to content

Commit 4cfbfbe

Browse files
committed
import aliases
1 parent 017c595 commit 4cfbfbe

File tree

9 files changed

+117
-114
lines changed

9 files changed

+117
-114
lines changed

src/content/projects/partyPickle.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Party Pickle is one of my first JavaScript projects. Created as the final assign
1414

1515
You can feed your pickle, give him a drink or poke him so your pickle doesn't get mouldy. You can also bully your pickle by smashing the jar till it breaks.
1616

17-
import PartyPickel from '../../components/PartyPickel.svelte';
17+
import PartyPickel from '@components/PartyPickel.svelte';
1818

1919
<PartyPickel client:load></PartyPickel>

src/content/projects/tictactoe.mdx

+3-8
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ This project started as a JavaScript exercise and a way to challenge myself to g
1414

1515
Tic Tac Toe has 196839 (3^9) possible positions which might sound like a lot of ways to play the game. But for a computer, this number is quite low. It is quite easy to brute force your way through all the possible positions and calculate the best move from there.
1616

17-
18-
import TicTacToe from '../../components/TicTacToe.svelte'
17+
import TicTacToe from '@/components/TicTacToe.svelte';
1918

2019
<TicTacToe client:load></TicTacToe>
2120

@@ -26,10 +25,6 @@ Once a winning position is reached or all board squares are filled I evaluate th
2625

2726
Later I updated this project to include alpha-beta pruning. Once fully implemented this sped up the search for the best move by about 10 times, which is truly crazy. Alpha-beta pruning works by not having to examine game positions that are determined to be worse than a previously looked at move.
2827

29-
<IconLink
30-
href="https://github.com/Vuurvos1/tictactoe"
31-
target="_blank"
32-
icon="github"
33-
>
34-
{'Source'}
28+
<IconLink href="https://github.com/Vuurvos1/tictactoe" target="_blank" icon="github">
29+
{'Source'}
3530
</IconLink>

src/layouts/Layout.astro

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
import { ViewTransitions } from 'astro:transitions';
3-
import Footer from '../components/Footer.astro';
4-
import Header from '../components/Header.astro';
5-
import '../styles/main.postcss';
6-
import '../styles/base.css';
7-
import BaseHead from '../components/BaseHead.astro';
3+
import Footer from '@components/Footer.astro';
4+
import Header from '@components/Header.astro';
5+
import '@styles/main.postcss';
6+
import '@styles/base.css';
7+
import BaseHead from '@components/BaseHead.astro';
88
99
interface Props {
1010
title: string;
@@ -17,7 +17,7 @@ const { title, description, image, follow } = Astro.props;
1717
---
1818

1919
<!doctype html>
20-
<html lang="en">
20+
<html lang="en" transition:animate="none">
2121
<head>
2222
<meta charset="UTF-8" />
2323
<meta name="description" content="Astro description" />

src/pages/404.astro

+56-56
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import Layout from '../layouts/Layout.astro';
2+
import Layout from '@layouts/Layout.astro';
33
---
44

55
<Layout title="404 - Sam de Kanter" description="Page not found">
@@ -58,80 +58,80 @@ import Layout from '../layouts/Layout.astro';
5858
</Layout>
5959

6060
<script lang="ts">
61-
const canvas = document.querySelector('canvas');
61+
const canvas = document.querySelector('canvas');
6262

63-
let ctx;
63+
let ctx;
6464

65-
function random(a, b) {
66-
if (b === undefined) return Math.random() * a;
67-
return a + Math.random() * (b - a);
68-
}
65+
function random(a, b) {
66+
if (b === undefined) return Math.random() * a;
67+
return a + Math.random() * (b - a);
68+
}
6969

70-
function setCanvasSize() {
71-
if (ctx) {
72-
ctx.canvas.width = canvas.offsetWidth;
73-
ctx.canvas.height = canvas.offsetHeight;
74-
}
75-
}
70+
function setCanvasSize() {
71+
if (ctx) {
72+
ctx.canvas.width = canvas.offsetWidth;
73+
ctx.canvas.height = canvas.offsetHeight;
74+
}
75+
}
7676

77-
function goBack() {
78-
history.back();
79-
}
77+
function goBack() {
78+
history.back();
79+
}
8080

81-
document.querySelector('#backButton').addEventListener('click', goBack);
81+
document.querySelector('#backButton').addEventListener('click', goBack);
8282

83-
window.addEventListener('resize', setCanvasSize);
83+
window.addEventListener('resize', setCanvasSize);
8484

85-
ctx = canvas.getContext('2d');
85+
ctx = canvas.getContext('2d');
8686

87-
ctx.canvas.width = canvas.offsetWidth;
88-
ctx.canvas.height = canvas.offsetHeight;
87+
ctx.canvas.width = canvas.offsetWidth;
88+
ctx.canvas.height = canvas.offsetHeight;
8989

90-
const speed = { x: 2, y: 2 };
91-
const pos = {
92-
x: random(64, canvas.width - 64),
93-
y: random(64, canvas.height - 64)
94-
};
90+
const speed = { x: 2, y: 2 };
91+
const pos = {
92+
x: random(64, canvas.width - 64),
93+
y: random(64, canvas.height - 64)
94+
};
9595

96-
let frame = requestAnimationFrame(loop);
96+
let frame = requestAnimationFrame(loop);
9797

98-
function loop() {
99-
frame = requestAnimationFrame(loop);
98+
function loop() {
99+
frame = requestAnimationFrame(loop);
100100

101-
ctx.clearRect(0, 0, canvas.width, canvas.height);
101+
ctx.clearRect(0, 0, canvas.width, canvas.height);
102102

103-
pos.x += speed.x;
104-
pos.y += speed.y;
103+
pos.x += speed.x;
104+
pos.y += speed.y;
105105

106-
// collisions
107-
if (pos.x <= 32 || pos.x + 32 >= canvas.width) {
108-
speed.x *= -1;
109-
}
106+
// collisions
107+
if (pos.x <= 32 || pos.x + 32 >= canvas.width) {
108+
speed.x *= -1;
109+
}
110110

111-
if (pos.y <= 32 || pos.y + 28 >= canvas.height) {
112-
speed.y *= -1;
113-
}
111+
if (pos.y <= 32 || pos.y + 28 >= canvas.height) {
112+
speed.y *= -1;
113+
}
114114

115-
// oob
116-
if (pos.x < 0 || pos.x > canvas.width || pos.y < 0 || pos.y > canvas.height) {
117-
pos.x = canvas.width / 2;
118-
pos.y = canvas.height / 2;
119-
}
115+
// oob
116+
if (pos.x < 0 || pos.x > canvas.width || pos.y < 0 || pos.y > canvas.height) {
117+
pos.x = canvas.width / 2;
118+
pos.y = canvas.height / 2;
119+
}
120120

121-
// set size of the emoji and the font
122-
ctx.font = '64px Arial';
123-
// use these alignment properties for "better" positioning
124-
ctx.textAlign = 'center';
125-
ctx.textBaseline = 'middle';
121+
// set size of the emoji and the font
122+
ctx.font = '64px Arial';
123+
// use these alignment properties for "better" positioning
124+
ctx.textAlign = 'center';
125+
ctx.textBaseline = 'middle';
126126

127-
// draw the emoji
128-
ctx.fillText('🦝', pos.x, pos.y);
129-
}
127+
// draw the emoji
128+
ctx.fillText('🦝', pos.x, pos.y);
129+
}
130130

131-
// onUnmounted(() => {
132-
// window.removeEventListener(setCanvasSize);
133-
// cancelAnimationFrame(frame);
134-
// });
131+
// onUnmounted(() => {
132+
// window.removeEventListener(setCanvasSize);
133+
// cancelAnimationFrame(frame);
134+
// });
135135
</script>
136136

137137
<style lang="postcss">

src/pages/contact.astro

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
import Layout from '../layouts/Layout.astro';
3-
import Textarea from '../components/Textarea.astro';
4-
import TextInput from '../components/TextInput.astro';
2+
import Layout from '@layouts/Layout.astro';
3+
import Textarea from '@components/Textarea.astro';
4+
import TextInput from '@components/TextInput.astro';
55
66
const title = 'Contact';
77
const description = 'Where to find me on other platforms, or contact me if you have any questions';
@@ -87,47 +87,47 @@ const image = '/logo.png';
8787
</Layout>
8888

8989
<script lang="ts">
90-
let loading = false;
90+
let loading = false;
9191

92-
/**
93-
* @param {FormSubmitEvent} ev
94-
*/
95-
async function sendForm(ev) {
96-
ev.preventDefault();
97-
if (loading) return;
92+
/**
93+
* @param {FormSubmitEvent} ev
94+
*/
95+
async function sendForm(ev) {
96+
ev.preventDefault();
97+
if (loading) return;
9898

99-
const submitButton = document.querySelector('#submit');
100-
loading = true; // sending state
99+
const submitButton = document.querySelector('#submit');
100+
loading = true; // sending state
101101

102-
submitButton.style = '--offset: 1';
102+
submitButton.style = '--offset: 1';
103103

104-
// TODO: validate inputs
105-
// TODO: animate button text
104+
// TODO: validate inputs
105+
// TODO: animate button text
106106

107-
// send form data
108-
await fetch('https://getform.io/f/7269afe1-d68e-4ecd-9138-b939abb663dc', {
109-
method: 'POST',
110-
body: new URLSearchParams(new FormData(ev.target))
111-
});
107+
// send form data
108+
await fetch('https://getform.io/f/7269afe1-d68e-4ecd-9138-b939abb663dc', {
109+
method: 'POST',
110+
body: new URLSearchParams(new FormData(ev.target))
111+
});
112112

113-
submitButton.style = '--offset: 0';
113+
submitButton.style = '--offset: 0';
114114

115-
// done state
115+
// done state
116116

117-
// reset form values
118-
ev.target.reset();
117+
// reset form values
118+
ev.target.reset();
119119

120-
loading = false;
120+
loading = false;
121121

122-
setTimeout(() => {
123-
// clicked.value = false;
124-
submitButton.style = '--offset: 2';
125-
}, 3000);
122+
setTimeout(() => {
123+
// clicked.value = false;
124+
submitButton.style = '--offset: 2';
125+
}, 3000);
126126

127-
// reset state
128-
}
127+
// reset state
128+
}
129129

130-
document.querySelector('#form').addEventListener('submit', sendForm);
130+
document.querySelector('#form').addEventListener('submit', sendForm);
131131
</script>
132132

133133
<style lang="postcss">

src/pages/index.astro

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
import Layout from '../layouts/Layout.astro';
3-
import ProjectCard from '../components/ProjectCard.astro';
2+
import Layout from '@layouts/Layout.astro';
3+
import ProjectCard from '@components/ProjectCard.astro';
44
import { getCollection } from 'astro:content';
55
66
const posts = (await getCollection('projects'))

src/pages/projects/[...slug].astro

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
import { type CollectionEntry, getCollection } from 'astro:content';
3-
import IconLink from '../../components/IconLink.astro';
4-
import TechStack from '../../components/TechStack.astro';
5-
import Layout from '../../layouts/Layout.astro';
3+
import IconLink from '@components/IconLink.astro';
4+
import TechStack from '@components/TechStack.astro';
5+
import Layout from '@layouts/Layout.astro';
66
77
export async function getStaticPaths() {
88
const posts = await getCollection('projects');

src/pages/projects/index.astro

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
import ProjectCard from '../../components/ProjectCard.astro';
3-
import Layout from '../../layouts/Layout.astro';
2+
import ProjectCard from '@components/ProjectCard.astro';
3+
import Layout from '@layouts/Layout.astro';
44
import { getCollection } from 'astro:content';
55
66
// TODO add optional url filters?

tsconfig.json

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
2-
"extends": "astro/tsconfigs/strict",
3-
"compilerOptions": {
4-
"allowJs": true
5-
}
2+
"extends": "astro/tsconfigs/strict",
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"baseUrl": ".",
6+
"paths": {
7+
"@components/*": ["src/components/*"],
8+
"@assets/*": ["src/assets/*"],
9+
"@layouts/*": ["src/layouts/*"],
10+
"@styles/*": ["src/styles/*"],
11+
"@/*": ["src/*"]
12+
}
13+
}
614
}

0 commit comments

Comments
 (0)