Skip to content

Commit d032415

Browse files
committed
show footer only on index.html
1 parent 4ee1be5 commit d032415

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

sdk/commands/_html.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from dataclasses import dataclass, field
88
from datetime import date, datetime, time
99
from pathlib import Path
10-
from types import MappingProxyType
1110

1211
import jinja2
1312
import rfeed
@@ -28,11 +27,6 @@
2827
)
2928
RSS_FILE_NAME = 'index.xml'
3029
v = sys.version_info
31-
CONTEXT = MappingProxyType(dict(
32-
python_version=f'{v.major}.{v.minor}.{v.micro}',
33-
now=datetime.now(),
34-
commit_sha=os.environ.get('CF_PAGES_COMMIT_SHA'),
35-
))
3630

3731

3832
@dataclass(frozen=True)
@@ -95,6 +89,11 @@ def run(self) -> int:
9589
'index',
9690
pages=PAGES,
9791
years=sorted(years.items(), reverse=True),
92+
93+
# for rendering footer
94+
python_version=f'{v.major}.{v.minor}.{v.micro}',
95+
now=datetime.now(),
96+
commit_sha=os.environ.get('CF_PAGES_COMMIT_SHA'),
9897
)
9998
render_html(
10099
'typing',
@@ -156,15 +155,15 @@ def _prepare_dirs(self) -> None:
156155

157156
def render_html(slug: str, title: str | None = None, **kwargs) -> None:
158157
template = jinja_env.get_template(f'{slug}.html.j2')
159-
content = template.render(len=len, title=title, **CONTEXT, **kwargs)
158+
content = template.render(len=len, title=title, **kwargs)
160159
html_path = ROOT / 'public' / f'{slug}.html'
161160
html_path.write_text(content, encoding='utf8')
162161

163162

164163
def render_post(posts: list[PostToRender]) -> None:
165164
main_post = posts[0]
166165
template = jinja_env.get_template('post.html.j2')
167-
content = template.render(title=main_post.title, posts=posts, **CONTEXT)
166+
content = template.render(title=main_post.title, posts=posts)
168167
html_path = ROOT / 'public' / 'posts' / f'{main_post.slug}.html'
169168
html_path.write_text(content, encoding='utf8')
170169

templates/base.html.j2

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
</main>
4242
</div>
4343

44-
<footer class="container-fluid bg-white py-3">
45-
<div class="container text-muted">
46-
Generated on {{ now.date().isoformat() }}
47-
using Python {{ python_version }}
48-
{% if commit_sha %}
49-
(<a href="https://github.com/life4/pythonetc/commit/{{ commit_sha }}">{{ commit_sha[:7] }}</a>)
50-
{% endif %}
51-
</div>
52-
</footer>
53-
5444
{# syntax highlighter #}
5545
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js" integrity="sha512-7Z9J3l1+EYfeaPKcGXu3MS/7T+w19WtKQY/n+xzmw4hZhJ9tyYmcUS+4QqAlzhicE5LAfMQSF3iFTK9bQdTxXg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
5646
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" integrity="sha512-vswe+cgvic/XBoF1OcM/TeJ2FW0OofqAVdCZiEYkd6dwGXthvkSFWOoGGJgS2CW70VK5dQM5Oh+7ne47s74VTg==" crossorigin="anonymous" referrerpolicy="no-referrer" />

templates/index.html.j2

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,15 @@
4141
{% endfor %}
4242
</div>
4343

44+
45+
<div class="container-fluid bg-white py-3">
46+
<div class="container text-muted">
47+
Generated on {{ now.date().isoformat() }}
48+
using Python {{ python_version }}
49+
{% if commit_sha %}
50+
(<a href="https://github.com/life4/pythonetc/commit/{{ commit_sha }}">{{ commit_sha[:7] }}</a>)
51+
{% endif %}
52+
</div>
53+
</div>
54+
4455
{% endblock %}

0 commit comments

Comments
 (0)