File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -109,12 +109,22 @@ module.exports = function (eleventyConfig) {
109109 return collection . filter ( ( item ) => item . data . locale === locale ) ;
110110 } ) ;
111111
112+ // Specific postDate filter for blog posts or other content with strict formatting
112113 eleventyConfig . addFilter ( "postDate" , ( dateObj ) => {
113114 return DateTime . fromJSDate ( dateObj , { zone : "utc" } )
114115 . setLocale ( "en" )
115116 . toFormat ( "yyyy'-'MM'-'dd" ) ;
116117 } ) ;
117118
119+ // Format date filter to display full date
120+ eleventyConfig . addFilter ( "formatDate" , function ( dateObj ) {
121+ const locale = this . ctx . locale || 'en' ; // Use the locale from the context, default to 'en'
122+
123+ return DateTime . fromJSDate ( dateObj , { zone : "utc" } )
124+ . setLocale ( locale )
125+ . toLocaleString ( DateTime . DATE_MED ) ; // Use DATE_MED to exclude the day of the week
126+ } ) ;
127+
118128 eleventyConfig . addPassthroughCopy ( { "./src/_docs" : "docs" } ) ;
119129 eleventyConfig . addPassthroughCopy ( { "./src/_images" : "img" } ) ;
120130 eleventyConfig . addPassthroughCopy ( { "./src/CNAME" : "CNAME" } ) ;
You can’t perform that action at this time.
0 commit comments