File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ const JUSTIFY_CSS = `
6767let configured = false ;
6868function configure ( ) {
6969 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 ) ;
7175 configured = true ;
7276 }
7377}
@@ -299,7 +303,7 @@ async function bundlePdf(items, options) {
299303 filetype : 'pdf' ,
300304 title,
301305 author,
302- date : humanDate ( new Date ( ) ) ,
306+ date : new Date ( ) ,
303307 items,
304308 style,
305309 options : {
@@ -497,7 +501,7 @@ async function bundleHtml(items, options) {
497501 title :
498502 options . title ||
499503 ( items . length === 1 ? items [ 0 ] . title : 'Untitled' ) ,
500- date : humanDate ( new Date ( ) ) ,
504+ date : new Date ( ) ,
501505 items,
502506 style,
503507 options : {
@@ -552,7 +556,7 @@ async function bundleMd(items, options) {
552556 title :
553557 options . title ||
554558 ( items . length === 1 ? items [ 0 ] . title : 'Untitled' ) ,
555- date : humanDate ( new Date ( ) ) ,
559+ date : new Date ( ) ,
556560 items,
557561 style,
558562 options : {
Original file line number Diff line number Diff line change @@ -173,6 +173,8 @@ export default async function cleanupItem(
173173 url,
174174 title : sanitizer . sanitize ( parsed . title ) ,
175175 byline : sanitizer . sanitize ( parsed . byline ) ,
176+ published : sanitizer . sanitize ( parsed . published || parsed . publishedTime ) ,
177+ updated : sanitizer . sanitize ( parsed . updated ) ,
176178 dir : sanitizer . sanitize ( parsed . dir ) ,
177179 excerpt : serializer ( sanitize_to_dom ( parsed . excerpt ) ) ,
178180 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' , {
27 dateStyle : 'medium'
38} ) ;
49
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 ) ;
713}
Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ article {
117117}
118118
119119article : not (: last-of-type ) {
120+ margin-bottom : 2em ;
120121 page-break-after : always;
121122}
122123
@@ -136,9 +137,12 @@ article:not(:last-of-type) {
136137 line-height : 1.1 ;
137138}
138139
140+ .article__byline ,
141+ .article__time ,
139142.article__url {
140143 font-style : italic;
141144 font-size : 0.9em ;
145+ margin : 0 ;
142146}
143147
144148/*
@@ -148,6 +152,7 @@ article:not(:last-of-type) {
148152
149153.article__content img {
150154 max-width : 100% ;
155+ height : auto;
151156 display : block;
152157 margin : 0 auto;
153158}
Original file line number Diff line number Diff line change 3131 < h1 class ="cover__title "> {{ title }}</ h1 >
3232 < p class ="cover__subtitle ">
3333 < time class ="cover__date " datetime ="{{ date }} "
34- > {{ date }}</ time
34+ > {{ date | humandate }}</ time
3535 >
3636 </ p >
3737 </ div >
@@ -57,6 +57,18 @@ <h1 class="toc__title">Table of Contents</h1>
5757 < h1 class ="article__title "> {{ item.title }}</ h1 >
5858 {% if item.byline %}
5959 < 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 >
6072 {% endif %}
6173 < p class ="article__url ">
6274 Source:
You can’t perform that action at this time.
0 commit comments