mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-21 20:50:40 +00:00
chore: rework js imports (#489)
This commit is contained in:
parent
57afb60b99
commit
ae96648fac
@ -1,22 +1,13 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"amd": true
|
||||
"es2017": true
|
||||
},
|
||||
"extends": ["plugin:prettier/recommended"],
|
||||
"parser": "@babel/eslint-parser",
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"requireConfigFile": false,
|
||||
"allowImportExportEverywhere": true
|
||||
"requireConfigFile": false
|
||||
},
|
||||
"plugins": ["prettier"],
|
||||
"rules": {
|
||||
"require-await": "warn"
|
||||
},
|
||||
"globals": {
|
||||
"require": false,
|
||||
"requirejs": false
|
||||
}
|
||||
"plugins": ["prettier"]
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
const { createCopyButton } = require("./copycode.js")
|
||||
const Clipboard = require("clipboard")
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
let clipboard = new Clipboard(".clip")
|
||||
|
||||
clipboard.on("success", function (e) {
|
||||
const trigger = e.trigger
|
||||
|
||||
if (trigger.hasAttribute("data-copy-feedback")) {
|
||||
trigger.classList.add("gblog-post__codecopy--success", "gblog-post__codecopy--out")
|
||||
trigger.querySelector(".gblog-icon.copy").classList.add("hidden")
|
||||
trigger.querySelector(".gblog-icon.check").classList.remove("hidden")
|
||||
|
||||
setTimeout(function () {
|
||||
trigger.classList.remove("gblog-post__codecopy--success", "gblog-post__codecopy--out")
|
||||
trigger.querySelector(".gblog-icon.copy").classList.remove("hidden")
|
||||
trigger.querySelector(".gblog-icon.check").classList.add("hidden")
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
e.clearSelection()
|
||||
})
|
||||
|
||||
document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButton(highlightDiv))
|
||||
})
|
@ -1,6 +1,5 @@
|
||||
const Storage = require("store2")
|
||||
const { TOGGLE_COLOR_THEMES, THEME, COLOR_THEME_AUTO } = require("./config.js")
|
||||
|
||||
import Storage from "store2"
|
||||
import { TOGGLE_COLOR_THEMES, THEME, COLOR_THEME_AUTO } from "./config.js"
|
||||
;(() => {
|
||||
applyTheme()
|
||||
})()
|
||||
|
@ -1,4 +1,30 @@
|
||||
export function createCopyButton(highlightDiv) {
|
||||
import Clipboard from "clipboard"
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
let clipboard = new Clipboard(".clip")
|
||||
|
||||
clipboard.on("success", function (e) {
|
||||
const trigger = e.trigger
|
||||
|
||||
if (trigger.hasAttribute("data-copy-feedback")) {
|
||||
trigger.classList.add("gblog-post__codecopy--success", "gblog-post__codecopy--out")
|
||||
trigger.querySelector(".gblog-icon.copy").classList.add("hidden")
|
||||
trigger.querySelector(".gblog-icon.check").classList.remove("hidden")
|
||||
|
||||
setTimeout(function () {
|
||||
trigger.classList.remove("gblog-post__codecopy--success", "gblog-post__codecopy--out")
|
||||
trigger.querySelector(".gblog-icon.copy").classList.remove("hidden")
|
||||
trigger.querySelector(".gblog-icon.check").classList.add("hidden")
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
e.clearSelection()
|
||||
})
|
||||
|
||||
document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButton(highlightDiv))
|
||||
})
|
||||
|
||||
function createCopyButton(highlightDiv) {
|
||||
const button = document.createElement("span")
|
||||
|
||||
let codeSelector = "pre > code"
|
@ -1,9 +1,3 @@
|
||||
import "katex/dist/katex.css"
|
||||
import renderMathInElement from "katex/dist/contrib/auto-render.mjs"
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
import("katex/dist/contrib/auto-render")
|
||||
.then(({ default: renderMathInElement }) => {
|
||||
renderMathInElement(document.body)
|
||||
})
|
||||
.catch((error) => console.error(error))
|
||||
})
|
||||
renderMathInElement(document.body)
|
||||
|
@ -1,6 +1,6 @@
|
||||
const Storage = require("store2")
|
||||
const { v4: uuidv4 } = require("uuid")
|
||||
const { COLOR_THEME_DARK, THEME, COLOR_THEME_AUTO } = require("./config.js")
|
||||
import Storage from "store2"
|
||||
import { v4 as uuidv4 } from "uuid"
|
||||
import { COLOR_THEME_DARK, THEME, COLOR_THEME_AUTO } from "./config.js"
|
||||
|
||||
import mermaid from "mermaid"
|
||||
|
||||
|
@ -17,7 +17,7 @@ var config = {
|
||||
path.resolve("src", "sass", "mobile.scss"),
|
||||
path.resolve("src", "sass", "print.scss")
|
||||
],
|
||||
main: path.resolve("src", "js", "app.js"),
|
||||
main: path.resolve("src", "js", "index.js"),
|
||||
colortheme: path.resolve("src", "js", "colorTheme.js"),
|
||||
mermaid: path.resolve("src", "js", "mermaid.js"),
|
||||
katex: [path.resolve("src", "js", "katex.js")].concat(
|
||||
@ -33,6 +33,7 @@ var config = {
|
||||
watchOptions: {
|
||||
ignored: ["/exampleSite/", "/node_modules/"]
|
||||
},
|
||||
target: ["web", "es2017"],
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
|
Loading…
Reference in New Issue
Block a user