feat: codeblock improvements (#1328)
* fix: do not show codeblock copy button if clipboard api is not available related: https://github.com/CaiJimmy/hugo-theme-stack/issues/1309 * fix: remove duplicated codeblock script in main.ts * feat: add i18n support to codeblock copy button * feat: add translation strings for codeblock copy button
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
import * as params from '@params';
|
||||||
|
|
||||||
|
export function setupCodeCopy() {
|
||||||
|
/**
|
||||||
|
* Add copy button to code block
|
||||||
|
*/
|
||||||
|
const highlights = document.querySelectorAll('.article-content div.highlight');
|
||||||
|
const copyText = params.codeblock.copy,
|
||||||
|
copiedText = params.codeblock.copied;
|
||||||
|
|
||||||
|
if (!navigator.clipboard) {
|
||||||
|
/// Clipboard API is only supported in secure contexts (HTTPS)
|
||||||
|
console.warn('Clipboard API not supported, copy button will not work.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
highlights.forEach(highlight => {
|
||||||
|
const copyButton = document.createElement('button');
|
||||||
|
copyButton.innerHTML = copyText;
|
||||||
|
copyButton.classList.add('copyCodeButton');
|
||||||
|
highlight.appendChild(copyButton);
|
||||||
|
|
||||||
|
const codeBlock = highlight.querySelector('code[data-lang]');
|
||||||
|
if (!codeBlock) return;
|
||||||
|
|
||||||
|
copyButton.addEventListener('click', () => {
|
||||||
|
navigator.clipboard.writeText(codeBlock.textContent)
|
||||||
|
.then(() => {
|
||||||
|
copyButton.textContent = copiedText;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
copyButton.textContent = copyText;
|
||||||
|
}, 1000);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
alert(err)
|
||||||
|
console.log('Something went wrong', err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
+2
-32
@@ -11,6 +11,7 @@ import StackColorScheme from './colorScheme';
|
|||||||
import { setupScrollspy } from './scrollspy';
|
import { setupScrollspy } from './scrollspy';
|
||||||
import { setupSmoothAnchors } from './smoothAnchors';
|
import { setupSmoothAnchors } from './smoothAnchors';
|
||||||
import { setupPaginationJump } from './pagination';
|
import { setupPaginationJump } from './pagination';
|
||||||
|
import { setupCodeCopy } from './code-copy';
|
||||||
|
|
||||||
let Stack = {
|
let Stack = {
|
||||||
init: () => {
|
init: () => {
|
||||||
@@ -23,42 +24,11 @@ let Stack = {
|
|||||||
if (articleContent) {
|
if (articleContent) {
|
||||||
setupSmoothAnchors();
|
setupSmoothAnchors();
|
||||||
setupScrollspy();
|
setupScrollspy();
|
||||||
|
setupCodeCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
setupPaginationJump();
|
setupPaginationJump();
|
||||||
|
|
||||||
/**
|
|
||||||
* Add copy button to code block
|
|
||||||
*/
|
|
||||||
const highlights = document.querySelectorAll('.article-content div.highlight');
|
|
||||||
const copyText = `Copy`,
|
|
||||||
copiedText = `Copied!`;
|
|
||||||
|
|
||||||
highlights.forEach(highlight => {
|
|
||||||
const copyButton = document.createElement('button');
|
|
||||||
copyButton.innerHTML = copyText;
|
|
||||||
copyButton.classList.add('copyCodeButton');
|
|
||||||
highlight.appendChild(copyButton);
|
|
||||||
|
|
||||||
const codeBlock = highlight.querySelector('code[data-lang]');
|
|
||||||
if (!codeBlock) return;
|
|
||||||
|
|
||||||
copyButton.addEventListener('click', () => {
|
|
||||||
navigator.clipboard.writeText(codeBlock.textContent)
|
|
||||||
.then(() => {
|
|
||||||
copyButton.textContent = copiedText;
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
copyButton.textContent = copyText;
|
|
||||||
}, 1000);
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
alert(err)
|
|
||||||
console.log('Something went wrong', err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
new StackColorScheme(document.getElementById('dark-mode-toggle')!);
|
new StackColorScheme(document.getElementById('dark-mode-toggle')!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "الوضع الداكن"
|
|||||||
warning = "تحذير"
|
warning = "تحذير"
|
||||||
caution = "تنبيه"
|
caution = "تنبيه"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "نسخ"
|
||||||
|
copied = "تم النسخ!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "غير موجود"
|
title = "غير موجود"
|
||||||
subtitle = "تعذر العثور على الصفحة المطلوبة."
|
subtitle = "تعذر العثور على الصفحة المطلوبة."
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ darkMode = "Цёмны рэжым"
|
|||||||
warning = "Папярэджанне"
|
warning = "Папярэджанне"
|
||||||
caution = "Асцярога"
|
caution = "Асцярога"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Капіяваць"
|
||||||
|
copied = "Скапіявана!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Не знойдзена"
|
title = "Не знойдзена"
|
||||||
subtitle = "Запытваемая старонка не існуе"
|
subtitle = "Запытваемая старонка не існуе"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Тъмен Режим"
|
|||||||
warning = "Предупреждение"
|
warning = "Предупреждение"
|
||||||
caution = "Внимание"
|
caution = "Внимание"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Копирай"
|
||||||
|
copied = "Копирано!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Не е намерено"
|
title = "Не е намерено"
|
||||||
subtitle = "Страницата която търсите не е открита"
|
subtitle = "Страницата която търсите не е открита"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "ডার্ক মোড"
|
|||||||
warning = "সতর্কতা"
|
warning = "সতর্কতা"
|
||||||
caution = "সাবধানতা"
|
caution = "সাবধানতা"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "কপি"
|
||||||
|
copied = "কপি হয়েছে!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "পাওয়া যায়নি"
|
title = "পাওয়া যায়নি"
|
||||||
subtitle = "এই পাতাটি বিদ্যমান নেই"
|
subtitle = "এই পাতাটি বিদ্যমান নেই"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Mode fosc"
|
|||||||
warning = "Avís"
|
warning = "Avís"
|
||||||
caution = "Precaució"
|
caution = "Precaució"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Copia"
|
||||||
|
copied = "Copiat!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "No Trobat"
|
title = "No Trobat"
|
||||||
subtitle = "Aquesta pàgina no existeix"
|
subtitle = "Aquesta pàgina no existeix"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Tmavý režim"
|
|||||||
warning = "Varování"
|
warning = "Varování"
|
||||||
caution = "Upozornění"
|
caution = "Upozornění"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Kopírovat"
|
||||||
|
copied = "Zkopírováno!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Nenalezeno"
|
title = "Nenalezeno"
|
||||||
subtitle = "Tato stránka neexistuje"
|
subtitle = "Tato stránka neexistuje"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Dunkler Modus"
|
|||||||
warning = "Warnung"
|
warning = "Warnung"
|
||||||
caution = "Vorsicht"
|
caution = "Vorsicht"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Kopieren"
|
||||||
|
copied = "Kopiert!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Seite nicht gefunden"
|
title = "Seite nicht gefunden"
|
||||||
subtitle = "Diese Seite existiert nicht"
|
subtitle = "Diese Seite existiert nicht"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Σκοτεινό θέμα"
|
|||||||
warning = "Προειδοποίηση"
|
warning = "Προειδοποίηση"
|
||||||
caution = "Προσοχή"
|
caution = "Προσοχή"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Αντιγραφή"
|
||||||
|
copied = "Αντιγράφηκε!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Δε βρέθηκε"
|
title = "Δε βρέθηκε"
|
||||||
subtitle = "Η σελίδα δε βρέθηκε."
|
subtitle = "Η σελίδα δε βρέθηκε."
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Dark Mode"
|
|||||||
warning = "Warning"
|
warning = "Warning"
|
||||||
caution = "Caution"
|
caution = "Caution"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Copy"
|
||||||
|
copied = "Copied!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Not Found"
|
title = "Not Found"
|
||||||
subtitle = "This page does not exist"
|
subtitle = "This page does not exist"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Modo oscuro"
|
|||||||
warning = "Advertencia"
|
warning = "Advertencia"
|
||||||
caution = "Precaución"
|
caution = "Precaución"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Copiar"
|
||||||
|
copied = "¡Copiado!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "No Encontrado"
|
title = "No Encontrado"
|
||||||
subtitle = "Esta página no existe"
|
subtitle = "Esta página no existe"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "حالت شب"
|
|||||||
warning = "هشدار"
|
warning = "هشدار"
|
||||||
caution = "احتیاط"
|
caution = "احتیاط"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "کپی"
|
||||||
|
copied = "کپی شد!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "یافت نشد"
|
title = "یافت نشد"
|
||||||
subtitle = "این صحه وجود ندارد"
|
subtitle = "این صحه وجود ندارد"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Mode sombre"
|
|||||||
warning = "Avertissement"
|
warning = "Avertissement"
|
||||||
caution = "Attention"
|
caution = "Attention"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Copier"
|
||||||
|
copied = "Copié !"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Page non trouvée"
|
title = "Page non trouvée"
|
||||||
subtitle = "Cette page n'existe pas."
|
subtitle = "Cette page n'existe pas."
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "डार्क मोड"
|
|||||||
warning = "चेतावनी"
|
warning = "चेतावनी"
|
||||||
caution = "सावधानी"
|
caution = "सावधानी"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "कॉपी"
|
||||||
|
copied = "कॉपी हो गया!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "404 नहीं मिला।"
|
title = "404 नहीं मिला।"
|
||||||
subtitle = "यह पृष्ठ मौजूद नहीं है।"
|
subtitle = "यह पृष्ठ मौजूद नहीं है।"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Sötét Mód"
|
|||||||
warning = "Figyelmeztetés"
|
warning = "Figyelmeztetés"
|
||||||
caution = "Óvatosság"
|
caution = "Óvatosság"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Másolás"
|
||||||
|
copied = "Másolva!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Nem található"
|
title = "Nem található"
|
||||||
subtitle = "Ez az oldal nem létezik"
|
subtitle = "Ez az oldal nem létezik"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Mode Gelap"
|
|||||||
warning = "Peringatan"
|
warning = "Peringatan"
|
||||||
caution = "Perhatian"
|
caution = "Perhatian"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Salin"
|
||||||
|
copied = "Disalin!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Tidak ditemukan"
|
title = "Tidak ditemukan"
|
||||||
subtitle = "Halaman yang Anda akses tidak ditemukan."
|
subtitle = "Halaman yang Anda akses tidak ditemukan."
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Modalità scura"
|
|||||||
warning = "Avvertenza"
|
warning = "Avvertenza"
|
||||||
caution = "Attenzione"
|
caution = "Attenzione"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Copia"
|
||||||
|
copied = "Copiato!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Non trovato"
|
title = "Non trovato"
|
||||||
subtitle = "Questa pagina non esiste."
|
subtitle = "Questa pagina non esiste."
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ darkMode = "ダークモード"
|
|||||||
warning = "警告"
|
warning = "警告"
|
||||||
caution = "注意"
|
caution = "注意"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "コピー"
|
||||||
|
copied = "コピーしました!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "404 Not Found"
|
title = "404 Not Found"
|
||||||
subtitle = "指定されたページは存在しません。"
|
subtitle = "指定されたページは存在しません。"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "다크 모드"
|
|||||||
warning = "경고"
|
warning = "경고"
|
||||||
caution = "주의"
|
caution = "주의"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "복사"
|
||||||
|
copied = "복사됨!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "찾을 수 없음"
|
title = "찾을 수 없음"
|
||||||
subtitle = "페이지를 찾을 수 없습니다."
|
subtitle = "페이지를 찾을 수 없습니다."
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ darkMode = "Donkere modus"
|
|||||||
warning = "Waarschuwing"
|
warning = "Waarschuwing"
|
||||||
caution = "Let op"
|
caution = "Let op"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Kopiëren"
|
||||||
|
copied = "Gekopieerd!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Niet gevonden"
|
title = "Niet gevonden"
|
||||||
subtitle = "Deze pagina bestaat niet."
|
subtitle = "Deze pagina bestaat niet."
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Mòde fosc"
|
|||||||
warning = "Avertiment"
|
warning = "Avertiment"
|
||||||
caution = "Atencion"
|
caution = "Atencion"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Copiar"
|
||||||
|
copied = "Copiat!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Non trobat"
|
title = "Non trobat"
|
||||||
subtitle = "Aquesta pagina existís pas"
|
subtitle = "Aquesta pagina existís pas"
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ darkMode = "Tryb ciemny"
|
|||||||
warning = "Ostrzeżenie"
|
warning = "Ostrzeżenie"
|
||||||
caution = "Uwaga"
|
caution = "Uwaga"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Kopiuj"
|
||||||
|
copied = "Skopiowano!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Nie znaleziono"
|
title = "Nie znaleziono"
|
||||||
subtitle = "Ta strona nie istnieje"
|
subtitle = "Ta strona nie istnieje"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Modo Escuro"
|
|||||||
warning = "Aviso"
|
warning = "Aviso"
|
||||||
caution = "Cuidado"
|
caution = "Cuidado"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Copiar"
|
||||||
|
copied = "Copiado!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Não Encontrado"
|
title = "Não Encontrado"
|
||||||
subtitle = "Esta página não existe."
|
subtitle = "Esta página não existe."
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Modo Escuro"
|
|||||||
warning = "Aviso"
|
warning = "Aviso"
|
||||||
caution = "Cuidado"
|
caution = "Cuidado"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Copiar"
|
||||||
|
copied = "Copiado!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Não Encontrado"
|
title = "Não Encontrado"
|
||||||
subtitle = "Esta página não existe."
|
subtitle = "Esta página não existe."
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ darkMode = "Тёмный режим"
|
|||||||
warning = "Предупреждение"
|
warning = "Предупреждение"
|
||||||
caution = "Осторожно"
|
caution = "Осторожно"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Копировать"
|
||||||
|
copied = "Скопировано!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Не найдено"
|
title = "Не найдено"
|
||||||
subtitle = "Запрашиваемая страница не существует"
|
subtitle = "Запрашиваемая страница не существует"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Tmavý režim"
|
|||||||
warning = "Varovanie"
|
warning = "Varovanie"
|
||||||
caution = "Upozornenie"
|
caution = "Upozornenie"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Kopírovať"
|
||||||
|
copied = "Skopírované!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Nenájdené"
|
title = "Nenájdené"
|
||||||
subtitle = "Tato stránka neexistuje"
|
subtitle = "Tato stránka neexistuje"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "ธีมมืด"
|
|||||||
warning = "คำเตือน"
|
warning = "คำเตือน"
|
||||||
caution = "ระวัง"
|
caution = "ระวัง"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "คัดลอก"
|
||||||
|
copied = "คัดลอกแล้ว!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "ไม่พบหัวข้อ"
|
title = "ไม่พบหัวข้อ"
|
||||||
subtitle = "ไม่พบหน้านี้ในระบบ"
|
subtitle = "ไม่พบหน้านี้ในระบบ"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Koyu Mod"
|
|||||||
warning = "Uyarı"
|
warning = "Uyarı"
|
||||||
caution = "Dikkat"
|
caution = "Dikkat"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Kopyala"
|
||||||
|
copied = "Kopyalandı!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Bulunamadı"
|
title = "Bulunamadı"
|
||||||
subtitle = "Aradığınız sayfa mevcut değil."
|
subtitle = "Aradığınız sayfa mevcut değil."
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ darkMode = "Темна тема"
|
|||||||
warning = "Попередження"
|
warning = "Попередження"
|
||||||
caution = "Обережно"
|
caution = "Обережно"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Копіювати"
|
||||||
|
copied = "Скопійовано!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Не знайдено"
|
title = "Не знайдено"
|
||||||
subtitle = "Ця сторінка не існує"
|
subtitle = "Ця сторінка не існує"
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ darkMode = "Chế độ nền tối"
|
|||||||
warning = "Cảnh báo"
|
warning = "Cảnh báo"
|
||||||
caution = "Thận trọng"
|
caution = "Thận trọng"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "Sao chép"
|
||||||
|
copied = "Đã sao chép!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "Không tìm thấy"
|
title = "Không tìm thấy"
|
||||||
subtitle = "Trang này không tồn tại"
|
subtitle = "Trang này không tồn tại"
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ darkMode = "深色模式"
|
|||||||
warning = "警告"
|
warning = "警告"
|
||||||
caution = "注意"
|
caution = "注意"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "複製"
|
||||||
|
copied = "已複製!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "找不到頁面"
|
title = "找不到頁面"
|
||||||
subtitle = "本頁面並不存在"
|
subtitle = "本頁面並不存在"
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ darkMode = "夜晚模式"
|
|||||||
warning = "警告"
|
warning = "警告"
|
||||||
caution = "注意"
|
caution = "注意"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "複製"
|
||||||
|
copied = "已複製!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "404 錯誤"
|
title = "404 錯誤"
|
||||||
subtitle = "頁面不存在"
|
subtitle = "頁面不存在"
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ darkMode = "暗色模式"
|
|||||||
warning = "警告"
|
warning = "警告"
|
||||||
caution = "注意"
|
caution = "注意"
|
||||||
|
|
||||||
|
[article.codeblock]
|
||||||
|
copy = "复制"
|
||||||
|
copied = "已复制!"
|
||||||
|
|
||||||
[notFound]
|
[notFound]
|
||||||
title = "404 错误"
|
title = "404 错误"
|
||||||
subtitle = "页面不存在"
|
subtitle = "页面不存在"
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
{{- $opts := dict "minify" hugo.IsProduction -}}
|
{{- $opts := dict
|
||||||
|
"minify" hugo.IsProduction
|
||||||
|
"params" (dict
|
||||||
|
"codeblock" (dict
|
||||||
|
"copy" (i18n "article.codeblock.copy")
|
||||||
|
"copied" (i18n "article.codeblock.copied")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
-}}
|
||||||
{{- $script := resources.Get "ts/main.ts" | js.Build $opts | fingerprint -}}
|
{{- $script := resources.Get "ts/main.ts" | js.Build $opts | fingerprint -}}
|
||||||
|
|
||||||
<script type="text/javascript" src="{{ $script.RelPermalink }}" defer></script>
|
<script type="text/javascript" src="{{ $script.RelPermalink }}" defer></script>
|
||||||
@@ -7,4 +15,4 @@
|
|||||||
{{/* Place your custom script in HUGO_SITE_FOLDER/assets/ts/custom.ts */}}
|
{{/* Place your custom script in HUGO_SITE_FOLDER/assets/ts/custom.ts */}}
|
||||||
{{- $customScript := . | js.Build $opts | fingerprint -}}
|
{{- $customScript := . | js.Build $opts | fingerprint -}}
|
||||||
<script type="text/javascript" src="{{ $customScript.RelPermalink }}" defer></script>
|
<script type="text/javascript" src="{{ $customScript.RelPermalink }}" defer></script>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|||||||
Reference in New Issue
Block a user