September 25th, 2024

How I Built My Blog

Josh W. Comeau has rebuilt his blog with a new tech stack, including Next.js and MDX, involving over 100,000 lines of code, while enhancing user experience and styling with Linaria.

Read original articleLink Icon
How I Built My Blog

Josh W. Comeau has recently rebuilt his blog, transitioning to a new tech stack while maintaining a similar design. The blog now runs on Next.js v15.0.0, React v19.0.0, and MDX v3.0.1, among other technologies. The migration involved over 100,000 lines of code and was both challenging and educational. Comeau emphasizes the importance of MDX for creating interactive content, allowing him to integrate custom React components seamlessly. He also discusses the switch from the older Pages Router to the new App Router in Next.js, which offers a reimagined approach to routing and rendering. The blog's styling has shifted from styled-components to Linaria, a CSS-in-JS library that compiles to CSS modules, although Comeau notes some challenges with its integration. He expresses excitement about future CSS tools like Pigment CSS. Additionally, he highlights the advantages of using Shiki for syntax highlighting, which does not add to the JavaScript bundle size and supports a wide range of languages. Overall, Comeau's blog rebuild reflects a commitment to leveraging modern technologies while enhancing the user experience.

- Josh W. Comeau has rebuilt his blog using a new tech stack, including Next.js and MDX.

- The migration process involved over 100,000 lines of code and was educational for Comeau.

- The blog now uses Linaria for styling, moving away from styled-components.

- Shiki is utilized for syntax highlighting, offering advantages in bundle size and language support.

- The transition to the App Router in Next.js represents a significant change in routing and rendering.

Link Icon 20 comments
By @pxtail - 7 months
For homepage I got frozen page and: page is not responsive / page is slowing down browser message from both Firefox and Chrome - I guess all that cutting-edge tech for displaying the blog really loves giving my CPU a workout.
By @dzonga - 7 months
this is the self-destructive behaviour that's prevalent in the JS ecosystem.

say a newbie wants to develop a website or web app and they run into this. The amount of tools listed is overwhelming, even for me who's been doing JS for over 7 years.

and the sad thing is JS can be pretty productive, without the merchants of complexity shilling their tools.

Express.js v5 just got released. Thanks doug & other maintainers. Yet the API has been stable for over 10 years. Vue.js even with the new composition Api - the api has been stable for a long time. & other useful node libraries like 'pg' etc.

The only recent useful thing is tailwind.

Next.js / Nest.js etc are all complex tools that are completely unnecessary and shilled by dev-tools companies

By @blenderob - 7 months
I appreciate the author sharing technical details about how they build their blog. I do.

However I'd like ask the HN community here to share some examples of really simple blogs? Those that do not take building Rube Goldberg machines to publish the blogs. Perhaps those where the posts are just simple HTMLs. I'll take slapping a header and footer with some scripting or SSIs. But that's about it. Do you know any such simple examples of blogs? I think such blogs are under-appreciated and should be highlighted more often on HN.

By @keybits - 7 months
> Over the years, my blog has become a surprisingly complex application. It’s over 100,000 lines of code, not counting the content.

When I read this my reaction was "that's ridiculous!" But the author is a skilled and experienced web developer. The rich educational interactivity on their site shows that achieving that level of presentational finesse doesn't come easily.

By @alin23 - 7 months
Something in the runtime JS is really slowing down the page.

Here's a demo video with scrolling after the page has loaded (really choppy) and scrolling after stopping the JS with Firefox's slow-script-detection-thingy (smooth): https://files.alinpanaitiu.com/joshwcomeau-slow-scroll_2.mp4

The code seems to enter a tight loop here whenever I'm scrolling: https://files.alinpanaitiu.com/joshwcomeau-debug-script.png

By @michaelfm1211 - 7 months
No one needs 100,000 LOC for a blog. A while back I wrote a blog generator for myself that took one markdown file per post and a template and turned it into a directory of static HTML files. The whole thing is 46 lines of shell script. The only dependency is a markdown parser.
By @todotask - 7 months
I wanted to say, the OP home page hang my Firefox browser, probably due to issues with JavaScript regexp or React code.
By @indigodaddy - 7 months
Slow as molasses on my extremely aging iPhone 7, but I guess that’s to be expected
By @jrhey - 7 months
Scrolling down from the top of homepage is pretty choppy on my M3 Max in Safari
By @paranoidxprod - 7 months
Josh has some really cool content on his site. The demos inlined within his posts are always top notch. His flexbox/grid articles are the most intuitive explanations of those layouts I've seen.
By @bestest - 7 months
Josh really does have a lot of nice and shiny stuff. But Josh should also learn to optimise. Downloading 7MB of stuff for minimally interactive above-the-fold content is overkill.
By @mazzystar - 7 months
Keep blog simple will make it's easier to generate raw idea.

I just made a new opensource project named TinyMind: https://github.com/mazzzystar/tinymind

Which allows you to create your blog page in 1 minutes and share to anyone.

It's non-profitable, just for hobby and helping most people who don't want stuck in Hexo/Hugo or code.

By @meiraleal - 7 months
I'm going to follow this thread just to know how successful "I built my own blog" posts still do in HN. I expect it to not attract that much attention anymore?
By @ClaraForm - 7 months
Crashed on scrolling for me on latest Librewolf stable/Fedora 40. I usually love Josh's work, but this isn't it.
By @koririn - 7 months
This was a lovely blogpost. I think as software engineers we've lost a lot of the enthusiasm that used to be prevalent amongst the profession 5-10 years back. He mentions it himself you don't necessarily need all of this for a blog. I still enjoyed the tour. It's a nice blog and his content is usually well written and easy to follow.
By @ploum - 7 months
When I read the blog was 10.000 lines of code and there was a long list of busswordesques technologies implied, I thought this was a parody.

Reading that it crashes or eat the CPU for some people, I still believe it somewhat is. It also displays very badly on my own Firefox (with very recent computer).

And I could not find a list of all posts.

I mean… My own blog is a 500 lines python script without any external dependency. It has 42 lines of CSS. And it is all contained, content included, in one git repository. It has a list of all the blog posts you can quickly scroll through. It displays the same on every single computer/browser/smartphone, even very slow connection on old hardware. (sources are here : https://sr.ht/~lioploum/ploum.net/ )

But I’m not an experienced web dev.

By @thomas_moon - 7 months
I find this post a bit misleading. It seems like he didn't build a blog. He built a website with real requirements, then added a blog to it.

The title* feels a bit rage baity to be honest.

By @ploum - 7 months
That guys made it to the top of the Bell Curve…

https://mamot.fr/@ploum/113044736819173509