4 ms·
I've been working this way for a while, but with minimal code niceness: 1. There is an HTML file that just renders with markdown based on the hash. I know hash
by murgindrag 6y ago
I've been working this way for a while, but with minimal code niceness:
1. There is an HTML file that just renders with markdown based on the hash. I know hash isn't ideal, but it was easy, and it's all static.
2. Edit buttons on rendered pages link back to the github editor.
3. There is a minimal JSON config file pages grab, which allow me to configure stuff I want for use on e.g. localhost versus github.
It works very well. I ain't sharing my code here, and you don't want it. It's about an hour's worth of hacking to rebuild yourself and working. It'd probably be another few hours before I had something worth sharing.
It works really well, and more importantly, scales pretty well. It works seamlessly as a wiki. git workflows become nice if things go from one person to many.
- tomcam 6y ago> renders with markdown based on the hash. This sounds interesting, but I am lost. What is the hash?
- murgindrag 6y agoOh. Sorry. Overloaded term. URL location hash, not git hash. To see it, type `location.hash` in your browser's JavaScript console. If I want to render a page foo.md, I will go to: http://server/wiki#page=foo http://server/wiki#page=foo This is not how location hashes are meant to be used, mind you, and this breaks semantics, but it has the huge upside of running on any static web server, anywhere, including nothing but JavaScript. Until recently, it even ran on file:/// URLs, but that got nerfed a couple of years ago. Nothing I have built there is rocket science, but it works really, really well. Including with completely non-technical people playing with my wikis.
- tomcam 6y ago> URL location hash, not git hash OH! I was flummoxed. That is super clever. It breaks semantics only by convention because of the missing question mark, right? Because technically that is a valid URL.
- murgindrag 6y agoSemantically, hashes are supposed to be used to point to different parts of a page, not to different pages. I'm breaking semantics. Lots of pages break semantics this way, though. It's a way to hack around being able to change the URL without a page reloading. That's worse for semantics, but better for performance. It can cause issues if you're not careful. For example, if I change just the hash, the page won't reload. On the other hand, it's not hard to be careful. You listen for hashchange events, and when one comes, you reload the body of the page. Of course, the upside is that it's a lot faster that way. I don't need to refresh the whole page. I just grab a small markdown file, render it with libraries already loaded, and dump it into a div. There are also minor issues around a11y, and around web crawlers. Again, you just want to be a little bit careful. And if you're doing this for yourself, you probably don't care about a11y or web crawlers.
- tomcam 6y agoOK that was a world class education in 3 paragraphs! Making my own Markdown-based CMS so this was gold. Thanks tons.