using System; namespace Volo.Docs { public class DocsUiOptions { private string _routePrefix = "documents"; /// /// Default value: "documents"; /// public string RoutePrefix { get => GetFormattedRoutePrefix(); set => _routePrefix = value; } /// /// Allows user to see a combobox in user interface for swapping across projects /// Default value: True; /// public bool ShowProjectsCombobox = true; /// /// Allows user to see a label in user interface for projects combobox /// Default value: True; /// public bool ShowProjectsComboboxLabel = true; /// /// If true, allows to create sections in document and show/hide sections according to user preferences. /// Default value: True; /// public bool SectionRendering = true; public bool MultiLanguageMode { get; set; } = true; public SingleProjectModeOptions SingleProjectMode { get; } = new (); public bool EnableEnlargeImage { get; set; } = true; public Func DocumentLinksNormalizer { get; set; } = link => { if (!link.EndsWith("/Index", StringComparison.OrdinalIgnoreCase)) { return link; } return link.Substring(0, link.LastIndexOf("/Index", StringComparison.OrdinalIgnoreCase)); }; public Func RedirectUrlResolver { get; set; } = url => { if (!url.EndsWith("/Index", StringComparison.OrdinalIgnoreCase)) { return null; } return url.Substring(0, url.LastIndexOf("/Index", StringComparison.OrdinalIgnoreCase)); }; public string? GetRedirectUrlIfNeeded(string url) { return RedirectUrlResolver.Invoke(url); } private string GetFormattedRoutePrefix() { if (string.IsNullOrWhiteSpace(_routePrefix)) { return "/"; } return _routePrefix.EnsureEndsWith('/').EnsureStartsWith('/'); } } public class SingleProjectModeOptions { /// /// Determines whether to enable single project mode by removing the project name from the routing. /// When enabled, only a single project is allowed within the module. /// public bool Enable { get; set; } public string ProjectName { get; set; } } }