11import matter from 'gray-matter' ;
22import glob from 'glob' ;
3- import { config } from './globals' ;
3+ import { globals } from './globals' ;
44export type PostData = {
55 path : string ;
66 title : string ;
@@ -36,7 +36,7 @@ export const mdToPost = (file: RawFile): PostData => {
3636 datePublished : metadata . data . datePublished || null ,
3737 tags : metadata . data . tags || null ,
3838 description : metadata . data . description || null ,
39- canonicalUrl : metadata . data . canonicalUrl || `${ config . url } /${ path } ` ,
39+ canonicalUrl : metadata . data . canonicalUrl || `${ globals . url } /${ path } ` ,
4040 author : metadata . data . author || null ,
4141 authorPhoto : metadata . data . authorPhoto || null ,
4242 authorTwitter : metadata . data . authorTwitter || null ,
@@ -47,7 +47,8 @@ export const mdToPost = (file: RawFile): PostData => {
4747
4848 if ( ! post . title ) throw new Error ( `Missing required field: title.` ) ;
4949 if ( ! post . content ) throw new Error ( `Missing required field: content.` ) ;
50- if ( ! post . datePublished ) throw new Error ( `Missing required field: datePublished.` ) ;
50+ if ( ! post . datePublished )
51+ throw new Error ( `Missing required field: datePublished.` ) ;
5152
5253 return post as PostData ;
5354} ;
@@ -69,7 +70,8 @@ export const loadPost = async (path: string): Promise<PostData> => {
6970} ;
7071
7172export const loadBlogPosts = async ( ) : Promise < PostData [ ] > => {
72- return await ( await loadMarkdownFiles ( `blog/*.md` ) ) . map ( mdToPost )
73+ return await ( await loadMarkdownFiles ( `blog/*.md` ) )
74+ . map ( mdToPost )
7375 . filter ( ( p ) => p . published )
74- . sort ( ( a , b ) => ( b . datePublished || 0 ) - ( a . datePublished || 0 ) ) ; ;
76+ . sort ( ( a , b ) => ( b . datePublished || 0 ) - ( a . datePublished || 0 ) ) ;
7577} ;
0 commit comments