click-effect-tutorial
On this page
I wrote this in 2023 for the old version of this site, which ran on Hexo. It runs on Astro now, so these steps may no longer apply.
Before Start
You can add some clicking effects in your Hexo project.
There are a lots of tutorial that ask you to add files into your themes\layout\*.ejs files, but I suppose you will only find a .gitkeep file in the latest version of Hexo.
NOTE: Do note that I am using Hexo + Next theme. So if you are not using Next theme, you might need to make some changes accordingly.
Steps
- prepare a
javascriptscript that will add effect when mouse clicking. In this tutorial I will use aheart.jsfile. - Store your
heart.jsfile somewhere undersourcedirectory.- in this case we will create a
javascriptfolder undersourceand put theheart.jsinside. - full path will be
/javascript/heart.js.
- in this case we will create a
- create a
_datafolder under yoursource. Visit link to understand how it works. - create a
head.njkfile. - from
_config.next.ymlfile, find thecustom_file_path:and uncomment the head section like this:
custom_file_path:
head: source/_data/head.njk- In
head.njk, we will insert code below:
<script type="text/javascript" src="/javascript/heart.js"></script>- That’s all! Enjoy!