Skip to content

Commit

Permalink
added highlight function
Browse files Browse the repository at this point in the history
  • Loading branch information
veedata committed Dec 20, 2021
1 parent e51adcc commit d95bffd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ news_limit: 5
# Markdown and syntax highlight
markdown: kramdown
highlighter: rouge
highlight_theme_light: native # https://github.com/jwarby/jekyll-pygments-themes
highlight_theme_dark: github # https://github.com/jwarby/jekyll-pygments-themes
highlight_theme_light: github # https://github.com/jwarby/jekyll-pygments-themes
highlight_theme_dark: native # https://github.com/jwarby/jekyll-pygments-themes
kramdown:
input: GFM
syntax_highlighter_opts:
Expand Down
16 changes: 12 additions & 4 deletions assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
let toggleTheme = (theme) => {
if (theme == "dark") {
setTheme("light");
document.getElementById("highlight_theme_light").media = "none";
document.getElementById("highlight_theme_dark").media = "";
} else {
setTheme("dark");
document.getElementById("highlight_theme_dark").media = "none";
document.getElementById("highlight_theme_light").media = "";
}
}


let setTheme = (theme) => {
transTheme();
setHighlight(theme);

if (theme) {
document.documentElement.setAttribute("data-theme", theme);
}
Expand All @@ -32,6 +30,16 @@ let setTheme = (theme) => {
}
};

let setHighlight = (theme) => {
if (theme == "dark") {
document.getElementById("highlight_theme_light").media = "none";
document.getElementById("highlight_theme_dark").media = "";
} else {
document.getElementById("highlight_theme_dark").media = "none";
document.getElementById("highlight_theme_light").media = "";
}
}


let transTheme = () => {
document.documentElement.classList.add("transition");
Expand Down

0 comments on commit d95bffd

Please sign in to comment.