Ghost CMS casper theme 開啟 dark mode
原本我是使用 casper 這個 theme 升級到 Ghost 4.0 之後,dark mode 沒有了自動判斷,讓我這個喜歡 dark mode 的人覺得很痛苦,所以還是記錄一下如何開啟 dark mode。
官方文件
如果有翻過一下官方文件,其實會找到這篇 How do I turn on dark mode in Casper?
不過也就是在 code-injection 內塞入
<script>document.documentElement.classList.add('dark-mode');</script>
乍看之下有點暴力,可是很有用,不過要是對前端有點潔癖的人可能會不喜歡吧。
修改 theme
我個人是使用修改 theme 的方法,修改起來也不會太難。
- 先去官方 TryGhost/Casper 把專案 clone 下來,照著 Development 把安裝環境 set 起來。
- 修改 theme code 如果你有詳細看上面的註解,有提到 dark mode
那其實也只要修改default.hbs
加上 html classdark-mode
- 修改完畢之後
yarn zip
到後台上傳打包出來的 theme
收工