No CMS? Writing Our Blog in React (2023)
getwaitlist.com
getwaitlist.com
What ? I've certainly not overriden the HTML div, nor the CSS font-weight.
This is solved by React server rendering or RSC, e.g. through Next.
Your visitors will see HTML.
You realise that's just HTML with more steps?
My perspective is of React as a templating engine for markup that allows you to add behaviour on top as you need. So in a sense, exactly what you've said.
It's good at this because it's all done seamlessly in the same language with hardly any magic or conventions they have invented. It's just javascript. It also has a rendering model that's extremely simple to reason about when updates happen.
You can build something as complicated or as simple as you want with that, of course, but React doesn't care if you do. That's up to you to decide. React can be 'just' a static markup template engine running at build time (my own blog is built this way!), a server-only template engine, little bits of behaviour sprinkled in on the client to isolated parts of the page, all the way up to a full blown client application with an arbitrary level of complexity.
But I prefer Mithril (https://mithril.js.org/), which offers the same immediate-mode advantages (https://news.ycombinator.com/item?id=19746235) without the crazy-complex dependency-tracking reactivity.
I rather liked this comment on React: https://news.ycombinator.com/item?id=38640051
There is nothing about writing that makes this automatically true, and if you look at some of the software that novelists, editors screenwriters, journalists, technical authors, etc use it doesn't really hold water. For example, Scrivener and Shotrunner are closer to databases than writing tools.
Humans have been writing for thousands of years, and modern tech tools to help have been around for about 50. It's far too early to say whether or not tools hinder the process.
Blog Articles are self-contained in most cases and are within the scope of that blob. So, most tools should be either an enabler in that writing (editors, formatters) or the aftermath -- publishing (most CMSes).
> My idea was that surely it's possible to write a bunch of markdown, and then have that get wrapped in a bunch of JSX tags that come pre-styled, using the styles of your existing repo? For example, what I expected was to be able to write *test* (Markdown for bold) and then get a component that looked like<Bold>test</Bold> where <Bold> is a library-defined React component
It surely is possible, so perhaps I can share some links if others are wondering the same thing.
If you like to roll your own solution for that, you can use the unified ecosystem: https://unifiedjs.com/
However, if you want JSX just do what everyone does and reach for MDX: https://mdxjs.com/
> We thought this would be a no-brainer and that there would be some CMS/SSG libraries out there that made this Markdown conversion process easy and facilitated integration with any number of frontend frameworks.
You thought correct:
- NextJS MDX integration: https://nextjs.org/docs/pages/building-your-application/conf... - Gatsby MDX integration: https://www.gatsbyjs.com/docs/how-to/routing/mdx/
Or check https://jamstack.org/generators/ for more options But since you seem to like
Why? The article doesn't explain.
> it turns out that it's not so easy to "just use a CMS." Like many others, we initially looked into popular ones like Ghost, Hugo, Jekyll, and Publii
I don't know what Publii is; but Hugo and Jekyll aren't CMS's.
> all I really wanted was to be able to write Markdown, and then get some React Components that were styled well enough to use in my blog
Why was this a technical requirement? Why should the output from Markdown be a React component? Why does she need React for her blog? The article doesn't say.
They do a lot of things right.
I would imagine that's the most common reason people use a CMS.
* What are you going to do when you hire a non-technical writer down the road?
* The handwringing about control over SEO smacks of NIH and makes little sense. It feels like a very thin justification for this weird scheme.
* You are a technical company but you couldn't figure out how to apply your look and feel, which isn't unique and feels like a bootstrap template, to something or anything else.
* Your content is JSON in JS
I'm going through some of your blog posts and I just don't see where this kind of overkill is necessary. Nothing I'm seeing can't be represented in markdown with a little front matter. I mean MDX lets you use react components, which doesn't feel like a good idea to me either but feels like a better idea than this.
I dunno, kind of a strange read first thing in the morning.
Maybe I am missing the point, but why would people want to manage their content within their code? It seems incredibly weird and prone to quite messy and unmaintainable code.
I wonder if they even looked into headless CMS options? I just don't understand the thinking behind this, it seems really bizarre and inefficient.
Surely you can just run a headless CMS and fetch content using GraphQL or REST, and have your blog look the way you want it to with React or Nuxt SSR?
Weird...
You've hit the nail on the head. There is IMO some distance between eating your own dog food and NIH, and they have happily traversed that distance without a thought.
If you are trying to have your blog as your main website and not just one sub-category it makes sense to use a blogging framework (Hugo, Ghost, Wordpress etc.), but I realized that having a blog integrated in a product isn't so straight forward if you want to keep your existing footer, header, CSS and share it.
I tried to use Hugo to integrate a blog in my Rails app but it was a bigger amount of pain than just doing it quickly in your existing code base with all the tools and styles already available.
That's actually pretty simple, and is what CSS is meant to be helping with - there will be a pain of having to wrangle the framework's HTML to fit what you need, but it's doable, and a small price to pay for the benefits the tried-and-tested framework brings.
If you want to use for example Tailwind CSS classes in your blog you also need to integrate it with your build pipeline to add/remove unused classes from the final stylesheet.
I thought Sitepress looks interesting, as its supposed to integrate with Rails. Have you given that one a try?
I expected there to be many solutions for this problem but wasn't able to find a simple one.
In the end I just generated a simple "post" model and have some ugly admin interface that allows me to paste some markdown into a small box and publish it. Then I'm just using some gems for RSS feed / sitemap handling.
Basically, just convert your markdown to HTML, and dump that into your existing templates.
The idea being you can have a file called blog.json, and your entire site structure can be generated from it. (in whatever fashion you want aka templates)
You can store the content of the blog posts in the blog.json or they blog posts can reference something at a quasi permanent place e.g. ipfs
There's been a huge push in the past few years for "headless CMS": content is managed entirely separately from the actual website or app where it's leveraged.
In this specific case, YAML frontmatter MDX along with Next.js, Gatsby or similar would have done the trick.
Shameless plug: if you want to focus on managing content rather than juggling YAML and git, I'm building Pages CMS [1]. It adds a user friendly interface on top of GitHub when dealing with flat files.
This is entirely incorrect. If you want to reproduce your header and footer in some other thing, simply copy your header and footer! View-Source, copy, paste. It’s that easy.
Hosting it on a subdomain? Nope, you don’t have to do that either. You can use nginx to serve the path, you can use httpd to serve the path, you can use AWS ALB’s, HAProxy, pretty much every web server that can load balance can host your path to the blog outside of the path to /.
I stopped reading after this failure to do due diligence and use common sense.
- open source
- configuration files for the cms data model
- github based (no database)
- yml, markdown, json output
- simple and aesthetic