Class
Sealed
public sealed class ThemeAssetPhase : IBuildPhase
Namespace: Moka.Docs.Engine.Phases
Writes theme CSS and JS assets to the output directory.
Inheritance
Inherits from: IBuildPhase
Constructors
| Name | Description |
|---|---|
ThemeAssetPhase(ThemeAssetPhase> logger) |
Writes theme CSS and JS assets to the output directory. |
ThemeAssetPhase(ThemeAssetPhase> logger)
ThemeAssetPhase.ThemeAssetPhase(ILogger<ThemeAssetPhase> logger)
Writes theme CSS and JS assets to the output directory.
Properties
Methods
| Name | Description |
|---|---|
ExecuteAsync(BuildContext context, CancellationToken ct) |
Type Relationships
classDiagram
style ThemeAssetPhase fill:#f9f,stroke:#333,stroke-width:2px
ThemeAssetPhase --|> IBuildPhase : inherits
View Source
/// <summary>
/// Writes theme CSS and JS assets to the output directory.
/// </summary>
public sealed class ThemeAssetPhase(ILogger<ThemeAssetPhase> logger) : IBuildPhase
{
/// <inheritdoc/>
public string Name => "ThemeAssets";
/// <inheritdoc/>
public int Order => 1150;
/// <inheritdoc/>
public Task ExecuteAsync(BuildContext context, CancellationToken ct = default)
{
IFileSystem fs = context.FileSystem;
string themeDir = fs.Path.Combine(context.OutputDirectory, "_theme");
// Write embedded CSS
string cssDir = fs.Path.Combine(themeDir, "css");
fs.Directory.CreateDirectory(cssDir);
fs.File.WriteAllText(fs.Path.Combine(cssDir, "main.css"), EmbeddedThemeProvider.GetCss());
// Write embedded JS
string jsDir = fs.Path.Combine(themeDir, "js");
fs.Directory.CreateDirectory(jsDir);
fs.File.WriteAllText(fs.Path.Combine(jsDir, "main.js"), EmbeddedThemeProvider.GetJs());
logger.LogInformation("Wrote theme assets to {Path}", themeDir);
return Task.CompletedTask;
}
}