File tree Expand file tree Collapse file tree 5 files changed +37
-8
lines changed Expand file tree Collapse file tree 5 files changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ const JUSTIFY_CSS = `
67
67
let configured = false ;
68
68
function configure ( ) {
69
69
if ( ! configured ) {
70
- nunjucks . configure ( { autoescape : false , noCache : true } ) ;
70
+ const env = nunjucks . configure ( {
71
+ autoescape : false ,
72
+ noCache : true
73
+ } ) ;
74
+ env . addFilter ( 'humandate' , humanDate ) ;
71
75
configured = true ;
72
76
}
73
77
}
@@ -299,7 +303,7 @@ async function bundlePdf(items, options) {
299
303
filetype : 'pdf' ,
300
304
title,
301
305
author,
302
- date : humanDate ( new Date ( ) ) ,
306
+ date : new Date ( ) ,
303
307
items,
304
308
style,
305
309
options : {
@@ -497,7 +501,7 @@ async function bundleHtml(items, options) {
497
501
title :
498
502
options . title ||
499
503
( items . length === 1 ? items [ 0 ] . title : 'Untitled' ) ,
500
- date : humanDate ( new Date ( ) ) ,
504
+ date : new Date ( ) ,
501
505
items,
502
506
style,
503
507
options : {
@@ -552,7 +556,7 @@ async function bundleMd(items, options) {
552
556
title :
553
557
options . title ||
554
558
( items . length === 1 ? items [ 0 ] . title : 'Untitled' ) ,
555
- date : humanDate ( new Date ( ) ) ,
559
+ date : new Date ( ) ,
556
560
items,
557
561
style,
558
562
options : {
Original file line number Diff line number Diff line change @@ -173,6 +173,8 @@ export default async function cleanupItem(
173
173
url,
174
174
title : sanitizer . sanitize ( parsed . title ) ,
175
175
byline : sanitizer . sanitize ( parsed . byline ) ,
176
+ published : sanitizer . sanitize ( parsed . published || parsed . publishedTime ) ,
177
+ updated : sanitizer . sanitize ( parsed . updated ) ,
176
178
dir : sanitizer . sanitize ( parsed . dir ) ,
177
179
excerpt : serializer ( sanitize_to_dom ( parsed . excerpt ) ) ,
178
180
content : serializer (
Original file line number Diff line number Diff line change 1
- const formatter = new Intl . DateTimeFormat ( 'en' , {
1
+ const dateTimeFormatter = new Intl . DateTimeFormat ( 'en' , {
2
+ dateStyle : 'medium' ,
3
+ timeStyle : 'short'
4
+ } ) ;
5
+
6
+ const dateFormatter = new Intl . DateTimeFormat ( 'en' , {
2
7
dateStyle : 'medium'
3
8
} ) ;
4
9
5
- export default function humanDate ( d ) {
6
- return formatter . format ( d ) ;
10
+ export default function humanDate ( date , includeTime = false ) {
11
+ const d = new Date ( date ) ;
12
+ return includeTime ? dateTimeFormatter . format ( d ) : dateFormatter . format ( d ) ;
7
13
}
Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ article {
117
117
}
118
118
119
119
article : not (: last-of-type ) {
120
+ margin-bottom : 2em ;
120
121
page-break-after : always;
121
122
}
122
123
@@ -136,9 +137,12 @@ article:not(:last-of-type) {
136
137
line-height : 1.1 ;
137
138
}
138
139
140
+ .article__byline ,
141
+ .article__time ,
139
142
.article__url {
140
143
font-style : italic;
141
144
font-size : 0.9em ;
145
+ margin : 0 ;
142
146
}
143
147
144
148
/*
@@ -148,6 +152,7 @@ article:not(:last-of-type) {
148
152
149
153
.article__content img {
150
154
max-width : 100% ;
155
+ height : auto;
151
156
display : block;
152
157
margin : 0 auto;
153
158
}
Original file line number Diff line number Diff line change 31
31
< h1 class ="cover__title "> {{ title }}</ h1 >
32
32
< p class ="cover__subtitle ">
33
33
< time class ="cover__date " datetime ="{{ date }} "
34
- > {{ date }}</ time
34
+ > {{ date | humandate }}</ time
35
35
>
36
36
</ p >
37
37
</ div >
@@ -57,6 +57,18 @@ <h1 class="toc__title">Table of Contents</h1>
57
57
< h1 class ="article__title "> {{ item.title }}</ h1 >
58
58
{% if item.byline %}
59
59
< p class ="article__byline "> By < span > {{ item.byline }}</ span > </ p >
60
+ {% endif %} {% if item.published %}
61
+ < p class ="article__time ">
62
+ Published
63
+ < time datetime ="{{item.published}} ">
64
+ {{item.published | humandate(true) }} </ time
65
+ > {%- if item.updated and item.updated !== item.published
66
+ -%}, updated
67
+ < time datetime ="{{item.updated}} ">
68
+ {{item.updated | humandate(true) }}
69
+ </ time >
70
+ {%- endif -%}
71
+ </ p >
60
72
{% endif %}
61
73
< p class ="article__url ">
62
74
Source:
You can’t perform that action at this time.
0 commit comments