<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Hugo on Theolexica</title><link>https://theolexica.com/tags/hugo/</link><description>Recent content in Hugo on Theolexica</description><generator>Hugo -- 0.134.3</generator><language>en-us</language><lastBuildDate>Tue, 27 May 2025 11:04:46 +0000</lastBuildDate><atom:link href="https://theolexica.com/tags/hugo/index.xml" rel="self" type="application/rss+xml"/><item><title>Linking the TOC for the Study Guides</title><link>https://theolexica.com/posts/linking-toc/</link><pubDate>Tue, 27 May 2025 11:04:46 +0000</pubDate><guid>https://theolexica.com/posts/linking-toc/</guid><description>&lt;h1 id="linking-toc-in-my-docs">Linking Toc In My Docs&lt;/h1>
&lt;p>This is a Hugo site. The nice thing about that for me is that all of my blog pages are written in markdown files. It makes it really portable and easily searchable. If I want to change something programatically, I can grep throught it all and do a find and replace in vim.&lt;/p>
&lt;p>Since it&amp;rsquo;s markdown, I can add any html that I need if I want to get fancy.&lt;/p></description><content:encoded><![CDATA[<h1 id="linking-toc-in-my-docs">Linking Toc In My Docs</h1>
<p>This is a Hugo site. The nice thing about that for me is that all of my blog pages are written in markdown files. It makes it really portable and easily searchable. If I want to change something programatically, I can grep throught it all and do a find and replace in vim.</p>
<p>Since it&rsquo;s markdown, I can add any html that I need if I want to get fancy.</p>
<p>One of the things that I do on certain pages is add a link back to the mother page. Eg, <a href="https://theolexica.com/posts/greek/schwandt-000/">Greek Study Guide Intro</a>
 links back to the <a href="https://theolexica.com/posts/greek/greek-study-guide-toc/">Greek Study Guide TOC</a>
. Doing this for dozens of pages is tedious, so I added a web-component <code>&lt;greek-toc&gt;&lt;/greek-toc&gt;</code> to the template for my Greek Study Guides.</p>
<p>I add a snippet to <a href="https://www.alfredapp.com" target="_blank" rel="noopener noreferrer">Alfred</a>
 to auto-expand on <code>!gr</code>. Now my post is ready to write with minimal mental overhead.</p>
<h2 id="the-problem">The Problem</h2>
<p>I had to create another one for latin and forgot the steps in Hugo, so I am documenting it for my future self.</p>
<h2 id="the-solution">The Solution</h2>
<ol>
<li>In <code>theolexica &gt; static &gt; js</code> duplicate one of the <code>NAME-toc.js</code> files, rename, and edit as needed.</li>
</ol>
<pre tabindex="0"><code>class GreekTOC extends HTMLElement {
    constructor() {
        super();
        this.attachShadow({ mode: &#39;open&#39; });
    }

    connectedCallback() {
        // Clear the shadowRoot to prevent duplicate content
        this.shadowRoot.innerHTML = &#39;&#39;;

        const tocContainer = document.createElement(&#39;div&#39;);
        tocContainer.innerHTML = `
        &lt;p&gt;
            A study guide for &lt;em&gt;
                &lt;a href=&#34;https://lexhampress.com/Schwandt&#34;&gt;An Introduction to Biblical Greek&lt;/a&gt;
            &lt;/em&gt; by John D Schwandt.
            (&lt;a href=&#34;https://theolexica.com/posts/greek/greek-study-guide-toc&#34;&gt;View all study guides&lt;/a&gt;.)
        &lt;/p&gt;
        `;

        this.shadowRoot.appendChild(tocContainer);
    }
}

customElements.define(&#39;greek-toc&#39;, GreekTOC);
</code></pre><ol start="2">
<li>
<p>In <code>layouts &gt; partials &gt; extend_head.html</code> add the script: <code>&lt;script src=&quot;/js/NAME-toc.js&quot; defer&gt;&lt;/script&gt;</code></p>
</li>
<li>
<p>Add your web component to a page <name-toc></name-toc></p>
</li>
</ol>
<h2 id="known-issues">Known issues</h2>
<ul>
<li>This adds the script to every page, not just the relevant post pages. I don&rsquo;t care.</li>
<li>Because of shadow DOM issues, it doesn&rsquo;t inherit the styling of the site. So far, I don&rsquo;t care enough to fix it.</li>
</ul>
]]></content:encoded></item></channel></rss>