diff --git a/src/components/WPAdapter.svelte b/src/components/WPAdapter.svelte index 3794493..877f23c 100644 --- a/src/components/WPAdapter.svelte +++ b/src/components/WPAdapter.svelte @@ -25,12 +25,28 @@ export let content + function encodeTextToUrl(text) { + return text + .replace(/[^A-Za-z ]/, '') + .replace('/ +/', ' ') + .replace(' ', '-') + } + onMount(() => { hljs.highlightAll() + + const selector = [1, 2, 3, 4, 5, 6] + .map((i) => `div.adapter h${i}`) + .join(', ') + const elements = window.document.querySelectorAll(selector) + for (const el of elements) { + const hash = encodeTextToUrl(el.textContent) + el.innerHTML = `${el.innerHTML}` + } }) -