1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 21:53:26 +00:00

Create the code language badge by Liquid

It prevents the language badges from flashing
This commit is contained in:
Cotes Chung
2021-07-04 20:09:45 +08:00
parent 65dbea9d3b
commit 5f1e6e9350
6 changed files with 33 additions and 26 deletions

View File

@@ -25,7 +25,7 @@ $(function() {
const title = nextTag.prop('tagName') === 'EM' ? nextTag.text() : '';
const src = $(this).attr('data-src'); // created by lozad.js
$(this).wrap(`<a href="${src}" title="${title}" class="popup"></a>`);
$(this).wrap(`<a href="${src}" title="${title}" class="popup img-link"></a>`);
}
);
@@ -42,6 +42,4 @@ $(function() {
/* markup the image links */
$(`${IMG_SCOPE} a`).has("img").addClass('img-link');
});

View File

@@ -1,20 +0,0 @@
/**
* Add language indicator to code snippets
*/
$(function() {
const prefix = "language-";
const regex = new RegExp(`^${prefix}([a-z])+$`);
$(`div[class^=${prefix}`).each(function() {
let classes = $(this).attr("class").split(" ");
classes.forEach((_class) => {
if (regex.test(_class)) {
let lang = _class.substring(prefix.length);
$(this).attr("lang", `${lang}`);
}
});
});
});