feat: Add static rendering for article pages

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-12-04 18:01:00 +00:00
parent 7c600dcfba
commit 32cbf47d95
2 changed files with 51 additions and 15 deletions

View File

@@ -46,18 +46,52 @@
<body>
<div class="nojs">
<noscript>
You need to enable JavaScript to run this app because it's written in React.
I was planning on writing a server-side version, but I've become distracted
by other projects -- sorry!
<br/>
I originally wrote this for myself, and of course I whitelist JavaScript on
all my own domains.
<br/><br/>
Alternatively, try activex.news.t0.vc for an ActiveX™ version.
</noscript>
<noscript></noscript>
</div>
<div id="root">
{% if story %}
<div class="container article">
<div class="header">
{% if show_comments %}
<h1>{{ story.title }}</h1>
{% else %}
<h1><a href="{{ story.url or story.link }}">{{ story.title }}</a></h1>
{% endif %}
<div class="info">
{{ story.score }} points
by <a href="{{ story.author_link }}">{{ story.author }}</a>
on <a href="{{ story.link }}">{{ story.source }}</a> |
<a href="/{{ story.id }}/c">
{{ story.num_comments }} comment{{ 's' if story.num_comments != 1 }}
</a>
</div>
<div class='dot toggleDot'>
<div class='button'>
<a href="/{{ story.id }}{{ '/c' if not show_comments else '' }}">
{{ '' if not show_comments else '' }}
</a>
</div>
</div>
</div>
{% if not show_comments %}
<div class="text">{{ story.text | safe }}</div>
{% else %}
{% macro render_comment(comment, level) %}
<div class="comment" style="margin-left: {{ level * 20 }}px">
<div class="c-info"><a href="{{ comment.author_link }}">{{ comment.author }}</a></div>
<div class="c-text">{{ comment.text | safe }}</div>
{% for reply in comment.comments %}
{{ render_comment(reply, level + 1) }}
{% endfor %}
</div>
{% endmacro %}
<div class="comments">
{% for comment in story.comments %}{{ render_comment(comment, 0) }}{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
</div>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.