public static string GetState(this RoutedContentBase post, bool isDraft)
        {
            if (post.Created == DateTime.MinValue)
            {
                return(ContentState.New);
            }

            if (post.Published.HasValue)
            {
                return(isDraft ? ContentState.Draft : ContentState.Published);
            }

            return(ContentState.Unpublished);
        }
        /// <summary>
        /// Handles HTTP Caching Headers and checks if the client has the
        /// latest version in cache.
        /// </summary>
        /// <param name="context">The HTTP Cache</param>
        /// <param name="site">The current site</param>
        /// <param name="content">The current content</param>
        /// <param name="expires">How many minutes the cache should be valid</param>
        /// <returns>If the client has the latest version</returns>
        public bool HandleCache(HttpContext context, Site site, RoutedContentBase content, int expires)
        {
            var headers = context.Response.GetTypedHeaders();

            if (expires > 0 && content.Published.HasValue)
            {
                _logger?.LogDebug($"Setting HTTP Cache for [{ content.Slug }]");

                var lastModified = !site.ContentLastModified.HasValue || content.LastModified > site.ContentLastModified
                    ? content.LastModified : site.ContentLastModified.Value;
                var etag = Utils.GenerateETag(content.Id.ToString(), lastModified);

                headers.CacheControl = new CacheControlHeaderValue
                {
                    Public = true,
                    MaxAge = TimeSpan.FromMinutes(expires),
                };
                headers.ETag         = new EntityTagHeaderValue(etag);
                headers.LastModified = lastModified;

                if (HttpCaching.IsCached(context, etag, lastModified))
                {
                    _logger?.LogInformation("Client has current version. Setting NotModified");
                    context.Response.StatusCode = 304;

                    return(true);
                }
            }
            else
            {
                _logger?.LogDebug($"Setting HTTP NoCache for [{ content.Slug }]");

                headers.CacheControl = new CacheControlHeaderValue
                {
                    NoCache = true
                };
            }
            return(false);
        }