Friday | 29 MAR 2024
[ previous ]
[ next ]

Switching to SvelteKit for the Blog

Title:
Date: 2023-01-20
Tags:  

Spoiler: I don't switch anything.

I read the following blog and it is quite well written.

https://joshcollinsworth.com/blog/build-static-sveltekit-markdown-blog

As an introduction to sveltekit, it's great and it gave me the urge to switch my current blog to sveltekit. I was already thinking about switching to a server rendered site to get access to the backend logic. I could do searching and tagging on the fly as right now I generate html pages from markdown and shove them to the "cloud".

The blog goes over the various things, such as setting up sveltekit and what using the static adapter means. It goes over incorporating sass into the workflow. The key part that I cared about was that it used mdsvex to render the markdown to html. This package allows for svelte components to be used inside markdown files and it would compile the entire thing into an html page.

This would let you write markdown as svelte and with it all the power of svelte. You could make interactive components and do basically anything within the markdown file. It is quite cool but the downside is that you now lose markdown. The whole point of markdown in my eyes is to write so that you can use any tool to generate html. Once you add components to markdown, now you are hard locked to the svelte ecosystem.

So for me, mdsvex becomes just a regular rendering engine as I would stay away from the components stuff regardless of how cool it is.

The dynamic loading of markdown in the page.js is cool. It is an idea that I knew of but it's only seeing it in the blog post that I realized what it meant. I can load data from any file in page.js using an import statement. That is quite neat! I wonder why it is a page.js file and not a page.server.js though. I figured the client would not be able to access it properly but I'm guessing by nesting the markdown in the blog itself, it is being made accessible somewhere along the way.

I would keep my posts separate so I think I would need to use page.server.js to get the content loaded into the page.svelte.

I also currently create .html files as the final endpoints and I'm guessing that sveltekit would do away with that and I would need to hack it back in.

I'm also a fan of the idea that I can simply convert my markdown and toss it to the cloud without having to think about anything. There is no dev server to run or manage. There is nothing on the server I have to manage. All the blog is, is some html files and nginx.