From 791f1009eb67a7e911c0e9f2834b282f382fa8d8 Mon Sep 17 00:00:00 2001 From: Ankur Sheel Date: Sun, 19 Dec 2021 23:32:06 +1300 Subject: [PATCH] feat: show posts in the future for Development environments --- src/StatiqHelpers/Extensions/ContextExtensions.cs | 5 ++++- src/StatiqHelpers/Pipelines/PostPipeline.cs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/StatiqHelpers/Extensions/ContextExtensions.cs b/src/StatiqHelpers/Extensions/ContextExtensions.cs index 3bbf1ac..f5a4c12 100644 --- a/src/StatiqHelpers/Extensions/ContextExtensions.cs +++ b/src/StatiqHelpers/Extensions/ContextExtensions.cs @@ -36,10 +36,13 @@ public static string GetGithubUserName(this IExecutionContext context) => context.GetString("GithubUsername"); public static string? GetGoogleTagManagerId(this IExecutionContext context) - => context.GetString("Environment") != "Development" + => context.IsDevelopment() ? context.GetString("GoogleTagManagerId") : null; + public static bool IsDevelopment(this IExecutionContext context) + => context.GetString("Environment") != "Development"; + public static string? GetGoatCounterCode(this IExecutionContext context) => context.GetString("GoatCounterCode"); } diff --git a/src/StatiqHelpers/Pipelines/PostPipeline.cs b/src/StatiqHelpers/Pipelines/PostPipeline.cs index a2d12f4..9160818 100644 --- a/src/StatiqHelpers/Pipelines/PostPipeline.cs +++ b/src/StatiqHelpers/Pipelines/PostPipeline.cs @@ -1,4 +1,5 @@ using System; +using Polly; using Statiq.Common; using Statiq.Core; using Statiq.Highlight; @@ -27,7 +28,7 @@ public PostPipeline(IReadingTimeService readingTimeService) { new ExtractFrontMatter(new ParseYaml()), new GeneratePostDetailsFromPath(), - new FilterDocuments(Config.FromDocument((document) => document.GetPublishedDate() <= DateTime.Today)), + new FilterDocuments(Config.FromDocument((document, context) => !context.IsDevelopment() || document.GetPublishedDate() <= DateTime.Today)), new GenerateRssMetaData(), new ReplaceInContent( @"!\[(?.*)\]\(./images/(?.*)\)",