chore(ui): Formatted and cleaned up the code

This commit is contained in:
Cipher Vance 2025-08-31 13:25:12 -05:00
parent ffdc4cde38
commit 46093d2b56
5 changed files with 638 additions and 611 deletions

View file

@ -7,36 +7,41 @@
{% block content %}
<div class="article-wrap">
<aside class="article-aside">
<a href="/newsletters" class="back-link">
<a href="{{ url_for('newsletters') }}" class="back-link">
<i class="fas fa-arrow-left"></i>
Back to Newsletters
</a>
<div class="article-meta">
<h2 class="article-title">{{ newsletter.subject if newsletter else 'Newsletter Title' }}</h2>
<h2 class="article-title">
{{ newsletter.subject if newsletter else 'Newsletter Title' }}
</h2>
<div class="meta-row">
<i class="fas fa-calendar-alt"></i>
<span>{{ newsletter.sent_at if newsletter else 'Published Date' }}</span>
</div>
{% if newsletter and newsletter.get('reading_time') %}
<div class="meta-row">
<i class="fas fa-clock"></i>
<span>{{ newsletter.reading_time }} min read</span>
</div>
<div class="meta-row">
<i class="fas fa-clock"></i>
<span>{{ newsletter.reading_time }} min read</span>
</div>
{% endif %}
{% if newsletter and newsletter.get('author') %}
<div class="meta-row">
<i class="fas fa-user"></i>
<span>{{ newsletter.author }}</span>
</div>
<div class="meta-row">
<i class="fas fa-user"></i>
<span>{{ newsletter.author }}</span>
</div>
{% endif %}
{% if newsletter and newsletter.get('tags') %}
<div class="article-tags">
{% for tag in newsletter.tags %}
<span class="tag">{{ tag }}</span>
{% endfor %}
</div>
<div class="article-tags">
{% for tag in newsletter.tags %}
<span class="tag">{{ tag }}</span>
{% endfor %}
</div>
{% endif %}
</div>
@ -48,7 +53,9 @@
<main class="article-main">
<header class="article-hero">
<div class="newsletter-icon"><i class="fas fa-envelope-open-text"></i></div>
<div class="newsletter-icon">
<i class="fas fa-envelope-open-text"></i>
</div>
<h1>{{ newsletter.subject if newsletter else 'Newsletter Title' }}</h1>
</header>
@ -62,7 +69,7 @@
</article>
<div class="newsletter-actions">
<a href="/newsletters" class="action-btn primary">
<a href="{{ url_for('newsletters') }}" class="action-btn primary">
<i class="fas fa-list"></i>
View All Newsletters
</a>
@ -80,35 +87,41 @@
{% endblock %}
{% block extra_scripts %}
<script>
function shareNewsletter() {
if (navigator.share) {
navigator.share({ title: document.title, url: location.href }).catch(() => {});
} else {
navigator.clipboard.writeText(location.href);
alert('Link copied to clipboard!');
<script>
function shareNewsletter() {
if (navigator.share) {
navigator
.share({ title: document.title, url: location.href })
.catch(() => {});
} else {
navigator.clipboard.writeText(location.href);
alert('Link copied to clipboard!');
}
}
}
// Build TOC from h2/h3 inside the article
(function buildTOC() {
const article = document.getElementById('article');
if (!article) return;
const headings = article.querySelectorAll('h2, h3');
const list = document.getElementById('toc-list');
if (!headings.length || !list) return;
// Build TOC from h2/h3 inside the article
(function buildTOC() {
const article = document.getElementById('article');
if (!article) return;
headings.forEach((h, idx) => {
const id = h.id || `h-${idx}`;
h.id = id;
const li = document.createElement('li');
li.className = h.tagName === 'H2' ? 'toc-h2' : 'toc-h3';
const a = document.createElement('a');
a.href = `#${id}`;
a.textContent = h.textContent;
li.appendChild(a);
list.appendChild(li);
});
})();
</script>
const headings = article.querySelectorAll('h2, h3');
const list = document.getElementById('toc-list');
if (!headings.length || !list) return;
headings.forEach((h, idx) => {
const id = h.id || `h-${idx}`;
h.id = id;
const li = document.createElement('li');
li.className = h.tagName === 'H2' ? 'toc-h2' : 'toc-h3';
const a = document.createElement('a');
a.href = `#${id}`;
a.textContent = h.textContent;
li.appendChild(a);
list.appendChild(li);
});
})();
</script>
{% endblock %}