private void RegisterTocMap(TocItemViewModel item, string key, IDocumentBuildContext context) { var href = item.Href; // Should be original href from working folder starting with ~ if (!PathUtility.IsRelativePath(href)) { return; } context.RegisterToc(key, href); }
private void RegisterTocMap(TocItemViewModel item, string key, IDocumentBuildContext context) { // If tocHref is set, href is originally RelativeFolder type, and href is set to the homepage of TocHref, // So in this case, TocHref should be used to in TocMap // TODO: what if user wants to set TocHref? var tocHref = item.TocHref; var tocHrefType = Utility.GetHrefType(tocHref); if (tocHrefType == HrefType.MarkdownTocFile || tocHrefType == HrefType.YamlTocFile) { context.RegisterToc(key, tocHref); } else { var href = item.Href; // Should be original href from working folder starting with ~ if (Utility.IsSupportedRelativeHref(href)) { context.RegisterToc(key, href); } } }
protected override void RegisterTocMapToContext(TocItemViewModel item, FileModel model, IDocumentBuildContext context) { var key = model.Key; // If tocHref is set, href is originally RelativeFolder type, and href is set to the homepage of TocHref, // So in this case, TocHref should be used to in TocMap // TODO: what if user wants to set TocHref? var tocHref = item.TocHref; var tocHrefType = Utility.GetHrefType(tocHref); if (tocHrefType == HrefType.MarkdownTocFile || tocHrefType == HrefType.YamlTocFile) { context.RegisterToc(key, HttpUtility.UrlDecode(UriUtility.GetPath(tocHref))); } else { var href = item.Href; // Should be original href from working folder starting with ~ if (Utility.IsSupportedRelativeHref(href)) { context.RegisterToc(key, HttpUtility.UrlDecode(UriUtility.GetPath(href))); } } }
public override void UpdateHref(FileModel model, IDocumentBuildContext context) { var toc = (TocViewModel)model.Content; var key = model.Key; // Add current folder to the toc mapping, e.g. `a/` maps to `a/toc` var directory = ((RelativePath)key).GetPathFromWorkingFolder().GetDirectoryPath(); context.RegisterToc(key, directory); if (toc.Count > 0) { foreach (var item in toc) { UpdateTocItemHref(item, model, context); } } }
public override void UpdateHref(FileModel model, IDocumentBuildContext context) { var toc = (TocItemViewModel)model.Content; var key = model.Key; // Add current folder to the toc mapping, e.g. `a/` maps to `a/toc` var directory = ((TypeForwardedToRelativePath)key).GetPathFromWorkingFolder().GetDirectoryPath(); context.RegisterToc(key, directory); UpdateTocItemHref(toc, model, context); var tocInfo = new TocInfo(key); if (toc.Homepage != null) { if (TypeForwardedToPathUtility.IsRelativePath(toc.Homepage)) { var pathToRoot = ((TypeForwardedToRelativePath)model.File + (TypeForwardedToRelativePath)toc.Homepage).GetPathFromWorkingFolder(); tocInfo.Homepage = pathToRoot; } } context.RegisterTocInfo(tocInfo); }
protected override void RegisterTocToContext(TocItemViewModel toc, FileModel model, IDocumentBuildContext context) { var key = model.Key; // Add current folder to the toc mapping, e.g. `a/` maps to `a/toc` var directory = ((RelativePath)key).GetPathFromWorkingFolder().GetDirectoryPath(); context.RegisterToc(key, directory); var tocInfo = new TocInfo(key); if (toc.Homepage != null) { if (PathUtility.IsRelativePath(toc.Homepage)) { var pathToRoot = ((RelativePath)model.File + (RelativePath)toc.Homepage).GetPathFromWorkingFolder(); tocInfo.Homepage = pathToRoot; } } context.RegisterTocInfo(tocInfo); }
private void RegisterTocMap(TocItemViewModel item, string key, IDocumentBuildContext context) { var href = item.Href; // Should be original href from working folder starting with ~ if (!PathUtility.IsRelativePath(href)) return; context.RegisterToc(key, href); }