g1eny0ung / hugo-theme-dream

🌱 A Hugo theme named Dream.
http://g1en.site/hugo-theme-dream/
MIT License
331 stars 128 forks source link

Add highlightjs for code syntax; possibly pick a light and dark theme as well #141

Closed KoderKow closed 4 years ago

KoderKow commented 4 years ago

Love the theme! I have a few posts that involve some code, I find syntax highlighting makes the code more engaging and easier to read. I have found out that Hugo can easily implement highlightjs. I have been able to get any theme I want working with your theme, but, I cannot figure out how to switch between two different highlightjs themes when toggling the theme. In Params I currently have:

[params]
  highlightjsVersion = "10.1.2"
  highlightjsCDN = "//cdnjs.cloudflare.com/ajax/libs"
  highlightjsLang = ["r", "yaml"]
  highlightjsTheme = "github"
  background = "#252323"

I would like:

highlightjsThemeDark = "rainbow"
highlightjsThemeLight = "github"

Example for code highlighting in my post: https://koderkow.rbind.io/post/introduction-to-neural-networks/

I have tried setting up a light/dark variable, however, I have no experience with Hugo code so I have had a hard time trying to get this to work with your theme. Here is a link to my current work on the partials. I got the highlight js Hugo code from here.

Can I get some help implementing this?

g1eny0ung commented 4 years ago

🤣 Sorry for the delayed reply, a little busy this week. I will try at the weekend.

KoderKow commented 4 years ago

Thank you! No rush at all! Your work is great! :) Keep it up!

g1eny0ung commented 4 years ago

@KoderKow https://g1eny0ung.site/hugo-theme-dream/#/highlightjs finished.~

KoderKow commented 4 years ago

This is amazing! Perfect! Thank you so much @g1eny0ung! You have made my day 👍