diff --git a/package.json b/package.json index fb6377f..140b575 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ." }, "devDependencies": { - "@sveltejs/kit": "next", + "@sveltejs/kit": "^1.0.0-next.306", "@types/cookie": "^0.4.1", "@types/html-minifier": "^4.0.1", "@types/marked": "^4.0.0", diff --git a/src/app.css b/src/app.css index 7da8cc8..d5c2dbc 100644 --- a/src/app.css +++ b/src/app.css @@ -1,16 +1,18 @@ @import '$lib/atkinson-hyperlegible.css'; :root { - --background-color: #000; + --background-color: #010502; --background-color-alt: #111; --background-color-alt-2: #222; --background-color-alt-3: #333; - --text-color: #f0f0f0; + --text-color: #f7f4f4; --text-color-alt: #ddd; --text-color-alt-2: #bbb; --text-color-alt-3: #999; + --accent-color: #0dc7f9; + --text-font: 'Atkinson Hyperlegible'; } @@ -34,11 +36,16 @@ button { color: var(--text-color); font-size: inherit; border-radius: 0.25em; - padding: 0.1em 0.5em; + padding: 0.2em 0.6em; cursor: pointer; font-family: inherit; + box-shadow: 0 0.1em 0.2em #000; } p { margin-top: 0; } + +a { + color: var(--accent-color); +} diff --git a/src/hooks.ts b/src/hooks.ts deleted file mode 100644 index 2b1eb8a..0000000 --- a/src/hooks.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { minify } from 'html-minifier' -import type { Options } from 'html-minifier' -import { prerendering } from '$app/env' -import type { Handle } from '@sveltejs/kit' - -const minificationOptions: Options = { - collapseBooleanAttributes: true, - collapseWhitespace: true, - // conservativeCollapse: true, - decodeEntities: true, - html5: true, - ignoreCustomComments: [/^#/], - minifyCSS: true, - minifyJS: false, - removeAttributeQuotes: true, - removeComments: true, - removeOptionalTags: true, - removeRedundantAttributes: true, - removeScriptTypeAttributes: true, - removeStyleLinkTypeAttributes: true, - sortAttributes: true, - sortClassName: true, -} - -export const handle: Handle = async ({ request, resolve }) => { - const response = await resolve(request) - - if (prerendering && response.headers['content-type'] === 'text/html') { - response.body = minify(response.body?.toString() ?? '', minificationOptions) - } - - return response -} diff --git a/src/lib/BackAnchor.svelte b/src/lib/BackAnchor.svelte new file mode 100644 index 0000000..ecb67e1 --- /dev/null +++ b/src/lib/BackAnchor.svelte @@ -0,0 +1,12 @@ + + +← Back + + diff --git a/src/lib/PostPreview.svelte b/src/lib/PostPreview.svelte new file mode 100644 index 0000000..8c4b852 --- /dev/null +++ b/src/lib/PostPreview.svelte @@ -0,0 +1,33 @@ + + + +
+

{post.title}

+
{@html post.html}
+
+
+ + diff --git a/src/lib/blog.ts b/src/lib/blog.ts index d39cc3c..fc90181 100644 --- a/src/lib/blog.ts +++ b/src/lib/blog.ts @@ -18,7 +18,7 @@ async function doesBlogPostExist(slug: string) { } /** Checks whether an asset exists in a blog post */ -export async function doesAssetExist(postSlug: string, assetName: string) { +export async function doesAssetExist(postSlug: string, assetName: string): Promise { // return false if the blog post doesn't exist if (!(await doesBlogPostExist(postSlug))) return false @@ -32,7 +32,9 @@ export async function getPost(slug: string): Promise { if (!doesBlogPostExist(slug)) return null // ok the post exists, so we can safely read the md file - const postMarkdown = await fs.promises.readFile(path.join(postsDir, slug, 'index.md'), 'utf8') + const postMarkdown = ( + await fs.promises.readFile(path.join(postsDir, slug, 'index.md'), 'utf8') + ).replace(/\r\n/g, '\n') const [_, yamlMetadata = null, markdownContent = null] = postMarkdown.match(/^---\n([\w\W]+?)\n---\n([\w\W]+)$/) ?? [] diff --git a/src/posts/hello/index.md b/src/posts/hello/index.md deleted file mode 100644 index e5416f2..0000000 --- a/src/posts/hello/index.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: hello -published: 2021-11-18T15:58:39.082Z ---- - -Tempor id lorem sit velit. Amet labore tempor mollit ad dolore exercitation ipsum dolore ipsum nostrud nulla nulla. Tempor laboris laboris cillum voluptate commodo duis aliqua. Do deserunt irure dolor quis elit irure occaecat excepteur laboris ipsum pariatur nostrud. Enim duis nostrud enim quis reprehenderit sunt officia aliquip laboris non non tempor cupidatat. - -Id non reprehenderit velit ipsum anim. Incididunt tempor incididunt ut occaecat irure aliquip veniam. Nisi nisi sunt commodo esse eu. Ullamco nisi officia et exercitation lorem pariatur qui consectetur aliquip aliqua consectetur in irure mollit. Eiusmod sunt deserunt eu quis duis ipsum eu commodo. - -Eu tempor id esse reprehenderit laboris eu magna laboris veniam ullamco tempor commodo duis dolore minim cupidatat. Sint id proident laboris ullamco occaecat magna esse duis ex excepteur proident labore tempor pariatur minim occaecat adipisicing quis. Sint nisi deserunt aute pariatur pariatur enim pariatur culpa nostrud aute tempor amet eiusmod elit pariatur. Aute anim cupidatat voluptate ut mollit incididunt laborum duis mollit aute veniam minim esse ad ad nostrud cupidatat lorem. - -Voluptate incididunt ea consectetur eiusmod est sunt eu quis laboris duis officia laborum id deserunt commodo do veniam elit. Ullamco sunt esse aliqua eiusmod excepteur est nisi sit veniam aliquip laboris. Fugiat exercitation esse reprehenderit sint aute nostrud esse adipisicing ipsum laboris amet culpa. Sint ullamco cillum quis commodo aliquip aliqua do elit consequat aliqua duis proident anim adipisicing sit dolor anim veniam. diff --git a/src/posts/the-story-of-reportscammers/index.md b/src/posts/the-story-of-reportscammers/index.md index 2c1c9b5..e564ddc 100644 --- a/src/posts/the-story-of-reportscammers/index.md +++ b/src/posts/the-story-of-reportscammers/index.md @@ -13,8 +13,7 @@ It all started on April 27th, 2020. I was bored and wanted to make a Hypixel For # madcausebad11 I didn’t do anything with this idea until a couple weeks later on May 14th, when I remembered it, and was actually motivated to create it. I asked around on the SkyBlock Community Discord for what it should be called and what it should do, and I decided on calling it madcausebad11 (name chosen by @TatorCheese), and making it say “thats crazy but I dont remember asking” (@Bliziq chose that one) to all posts that mentioned being scammed. -.![Screenshot of a post on the Hypixel Forums where a user named madcausebad11 says "thats crazy but i dont remember asking"](https://lh3.googleusercontent.com/qHrXN2ZVQSXtJ8PgQyXm5R22eUPiayAkZKdwxPLKfRIk5hQdXfLCUon5t2mU_fM3fXrw8AROEk-E0UYhBqfmit9udhvcURqpJLnDKqLaMVDjovx3n0-fYb20RRlOTqTJYtMedr5l) -When that had been decided, I started working on the code. It was written in Python, using BeautifulSoup to scrape the web pages and aiohttp to make the requests. After an hour of writing code, madcausebad11 was working. +.![Screenshot of a post on the Hypixel Forums where a user named madcausebad11 says "thats crazy but i dont remember asking"](thats-crazy-but-i-dont-remember-asking.png) to make the requests. After an hour of writing code, madcausebad11 was working. Less than an hour after the bot started working, it got banned for the reason “spam”. diff --git a/src/posts/the-story-of-reportscammers/thats-crazy-but-i-dont-remember-asking.png b/src/posts/the-story-of-reportscammers/thats-crazy-but-i-dont-remember-asking.png new file mode 100644 index 0000000..a0ab62b Binary files /dev/null and b/src/posts/the-story-of-reportscammers/thats-crazy-but-i-dont-remember-asking.png differ diff --git a/src/posts/who-is-mat/favicon.png b/src/posts/who-is-mat/favicon.png new file mode 100644 index 0000000..c8e5a23 Binary files /dev/null and b/src/posts/who-is-mat/favicon.png differ diff --git a/src/posts/who-is-mat/index.md b/src/posts/who-is-mat/index.md index 887e74c..2eaea65 100644 --- a/src/posts/who-is-mat/index.md +++ b/src/posts/who-is-mat/index.md @@ -4,7 +4,7 @@ published: 2019-04-25T01:08:27.057+00:00 --- ||Welcome to mat does dev. You might have some questions, so I'm here to answer them.|| -![mat does dev](https://www.matdoes.dev/favicon.png) +![mat does dev](favicon.png) --- @@ -24,8 +24,9 @@ I make a variety of different tools, and you can see some of those things in [my I mainly use Python, as it's the language I'm most comfortable writing with. I'm also proficient with JavaScript, HTML, and CSS. I also know limited amounts of C++, C, Go, and Java. **How did you make this website?** +2022 update: This website was rewritten in Svelte. The backend for this website was written by me in pure [Python](https://www.python.org/) with beautiful asynchronous [aiohttp.web](https://github.com/aio-libs/aiohttp/) and [Jinja2](http://jinja.pocoo.org/). The frontend was made with [VanillaJS](http://vanilla-js.com) **How can I contact you?** -You can contact me through Discord (mat#6207). I'm not likely to accept friend requests though, so you'll have to contact me through servers I am in. +You can contact me through Discord (mat#1592). diff --git a/src/routes/__error.svelte b/src/routes/__error.svelte index dd67949..a316c7b 100644 --- a/src/routes/__error.svelte +++ b/src/routes/__error.svelte @@ -1,20 +1,19 @@
-

{status}

-

{message}

-
+

{status}

+

{message}

+
\ No newline at end of file + diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index 257a9d2..a3e8397 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -26,8 +26,11 @@ } main { - margin: 1em; + padding: 1em; + margin: auto; flex: 1 0; + max-width: 50em; + width: calc(100% - 2em); } footer { text-align: center; diff --git a/src/routes/blog/index.json.ts b/src/routes/blog/index.json.ts index 153b6fa..414fbf9 100644 --- a/src/routes/blog/index.json.ts +++ b/src/routes/blog/index.json.ts @@ -25,7 +25,13 @@ export const get: RequestHandler = async () => { return { title: blogPost.title, // cut it off after 255 characters because that's a nice number - html: markdownToHtml(blogPost.body.slice(0, 512), `/blog/post/${blogPost.slug}/index.md`), + html: markdownToHtml( + blogPost.body + .slice(0, 512) + .replace(/!\[[^\]]+?\]\([^)]+?\)/g, '') + .replace(/\[([^\]]+?)\]\([^)]+?\)/g, '$1'), + `/blog/post/${blogPost.slug}/index.md` + ), slug: blogPost.slug, } }) diff --git a/src/routes/blog/index.svelte b/src/routes/blog/index.svelte index 7c20c49..04c8240 100644 --- a/src/routes/blog/index.svelte +++ b/src/routes/blog/index.svelte @@ -17,37 +17,18 @@
+ + {#each posts as post} - -
-

{post.title}

-
{@html post.html}
-
-
+ {/each}
- - diff --git a/src/routes/blog/post/[slug].svelte b/src/routes/blog/post/[slug].svelte index 5170209..b0234a4 100644 --- a/src/routes/blog/post/[slug].svelte +++ b/src/routes/blog/post/[slug].svelte @@ -3,13 +3,15 @@ import type { Load } from '@sveltejs/kit' export const prerender = true - // export const router = false - export const load: Load = async ({ page, fetch }) => { - const slug: string = page.params.slug ?? '' + export const load: Load = async ({ params, fetch }) => { + const slug: string = params.slug ?? '' const resp = await fetch(`/blog/post/${slug}.json`) - if (resp.status === 404) return + if (resp.status === 404) + return { + status: 404, + } const body: APIBlogPost = await resp.json() @@ -23,13 +25,15 @@

{title}

@@ -38,16 +42,6 @@