Markdown blog on Flask with Vite-built assets and WeasyPrint PDF export, rewritten from the Wagtail build that preceded it.
blogdockerflaskmarkdownpythonself-hostedvite
1<!doctype html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>{{ post.title }}</title>
6 <style>
7 @page {
8 size: A4;
9 margin: 2cm 2cm 2.5cm 2cm;
10 @top-left {
11 content: "{{ post.title }}";
12 font-size: 7pt;
13 color: #999;
14 font-family: sans-serif;
15 }
16 @top-right {
17 content: "blog.bythewood.me";
18 font-size: 7pt;
19 color: #999;
20 font-family: sans-serif;
21 }
22 @bottom-center {
23 content: counter(page) " / " counter(pages);
24 font-size: 7pt;
25 color: #999;
26 font-family: sans-serif;
27 }
28 }
29 @page :first {
30 @top-left { content: none; }
31 @top-right { content: none; }
32 }
33 body {
34 font-family: sans-serif;
35 font-size: 10pt;
36 line-height: 1.5;
37 color: #1a1a1a;
38 }
39 h1 {
40 font-size: 1.8em;
41 margin-bottom: 0.2em;
42 }
43 .meta {
44 color: #666;
45 font-size: 0.9em;
46 margin-bottom: 2em;
47 padding-bottom: 1em;
48 border-bottom: 2px solid #eee;
49 }
50 .meta .tags {
51 margin-top: 0.3em;
52 }
53 .meta .tag {
54 background: #eee;
55 padding: 0.1em 0.5em;
56 border-radius: 3px;
57 font-size: 0.85em;
58 }
59 .cover-image {
60 margin-bottom: 1.5em;
61 text-align: center;
62 }
63 .cover-image img {
64 max-width: 100%;
65 border-radius: 4px;
66 }
67 .description {
68 font-size: 1.1em;
69 color: #555;
70 margin-bottom: 1.5em;
71 }
72 .block-rich-text {
73 margin-bottom: 0.5em;
74 }
75 .block-code {
76 margin: 1em 0;
77 page-break-inside: avoid;
78 }
79 .block-code pre {
80 background: #f5f5f5;
81 border-radius: 4px;
82 padding: 0.8em;
83 margin: 0;
84 white-space: pre-wrap;
85 word-wrap: break-word;
86 overflow-wrap: break-word;
87 }
88 .block-code code {
89 font-family: "JetBrains Mono", monospace;
90 font-size: 8.5pt;
91 line-height: 1.4;
92 background: none;
93 padding: 0;
94 border-radius: 0;
95 }
96 .block-image {
97 margin: 1.5em 0;
98 text-align: center;
99 }
100 .block-image img {
101 max-width: 100%;
102 max-height: 500px;
103 object-fit: contain;
104 border-radius: 4px;
105 }
106 code {
107 font-family: "JetBrains Mono", monospace;
108 background: #f0f0f0;
109 padding: 0.1em 0.3em;
110 border-radius: 3px;
111 font-size: 0.9em;
112 }
113 a {
114 color: #0e3ff4;
115 }
116 blockquote {
117 border-left: 3px solid #ddd;
118 margin-left: 0;
119 padding-left: 1em;
120 color: #555;
121 }
122 hr {
123 border: none;
124 border-top: 2px solid #eee;
125 margin: 2em auto;
126 max-width: 300px;
127 }
128 </style>
129</head>
130<body>
131 <h1>{{ post.title }}</h1>
132 <div class="meta">
133 <div>Isaac Bythewood · {{ post.date }} · {{ post.read_time }} min read</div>
134 {% if post.tags %}
135 <div class="tags">
136 {% for tag in post.tags %}
137 <span class="tag">{{ tag }}</span>
138 {% endfor %}
139 </div>
140 {% endif %}
141 </div>
142
143 {% if post.cover_image %}
144 <div class="cover-image">
145 <img src="/content/images/{{ post.cover_image }}" alt="{{ post.title }}">
146 </div>
147 {% endif %}
148
149 {% if post.description %}
150 <div class="description">{{ post.description }}</div>
151 {% endif %}
152
153 <article>
154 {{ post.body_html_pdf|safe }}
155 </article>
156
157</body>
158</html>