PageSourceSearch

https://mouvement-municipal.fr/assets/prose-toc-IuP94NY.js

js mouvement-municipal.fr collected 2026-09-25 12:15:43 UTC 1,591 bytes, 50 lines download raw bytes

1/**
2 * prose-toc.js — Table des matières légère pour les pages longues.
3 *
4 * Active si [data-toc] est présent et contient ≥ 3 h2.
5 * Ajoute des id aux h2, injecte une <nav> .prose-toc avant le contenu.
6 * Idempotent : guard contre les imports multiples (HTMX swaps éventuels).
7 */
8(function buildToc() {
9  const container = document.querySelector('[data-toc]');
10  if (!container || container.dataset.tocReady) return;
11  container.dataset.tocReady = '1';
12
13  const headings = Array.from(container.querySelectorAll('h2'));
14  if (headings.length < 3) return;
15
16  // Assigner des id stables sur les h2
17  headings.forEach((h, i) => {
18    if (!h.id) {
19      const slug = (h.textContent || '').trim()
20        .toLowerCase()
21        .normalize('NFD').replace(/[̀-ͯ]/g, '')  // strip accents
22        .replace(/[^a-z0-9]+/g, '-')
23        .replace(/^-|-$/g, '');
24      h.id = slug || `section-${i + 1}`;
25    }
26  });
27
28  // Construire la nav TDM
29  const nav = document.createElement('nav');
30  nav.className = 'prose-toc';
31  nav.setAttribute('aria-label', 'Table des matières');
32
33  const title = document.createElement('p');
34  title.className = 'prose-toc-title';
35  title.textContent = 'Sur cette page';
36  nav.appendChild(title);
37
38  const ol = document.createElement('ol');
39  headings.forEach((h) => {
40    const li = document.createElement('li');
41    const a  = document.createElement('a');
42    a.href = `#${h.id}`;
43    a.textContent = h.textContent.trim();
44    li.appendChild(a);
45    ol.appendChild(li);
46  });
47  nav.appendChild(ol);
48
49  container.insertBefore(nav, container.firstChild);
50})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.