<!-- views/ipns.html -->
<section class="mb-8">
  <!-- 
    Added "text-gray-900" here to ensure we override 
    any global white text color that might be inherited. 
  -->
  <div class="bg-white p-6 rounded-lg shadow-md text-gray-900">
    <h2 class="text-2xl font-bold mb-4 text-gray-700">IPNS Gateways</h2>

    <!-- 
      "markdown-body" can be any class name; it’s just so markdown.css 
      can style headings, lists, etc. 
    -->
    <div id="markdown-container" class="markdown-body">
      <p class="text-gray-500">Loading content...</p>
    </div>
  </div>
</section>

<script>
  (async () => {
    try {
      const response = await fetch("content/ipns.md");
      if (!response.ok) {
        throw new Error("Failed to load IPNS markdown file.");
      }
      const markdownText = await response.text();

      // Convert to HTML with Marked (make sure "marked" is loaded globally)
      const html = marked.parse(markdownText);

      // Insert final HTML into #markdown-container
      const container = document.getElementById("markdown-container");
      if (container) {
        container.innerHTML = html;
      }

      // Optional: highlight code blocks (requires "hljs" loaded globally)
      document.querySelectorAll("pre code").forEach((block) => {
        hljs.highlightBlock(block);
      });
    } catch (err) {
      console.error("Error loading IPNS content:", err);
      const container = document.getElementById("markdown-container");
      if (container) {
        container.innerHTML = `
          <p class="text-red-500">Error loading content. Please try again later.</p>
        `;
      }
    }
  })();
</script>
