public bool TryFindContent(PublishedContentRequest contentRequest)
        {
            var site = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot();

            var notFoundNode = site
                               .DescendantsOrSelf(nameof(ErrorPage))
                               .FirstOrDefault(x =>
                                               x.GetPropertyValue <int>(nameof(ErrorPage.ErrorCode)) == 404);

            contentRequest.PublishedContent = notFoundNode;
            contentRequest.SetIs404();

            return(contentRequest.PublishedContent != null);
        }
        public override bool TryFindContent(PublishedContentRequest contentRequest)
        {
            // eg / or /path/to/whatever
            var url = contentRequest.Uri.GetAbsolutePathDecoded();

            var mdRoot = "/" + MarkdownLogic.BaseUrl;

            if (url.StartsWith("/projects/umbraco-pro/contour/documentation"))
            {
                mdRoot = "/projects";
            }

            // ensure it's a md url
            if (url.StartsWith(mdRoot) == false)
            {
                return(false); // not for us
            }
            // find the root content
            var node = FindContent(contentRequest, mdRoot);

            if (node == null)
            {
                return(false);
            }

            // kill those old urls
            foreach (var s in new [] { "master", "v480" })
            {
                if (url.StartsWith(mdRoot + "/" + s))
                {
                    url = url.Replace(mdRoot + "/" + s, mdRoot);
                    contentRequest.SetRedirectPermanent(url);
                    return(true);
                }
            }

            // find the md file
            var mdFilepath = FindMarkdownFile(url);

            //return the broken link doc page
            var is404 = false;

            if (mdFilepath == null)
            {
                mdFilepath = FindMarkdownFile("/documentation/broken-link");
                is404      = true;
            }
            if (mdFilepath == null)
            {
                // clear the published content (that was set by FindContent) to cause a 404, and in
                // both case return 'true' because there's no point other finders try to handle the request
                contentRequest.PublishedContent = null;
                return(true);
            }

            if (is404)
            {
                contentRequest.SetIs404();
            }

            // set the context vars
            var httpContext = contentRequest.RoutingContext.UmbracoContext.HttpContext;

            httpContext.Items[MarkdownLogic.MarkdownPathKey] = mdFilepath;
            httpContext.Items["topicTitle"] = string.Join(" - ", httpContext.Request.RawUrl
                                                          .Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)
                                                          .Skip(1)
                                                          .Reverse());

            // override the template
            const string altTemplate   = "DocumentationSubpage";
            var          templateIsSet = contentRequest.TrySetTemplate(altTemplate);

            //httpContext.Trace.Write("Markdown Files Handler",
            //    string.Format("Template changed to: '{0}' is {1}", altTemplate, templateIsSet));

            // be happy
            return(true);
        }