Skip to content

Instantly share code, notes, and snippets.

View vlavrynovych's full-sized avatar
🥷
Code Ninja

Volodymyr Lavrynovych vlavrynovych

🥷
Code Ninja
View GitHub Profile
@vlavrynovych
vlavrynovych / ghost-toc-v2.1.html
Last active January 11, 2025 22:34
Script for the Ghost blog which builds a Table of Contents. Provided code should be added to the footer using Ghost code injection. And then in article you only need to add html with <toc title="Table of Contents"></toc> tag
<script>
class TOC {
constructor() {
document.addEventListener('DOMContentLoaded', () => this.onLoad());
}
onLoad() {
this.article = document.querySelector('article');
const toc = this.article.querySelector('toc');
if (!toc) return;
@vlavrynovych
vlavrynovych / ghost-toc.html
Last active May 12, 2024 20:11
Script for the Ghost blog which builds a Table of Contents where it is placed
<!-- <toc> element is used to inject a TOC to it -->
<toc></toc>
<style>
toc #toc-container { width: 100%; }
toc .toc-empty-item { display: block }
toc .toc-caption { text-align: center; margin-bottom: 15px }
</style>
<script>
class TOC {
caption = {