- Published on
Yet another modernisation
- Authors
- Name
- Freeman Man
So it's 2023 - almost 2024, and I'm still using a static site generator. I'm not sure if it's cool or not, but I'm sure it's not as cool as it was before. I'm not sure if I'm cool or not, but I'm sure I'm not as cool as I was before.
(LOL, above content is a plain tab and accept what's coming from copilot.)
and copilot is still shoveling me with the same content, so I'm going to write something else. (lol - copilot again before the comma)
omfg copilot, enough of padding this post with your content. (rofl, still copilot after first comma)
I'm going to write something else. (rofl - whole sentence copilot - i'm laughing in front of the screen like an idiot)
ok ok enough of this nonsense
Nuke and start over
it is now 2023, and these days it's all back to dynamic content and server pages, like back in the days of php
where you just write code in the page and it gets executed (lol, copilot again) (even this bracket is from copilot)
so I just decided to migrate my good old blog from jerkyll to nextjs, and may as well host it on vercel, because seems it's what cool kids do these days.
Oh right, i've been looking at tailwindcss recently as well, a quick google nextjs tailwind blog template
and shopped around for a while, i found this one https://github.com/timlrx/tailwind-nextjs-starter-blog
and ooo cutting edge stuff
- contentlayer
- 0.3.4 at the time im writing this
- looks like it's lighter than having an entire gatsby to wrap mdx?
- and looks like gatsby is not cool any more?
I was thinking about nuking the whole site and start a new repo, but then I think may as well try nuke the whole app within the same repo, just to apply what I've learnt for a while ago about git subtree
and pretty much thinking about using github discussion for comments, because there's this thing called giscus.
Here's the scenario:
- i want to keep the github repo, so that the forks, stars, comments, issues will stay the same - e.g. thinking about using github to do project management as well
- i also want to fork this new site from another repo / starter template
maybe playing with git subtree would solve the issue
since this git subtree can basically ignore the old branch / trunk and start new while keeping both histories
a quick google gives me this https://stackoverflow.com/questions/72019163/git-subtree-to-add-the-files-directly-under-root-folder
looks exactly like what i need
git switch -c temp
git subtree add -P temp --squash <remote-repo> main
git switch - # return to original branch
git switch -c init temp^2 # select squashed commit as starting point
# the following sed is probably somewhat unstable, but does the job
# the important point is to change to 'git-subtree-dir: .' within commit message body here!
patchedCommitMessage=$(git show -s --format=%B init | sed 's/temp/./')
git commit --amend --no-edit -m "$patchedCommitMessage"
git switch - # return to original branch
# allow merge conflicts and resolve in next step
git merge --allow-unrelated-histories --no-edit init
# then to quickly resolve all conflicts and discard “ours”
# git checkout --theirs .
# cleanup
git branch -D init
git branch -D temp
cool beans, next step
Few more things to consider
- i want to keep the old posts
- with some effort to migrate, but kept minimal
- i want to keep the old urls
- so i don't need to worry about seo and stuff
- i want to keep the old images
- even the ones back the wordpress days
- i want to keep my domain
- free hosting is important
- i don't want to pay for hosting
- i don't want to pay for ssl
(most above are from copilot)
see readme of this repo for what i've done for this site
worked out a pretty easy workflow
- create year/month folder
- move old .md file into the folder and remove the date part in the old file name
- rename to .mdx
- add date: and put date part into it
- merge categories and tags into tags
- migrate lightbox-img tags
for newer posts
- copy the original .md to /blog
- rename to .mdx
- add date: and draft: and remove old attributes
not too shabby imo
seems just like any other migration projects, it's easier planning than doing
obstacles i've encountered
- old posts are not pure markdown
- many of the html bits does not work properly in mdx
- but it is kind of understandable, given it was originally written for wordpress, got converted to markdown with a plugin, then got converted to mdx
so after a few hours of manual work, i've got the old posts migrated, definitely much more work than i'd have hoped for, but it's done'ish (very rough and pretty much dropped all formatting and images)
but this round it got down simple enough so that maybe in the future it would work without more manual works
it's actually good to come back to look at what i was doing 13 years ago, and get me to think about what i should be doing in the next 10 years
Self reflection
- is this the last time of doing this?
- definitely not, i'm sure i'll be doing this again probably in 5 years
- what should i aim for then?
- maybe efficiency?
- maybe reduce amount of manual code?
or maybe it simply doesn't matter that much, as long as it is clear and the thought behind or the why is documentated, and stop overengineering it for the sake of thinking about the future, simply use whatever makes sense at the time
but maybe timeboxing it so that it may take no more than a planned amount of effort even if it's a complete rewrite
all tech choices may just be making a bet, it may work out or it may not
it may just be a balance of compromise between the amount of time spent on it and the amount of time it will save in the future, and the tech will just change every time and it probably does not matter as long as it solves the problem well enough at the time
End note
copilot in coding / writing blog post is pretty handy, it tries to guess what i want to write, and if i like it i just tab, and if i don't i just ignore it - i kinda treat it like autocompletion on steroid
i've seen people using the chatbot in their workflow, to me i still cannot get to a workflow like this
- out of the coding screen
- use another panel to do chatbot stuff
- then back to coding screen,
therefore like code dictation and chatbot panel, i still haven't tried those yet. somehow copilot doesn't do spell checks very well, and it doesn't seem to pick up my grammatical or spelling errors like one would expect in a word processor.
Related work
btw, I also moved the a gatsby site from netlify to vercel last month radio4ebchinese.org, with 0 change in code,
just a few clicks in vercel and change the DNS in cloudflare and it's done