From ec22fd57f5bfe2cb8b107dee8a08a37c121bcb12 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:26:38 +0200 Subject: [PATCH] feat: add dockerfile tooltips Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- assets/js/src/tooltip.js | 12 ++++++++++++ tailwind.config.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 assets/js/src/tooltip.js diff --git a/assets/js/src/tooltip.js b/assets/js/src/tooltip.js new file mode 100644 index 0000000000..50707cda64 --- /dev/null +++ b/assets/js/src/tooltip.js @@ -0,0 +1,12 @@ +const cmds = document.querySelectorAll(".language-dockerfile span.k"); + +for (const cmd of cmds) { + const name = cmd.textContent; + const a = document.createElement("a") + a.classList.add("underline","underline-offset-4","decoration-dashed","cursor-pointer") + a.title = `Learn more about the ${name} instruction` + a.href = `/engine/reference/builder/#${name.toLowerCase()}` + a.innerHTML = cmd.outerHTML + cmd.insertAdjacentElement("beforebegin", a) + cmd.remove() +} diff --git a/tailwind.config.js b/tailwind.config.js index a3d3398ddf..18e4994561 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,6 +1,6 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ["./hugo_stats.json","./layouts/**/*.{html,js}", "./content/**/*.md"], + content: ["./hugo_stats.json","./layouts/**/*.{html,js}", "./content/**/*.md", "assets/js/**/*.js"], darkMode: "class", theme: { extend: {