Add the likebutton.js: Place a file named likebutton.js next to book.toml in your custom-made mdBook. You can also use sdk.js from the likecoin/likecoin-button-sdk, as it works the same.
Here's an example of the likebutton.js code:
const LIKER_ID = "dltdojo";//Replace your own Liker ID
let likeurl = `https://button.like.co/in/embed/${LikerID}/button?referrer=${encodeURI(window.location.href)}`;
let el = document.getElementsByClassName("likebutton")[0];
if(el){
el.innerHTML = `<div class="likecoin-embed likecoin-button">
<div></div>
<iframe scrolling="no" frameborder="0" src="${likeurl}"></iframe>
</div>`;
}
Copy and modify the CSS: Copy the LikeCoinButton-integration/style.css file and rename it to become likebutton.css. Make the following modifications:
Edit the book.toml: Open the book.toml and add the following lines under the output.html section:
Add the LikeCoin button to specific pages: In your markdown (md) files, add a <div> element with the class "likebutton" where you want the LikeCoin button to appear. For example:
The above instructions are for a single Liker ID. If you want to support multiple users, you can achieve it by using getElementsByClassName(LikerIDFoo).
Remember to build the mdBook and preview your website to see the LikeCoin button in action.