@@ -65,6 +65,7 @@ | |||||
<Compile Include="Properties\AssemblyInfo.cs" /> | <Compile Include="Properties\AssemblyInfo.cs" /> | ||||
<Compile Include="SearchIndexEntry.cs" /> | <Compile Include="SearchIndexEntry.cs" /> | ||||
<Compile Include="SimpleNavigationElement.cs" /> | <Compile Include="SimpleNavigationElement.cs" /> | ||||
<Compile Include="INavigationElementExtensions.cs" /> | |||||
<Compile Include="Utils.cs" /> | <Compile Include="Utils.cs" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -0,0 +1,27 @@ | |||||
using System; | |||||
using System.Web; | |||||
namespace Docnet | |||||
{ | |||||
public static class INavigationElementExtensions | |||||
{ | |||||
/// <summary> | |||||
/// Gets the final URL by encoding the path and by removing the filename if it equals <c>index.htm</c>. | |||||
/// </summary> | |||||
/// <param name="navigationElement">The navigation element.</param> | |||||
/// <param name="pathSpecification">The path specification.</param> | |||||
/// <returns></returns> | |||||
public static string GetFinalTargetUrl(this INavigationElement navigationElement, PathSpecification pathSpecification) | |||||
{ | |||||
var targetUrl = navigationElement.GetTargetURL(pathSpecification); | |||||
var link = HttpUtility.UrlPathEncode(targetUrl); | |||||
if (link.EndsWith("index.htm", StringComparison.InvariantCultureIgnoreCase)) | |||||
{ | |||||
link = link.Substring(0, link.Length - "index.htm".Length); | |||||
} | |||||
return link; | |||||
} | |||||
} | |||||
} |
@@ -180,14 +180,8 @@ namespace Docnet | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
var link = HttpUtility.UrlPathEncode(indexElement.GetTargetURL(pathSpecification)); | |||||
if (link.EndsWith("index.htm",StringComparison.InvariantCultureIgnoreCase)) | |||||
{ | |||||
link = link.Substring(0, link.Length - "index.htm".Length); | |||||
} | |||||
fragments.Add(string.Format("{0}<a href=\"{1}{2}\">{3}</a></span></li>", | fragments.Add(string.Format("{0}<a href=\"{1}{2}\">{3}</a></span></li>", | ||||
elementStartTag, relativePathToRoot, link, this.Name)); | |||||
elementStartTag, relativePathToRoot, indexElement.GetFinalTargetUrl(pathSpecification), this.Name)); | |||||
} | } | ||||
} | } | ||||
// then the elements in the container. Index elements are skipped here. | // then the elements in the container. Index elements are skipped here. | ||||
@@ -199,15 +193,9 @@ namespace Docnet | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
var link = HttpUtility.UrlPathEncode(this.GetTargetURL(pathSpecification)); | |||||
if (link.EndsWith("index.htm", StringComparison.InvariantCultureIgnoreCase)) | |||||
{ | |||||
link = link.Substring(0, link.Length - "index.htm".Length); | |||||
} | |||||
// just a link | // just a link | ||||
fragments.Add(string.Format("<span class=\"navigationgroup\"><i class=\"fa fa-caret-right\"></i> <a href=\"{0}{1}\">{2}</a></span>", | fragments.Add(string.Format("<span class=\"navigationgroup\"><i class=\"fa fa-caret-right\"></i> <a href=\"{0}{1}\">{2}</a></span>", | ||||
relativePathToRoot, link, this.Name)); | |||||
relativePathToRoot, this.GetFinalTargetUrl(pathSpecification), this.Name)); | |||||
} | } | ||||
if (!this.IsRoot) | if (!this.IsRoot) | ||||
{ | { | ||||
@@ -89,7 +89,8 @@ namespace Docnet | |||||
{ | { | ||||
continue; | continue; | ||||
} | } | ||||
defaultMarkdown.AppendFormat("* [{0}]({1}{2}){3}", sibling.Name, relativePathToRoot, HttpUtility.UrlPathEncode(sibling.GetTargetURL(pathSpecification)), Environment.NewLine); | |||||
defaultMarkdown.AppendFormat("* [{0}]({1}{2}){3}", sibling.Name, relativePathToRoot, | |||||
sibling.GetFinalTargetUrl(pathSpecification), Environment.NewLine); | |||||
} | } | ||||
defaultMarkdown.Append(Environment.NewLine); | defaultMarkdown.Append(Environment.NewLine); | ||||
content = Utils.ConvertMarkdownToHtml(defaultMarkdown.ToString(), Path.GetDirectoryName(destinationFile), activeConfig.Destination, string.Empty, _relativeH2LinksOnPage, activeConfig.ConvertLocalLinks); | content = Utils.ConvertMarkdownToHtml(defaultMarkdown.ToString(), Path.GetDirectoryName(destinationFile), activeConfig.Destination, string.Empty, _relativeH2LinksOnPage, activeConfig.ConvertLocalLinks); | ||||
@@ -189,7 +190,7 @@ namespace Docnet | |||||
string.IsNullOrWhiteSpace(liClass) ? string.Empty : string.Format(" class=\"{0}\"", liClass), | string.IsNullOrWhiteSpace(liClass) ? string.Empty : string.Format(" class=\"{0}\"", liClass), | ||||
string.IsNullOrWhiteSpace(aClass) ? string.Empty : string.Format(" class=\"{0}\"", aClass), | string.IsNullOrWhiteSpace(aClass) ? string.Empty : string.Format(" class=\"{0}\"", aClass), | ||||
relativePathToRoot, | relativePathToRoot, | ||||
HttpUtility.UrlPathEncode(this.GetTargetURL(pathSpecification)), | |||||
this.GetFinalTargetUrl(pathSpecification), | |||||
this.Name)); | this.Name)); | ||||
if(isCurrent && _relativeH2LinksOnPage.Any()) | if(isCurrent && _relativeH2LinksOnPage.Any()) | ||||
{ | { | ||||