public static class MokaDefaults
Namespace: Moka.Docs.Core
Properties
| Name | Description |
|---|---|
CleanOutput static |
Clean output directory before build. |
CodeStyle static |
Default code block window style (plain, macos, terminal, vscode). |
CodeTheme static |
Default code syntax theme. |
EnableAiSearch static |
Enable AI-powered semantic search. |
EnableAnalytics static |
Enable analytics dashboard. |
EnableCloudFeatures static |
Enable cloud features (requires license). |
EnableCustomDomain static |
Enable custom domain support. |
EnablePdfExport static |
Enable PDF export. |
EnableWhiteLabel static |
Enable white-labeling (remove MokaDocs branding). |
GenerateRobots static |
Generate robots.txt by default. |
GenerateSitemap static |
Generate sitemap.xml by default. |
PrimaryColor static |
Default primary color (hex). |
SearchEnabled static |
Enable search by default. |
SearchProvider static |
Default search provider. |
ShowAnimations static |
Show page animations (fade-in, slide-up, etc). |
ShowBackToTop static |
Show the back-to-top button. |
ShowBreadcrumbs static |
Show breadcrumb navigation. |
ShowBuiltWith static |
Show "Built with MokaDocs" branding and version in the footer. |
ShowCodeStyleSelector static |
Show the code block window style selector in the header. |
ShowCodeThemeSelector static |
Show the code syntax theme selector in the header. |
ShowColorThemeSelector static |
Show the color theme palette selector in the header. |
ShowCopyButton static |
Show copy button on code blocks. |
ShowDarkModeToggle static |
Show the dark/light mode toggle. |
ShowEditLink static |
Show "Edit on GitHub" link. |
ShowFeedbackWidget static |
Show the "Was this page helpful?" feedback widget. |
ShowLastUpdated static |
Show "Last updated" date on pages. |
ShowLineNumbers static |
Show line numbers on code blocks. |
ShowPrevNext static |
Show Previous/Next navigation at bottom of pages. |
ShowSearch static |
Show the search bar and Ctrl+K shortcut. |
ShowTableOfContents static |
Show the table of contents sidebar. |
ShowVersionSelector static |
Show the version selector dropdown. |
ThemeName static |
Default theme name. |
TocDepth static |
Maximum heading level shown in the table of contents (2–6). |
CleanOutput
bool MokaDefaults.CleanOutput { get; set; }
Clean output directory before build.
CodeStyle
string MokaDefaults.CodeStyle { get; set; }
Default code block window style (plain, macos, terminal, vscode).
CodeTheme
string MokaDefaults.CodeTheme { get; set; }
Default code syntax theme.
EnableAiSearch
bool MokaDefaults.EnableAiSearch { get; set; }
Enable AI-powered semantic search.
EnableAnalytics
bool MokaDefaults.EnableAnalytics { get; set; }
Enable analytics dashboard.
EnableCloudFeatures
bool MokaDefaults.EnableCloudFeatures { get; set; }
Enable cloud features (requires license).
EnableCustomDomain
bool MokaDefaults.EnableCustomDomain { get; set; }
Enable custom domain support.
EnablePdfExport
bool MokaDefaults.EnablePdfExport { get; set; }
Enable PDF export.
EnableWhiteLabel
bool MokaDefaults.EnableWhiteLabel { get; set; }
Enable white-labeling (remove MokaDocs branding).
GenerateRobots
bool MokaDefaults.GenerateRobots { get; set; }
Generate robots.txt by default.
GenerateSitemap
bool MokaDefaults.GenerateSitemap { get; set; }
Generate sitemap.xml by default.
PrimaryColor
string MokaDefaults.PrimaryColor { get; set; }
Default primary color (hex).
SearchEnabled
bool MokaDefaults.SearchEnabled { get; set; }
Enable search by default.
SearchProvider
string MokaDefaults.SearchProvider { get; set; }
Default search provider.
ShowAnimations
bool MokaDefaults.ShowAnimations { get; set; }
Show page animations (fade-in, slide-up, etc).
ShowBackToTop
bool MokaDefaults.ShowBackToTop { get; set; }
Show the back-to-top button.
ShowBreadcrumbs
bool MokaDefaults.ShowBreadcrumbs { get; set; }
Show breadcrumb navigation.
ShowBuiltWith
bool MokaDefaults.ShowBuiltWith { get; set; }
Show "Built with MokaDocs" branding and version in the footer.
ShowCodeStyleSelector
bool MokaDefaults.ShowCodeStyleSelector { get; set; }
Show the code block window style selector in the header.
ShowCodeThemeSelector
bool MokaDefaults.ShowCodeThemeSelector { get; set; }
Show the code syntax theme selector in the header.
ShowColorThemeSelector
bool MokaDefaults.ShowColorThemeSelector { get; set; }
Show the color theme palette selector in the header.
ShowCopyButton
bool MokaDefaults.ShowCopyButton { get; set; }
Show copy button on code blocks.
ShowDarkModeToggle
bool MokaDefaults.ShowDarkModeToggle { get; set; }
Show the dark/light mode toggle.
ShowEditLink
bool MokaDefaults.ShowEditLink { get; set; }
Show "Edit on GitHub" link.
ShowFeedbackWidget
bool MokaDefaults.ShowFeedbackWidget { get; set; }
Show the "Was this page helpful?" feedback widget.
ShowLastUpdated
bool MokaDefaults.ShowLastUpdated { get; set; }
Show "Last updated" date on pages.
ShowLineNumbers
bool MokaDefaults.ShowLineNumbers { get; set; }
Show line numbers on code blocks.
ShowPrevNext
bool MokaDefaults.ShowPrevNext { get; set; }
Show Previous/Next navigation at bottom of pages.
ShowSearch
bool MokaDefaults.ShowSearch { get; set; }
Show the search bar and Ctrl+K shortcut.
ShowTableOfContents
bool MokaDefaults.ShowTableOfContents { get; set; }
Show the table of contents sidebar.
ShowVersionSelector
bool MokaDefaults.ShowVersionSelector { get; set; }
Show the version selector dropdown.
ThemeName
string MokaDefaults.ThemeName { get; set; }
Default theme name.
TocDepth
int MokaDefaults.TocDepth { get; set; }
Maximum heading level shown in the table of contents (2–6).
Methods
| Name | Description |
|---|---|
Resolve(string envVarName, T defaultValue) static |
Resolves a default value with environment variable override. Environment variables use the pattern: MOKADOCS_PROPERTY_NAME e.g., MOKADOCS_SHOW_COLOR_THEME_SELECTOR, MOKADOCS_PRIMARY_COLOR |
ResolveBool(…) static |
Resolves a bool value: env var > yaml config > MokaDefaults. |
ResolveInt(…) static |
Resolves an int value: env var > yaml config > MokaDefaults. |
ResolveString(…) static |
Resolves a string value: env var > yaml config > MokaDefaults. |
Resolve(string envVarName, T defaultValue)
T MokaDefaults.Resolve<T>(string envVarName, T defaultValue)
Resolves a default value with environment variable override. Environment variables use the pattern: MOKADOCS_PROPERTY_NAME e.g., MOKADOCS_SHOW_COLOR_THEME_SELECTOR, MOKADOCS_PRIMARY_COLOR
Parameters
| Name | Type | Description |
|---|---|---|
envVarName | string | The environment variable suffix (without MOKADOCS_ prefix). |
defaultValue | T | The default value if no environment variable is set. |
Returns: The resolved value.
ResolveBool(string envVarName, bool? yamlValue, bool defaultValue)
bool MokaDefaults.ResolveBool(string envVarName, bool? yamlValue, bool defaultValue)
Resolves a bool value: env var > yaml config > MokaDefaults.
Parameters
| Name | Type | Description |
|---|---|---|
envVarName | string | The environment variable suffix (without MOKADOCS_ prefix). |
yamlValue | bool? | The value from the user's YAML config, or null if not specified. |
defaultValue | bool | The default value from MokaDefaults. |
Returns: The resolved boolean value.
ResolveInt(string envVarName, int? yamlValue, int defaultValue)
int MokaDefaults.ResolveInt(string envVarName, int? yamlValue, int defaultValue)
Resolves an int value: env var > yaml config > MokaDefaults.
Parameters
| Name | Type | Description |
|---|---|---|
envVarName | string | The environment variable suffix (without MOKADOCS_ prefix). |
yamlValue | int? | The value from the user's YAML config, or null if not specified. |
defaultValue | int | The default value from MokaDefaults. |
Returns: The resolved int value.
ResolveString(string envVarName, string? yamlValue, string defaultValue)
string MokaDefaults.ResolveString(string envVarName, string? yamlValue, string defaultValue)
Resolves a string value: env var > yaml config > MokaDefaults.
Parameters
| Name | Type | Description |
|---|---|---|
envVarName | string | The environment variable suffix (without MOKADOCS_ prefix). |
yamlValue | string? | The value from the user's YAML config, or null if not specified. |
defaultValue | string | The default value from MokaDefaults. |
Returns: The resolved string value.
View Source
/// <summary>
/// Central defaults for MokaDocs. The library author sets these to control
/// what ships as the default experience. Users override via mokadocs.yaml,
/// and environment variables override everything.
/// Priority: Environment Variable > User YAML Config > MokaDefaults
/// </summary>
public static class MokaDefaults
{
#region UI Feature Toggles
/// <summary>Show the color theme palette selector in the header.</summary>
public static bool ShowColorThemeSelector { get; set; } = true;
/// <summary>Show the code syntax theme selector in the header.</summary>
public static bool ShowCodeThemeSelector { get; set; } = false;
/// <summary>Show the code block window style selector in the header.</summary>
public static bool ShowCodeStyleSelector { get; set; } = false;
/// <summary>Show the "Was this page helpful?" feedback widget.</summary>
public static bool ShowFeedbackWidget { get; set; } = true;
/// <summary>Show the version selector dropdown.</summary>
public static bool ShowVersionSelector { get; set; } = true;
/// <summary>Show "Built with MokaDocs" branding and version in the footer.</summary>
public static bool ShowBuiltWith { get; set; } = true;
/// <summary>Show the dark/light mode toggle.</summary>
public static bool ShowDarkModeToggle { get; set; } = true;
/// <summary>Show page animations (fade-in, slide-up, etc).</summary>
public static bool ShowAnimations { get; set; } = false;
/// <summary>Show the search bar and Ctrl+K shortcut.</summary>
public static bool ShowSearch { get; set; } = true;
/// <summary>Show the table of contents sidebar.</summary>
public static bool ShowTableOfContents { get; set; } = true;
/// <summary>Show "Last updated" date on pages.</summary>
public static bool ShowLastUpdated { get; set; } = true;
/// <summary>Show "Edit on GitHub" link.</summary>
public static bool ShowEditLink { get; set; } = false;
/// <summary>Show Previous/Next navigation at bottom of pages.</summary>
public static bool ShowPrevNext { get; set; } = true;
/// <summary>Show breadcrumb navigation.</summary>
public static bool ShowBreadcrumbs { get; set; } = true;
/// <summary>Show the back-to-top button.</summary>
public static bool ShowBackToTop { get; set; } = true;
/// <summary>Show copy button on code blocks.</summary>
public static bool ShowCopyButton { get; set; } = true;
/// <summary>Show line numbers on code blocks.</summary>
public static bool ShowLineNumbers { get; set; } = true;
/// <summary>Maximum heading level shown in the table of contents (2–6).</summary>
public static int TocDepth { get; set; } = 3;
#endregion
#region Theme Defaults
/// <summary>Default primary color (hex).</summary>
public static string PrimaryColor { get; set; } = "#0ea5e9";
/// <summary>Default code syntax theme.</summary>
public static string CodeTheme { get; set; } = "catppuccin-mocha";
/// <summary>Default code block window style (plain, macos, terminal, vscode).</summary>
public static string CodeStyle { get; set; } = "plain";
/// <summary>Default theme name.</summary>
public static string ThemeName { get; set; } = "default";
#endregion
#region Build Defaults
/// <summary>Generate sitemap.xml by default.</summary>
public static bool GenerateSitemap { get; set; } = true;
/// <summary>Generate robots.txt by default.</summary>
public static bool GenerateRobots { get; set; } = true;
/// <summary>Clean output directory before build.</summary>
public static bool CleanOutput { get; set; } = true;
#endregion
#region Feature Defaults
/// <summary>Enable search by default.</summary>
public static bool SearchEnabled { get; set; } = true;
/// <summary>Default search provider.</summary>
public static string SearchProvider { get; set; } = "flexsearch";
#endregion
#region Cloud/Premium Features
/// <summary>Enable cloud features (requires license).</summary>
public static bool EnableCloudFeatures { get; set; } = false;
/// <summary>Enable analytics dashboard.</summary>
public static bool EnableAnalytics { get; set; } = false;
/// <summary>Enable AI-powered semantic search.</summary>
public static bool EnableAiSearch { get; set; } = false;
/// <summary>Enable PDF export.</summary>
public static bool EnablePdfExport { get; set; } = false;
/// <summary>Enable custom domain support.</summary>
public static bool EnableCustomDomain { get; set; } = false;
/// <summary>Enable white-labeling (remove MokaDocs branding).</summary>
public static bool EnableWhiteLabel { get; set; } = false;
#endregion
#region Environment Variable Resolution
private const string _envPrefix = "MOKADOCS_";
/// <summary>
/// Resolves a default value with environment variable override.
/// Environment variables use the pattern: MOKADOCS_PROPERTY_NAME
/// e.g., MOKADOCS_SHOW_COLOR_THEME_SELECTOR, MOKADOCS_PRIMARY_COLOR
/// </summary>
/// <typeparam name = "T">The type of value to resolve.</typeparam>
/// <param name = "envVarName">The environment variable suffix (without MOKADOCS_ prefix).</param>
/// <param name = "defaultValue">The default value if no environment variable is set.</param>
/// <returns>The resolved value.</returns>
public static T Resolve<T>(string envVarName, T defaultValue)
{
string? envValue = Environment.GetEnvironmentVariable(_envPrefix + envVarName);
if (string.IsNullOrEmpty(envValue))
{
return defaultValue;
}
Type targetType = typeof(T);
if (targetType == typeof(bool))
{
return (T)(object)ParseBool(envValue, (bool)(object)defaultValue!);
}
if (targetType == typeof(string))
{
return (T)(object)envValue;
}
if (targetType == typeof(int) && int.TryParse(envValue, out int intVal))
{
return (T)(object)intVal;
}
return defaultValue;
}
/// <summary>
/// Resolves a bool value: env var > yaml config > MokaDefaults.
/// </summary>
/// <param name = "envVarName">The environment variable suffix (without MOKADOCS_ prefix).</param>
/// <param name = "yamlValue">The value from the user's YAML config, or null if not specified.</param>
/// <param name = "defaultValue">The default value from MokaDefaults.</param>
/// <returns>The resolved boolean value.</returns>
public static bool ResolveBool(string envVarName, bool? yamlValue, bool defaultValue)
{
string? envValue = Environment.GetEnvironmentVariable(_envPrefix + envVarName);
if (!string.IsNullOrEmpty(envValue))
{
return ParseBool(envValue, defaultValue);
}
return yamlValue ?? defaultValue;
}
/// <summary>
/// Resolves a string value: env var > yaml config > MokaDefaults.
/// </summary>
/// <param name = "envVarName">The environment variable suffix (without MOKADOCS_ prefix).</param>
/// <param name = "yamlValue">The value from the user's YAML config, or null if not specified.</param>
/// <param name = "defaultValue">The default value from MokaDefaults.</param>
/// <returns>The resolved string value.</returns>
public static string ResolveString(string envVarName, string? yamlValue, string defaultValue)
{
string? envValue = Environment.GetEnvironmentVariable(_envPrefix + envVarName);
if (!string.IsNullOrEmpty(envValue))
{
return envValue;
}
return yamlValue ?? defaultValue;
}
/// <summary>
/// Resolves an int value: env var > yaml config > MokaDefaults.
/// </summary>
/// <param name = "envVarName">The environment variable suffix (without MOKADOCS_ prefix).</param>
/// <param name = "yamlValue">The value from the user's YAML config, or null if not specified.</param>
/// <param name = "defaultValue">The default value from MokaDefaults.</param>
/// <returns>The resolved int value.</returns>
public static int ResolveInt(string envVarName, int? yamlValue, int defaultValue)
{
string? envValue = Environment.GetEnvironmentVariable(_envPrefix + envVarName);
if (!string.IsNullOrEmpty(envValue) && int.TryParse(envValue, out int parsed))
{
return parsed;
}
return yamlValue ?? defaultValue;
}
private static bool ParseBool(string value, bool fallback)
{
return value.Trim().ToLowerInvariant() switch
{
"true" or "1" or "yes" => true,
"false" or "0" or "no" => false,
_ => fallback
};
}
#endregion
}