Skip to content

Commit bb0f22b

Browse files
committed
Adds the ability to specify a current date/time that's different from the actual date/time using a CurrentDateTime setting
1 parent 4f8abec commit bb0f22b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Statiq.Web/Bootstrapper/BootstrapperExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private static TBootstrapper AddDefaultWebSettings<TBootstrapper>(this TBootstra
167167
}
168168
},
169169
{ WebKeys.Xref, Config.FromDocument(doc => doc.GetTitle()?.Replace(' ', '-')) }, // Not all documents have a title (I.e. no title metadata and no source)
170-
{ WebKeys.Excluded, Config.FromDocument(doc => doc.GetDateTime(WebKeys.Published) > DateTime.Now) },
170+
{ WebKeys.Excluded, Config.FromDocument((doc, ctx) => doc.GetDateTime(WebKeys.Published) > ctx.GetCurrentDateTime()) },
171171
{ WebKeys.PublishedUsesLastModifiedDate, true },
172172
{
173173
WebKeys.FrontMatterRegexes,

src/Statiq.Web/IDocumentExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static DateTime GetPublishedDate(this IDocument document, IExecutionConte
5656
}
5757

5858
// If all else fails, use today
59-
return DateTime.Today;
59+
return context.GetCurrentDateTime().Date;
6060
}
6161
}
62-
}
62+
}

0 commit comments

Comments
 (0)