diff --git a/RELEASE.md b/RELEASE.md index 88c224c4..71577157 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,6 +1,7 @@ # 1.0.0-beta.72 - Added an improved warning message and early exit out of recursive settings expansion. +- Added a `MediaTypes.IsMediaType()` method to help determine if a given path matches specified media type(s). # 1.0.0-beta.71 diff --git a/src/core/Statiq.Common/Content/MediaTypes.cs b/src/core/Statiq.Common/Content/MediaTypes.cs index 484d3abc..f0958d05 100644 --- a/src/core/Statiq.Common/Content/MediaTypes.cs +++ b/src/core/Statiq.Common/Content/MediaTypes.cs @@ -1127,5 +1127,17 @@ public static string Get(string path, bool defaultIfNotFound = true) => /// The extensions that result in the specified media type. public static IEnumerable GetExtensions(string mediaType) => ExtensionMappings.Where(x => x.Value.Equals(mediaType, StringComparison.OrdinalIgnoreCase)).Select(x => x.Key); + + /// + /// Checks whether the given path is of the specified media type(s). + /// + /// The path to check. + /// The media types of check. + /// true if the path is of the specified media type(s), false otherwise. + public static bool IsMediaType(string path, params string[] mediaTypes) + { + string pathMediaType = Get(path); + return mediaTypes.Any(x => x.Equals(pathMediaType, StringComparison.OrdinalIgnoreCase)); + } } } \ No newline at end of file diff --git a/src/core/Statiq.Core/Modules/Control/CacheDocuments.cs b/src/core/Statiq.Core/Modules/Control/CacheDocuments.cs index d6c1bb60..7a7cc11b 100644 --- a/src/core/Statiq.Core/Modules/Control/CacheDocuments.cs +++ b/src/core/Statiq.Core/Modules/Control/CacheDocuments.cs @@ -142,7 +142,7 @@ protected override async Task> ExecuteContextAsync(IExecu return await context.ExecuteModulesAsync(Children, context.Inputs); } - // If we're reseting the cache, reset it but then continue + // If we're resetting the cache, reset it but then continue if (context.Settings.GetBool(Keys.ResetCache)) { context.LogInformation($"Resetting cache due to {nameof(Keys.ResetCache)} metadata");