diff --git a/src/Elastic.Markdown/BuildContext.cs b/src/Elastic.Markdown/BuildContext.cs index 04932301..7c23577a 100644 --- a/src/Elastic.Markdown/BuildContext.cs +++ b/src/Elastic.Markdown/BuildContext.cs @@ -30,6 +30,9 @@ public string? UrlPathPrefix init => _urlPathPrefix = value; } + // This property is used to determine if the site should be indexed by search engines + public bool AllowIndexing { get; init; } + private readonly string? _urlPathPrefix; public BuildContext(IFileSystem fileSystem) diff --git a/src/Elastic.Markdown/Slices/HtmlWriter.cs b/src/Elastic.Markdown/Slices/HtmlWriter.cs index 8f0a2525..aac30edf 100644 --- a/src/Elastic.Markdown/Slices/HtmlWriter.cs +++ b/src/Elastic.Markdown/Slices/HtmlWriter.cs @@ -65,7 +65,8 @@ public async Task RenderLayout(MarkdownFile markdown, Cancel ctx = defau NavigationHtml = navigationHtml, UrlPathPrefix = markdown.UrlPathPrefix, Applies = markdown.YamlFrontMatter?.AppliesTo, - GithubEditUrl = editUrl + GithubEditUrl = editUrl, + AllowIndexing = DocumentationSet.Context.AllowIndexing }); return await slice.RenderAsync(cancellationToken: ctx); } diff --git a/src/Elastic.Markdown/Slices/Index.cshtml b/src/Elastic.Markdown/Slices/Index.cshtml index 9dc916fa..0a03dbc5 100644 --- a/src/Elastic.Markdown/Slices/Index.cshtml +++ b/src/Elastic.Markdown/Slices/Index.cshtml @@ -11,7 +11,8 @@ Next = Model.NextDocument, NavigationHtml = Model.NavigationHtml, UrlPathPrefix = Model.UrlPathPrefix, - GithubEditUrl = Model.GithubEditUrl + GithubEditUrl = Model.GithubEditUrl, + AllowIndexing = Model.AllowIndexing, }; }
diff --git a/src/Elastic.Markdown/Slices/Layout/_Head.cshtml b/src/Elastic.Markdown/Slices/Layout/_Head.cshtml index 4f34bc82..3b8e90ed 100644 --- a/src/Elastic.Markdown/Slices/Layout/_Head.cshtml +++ b/src/Elastic.Markdown/Slices/Layout/_Head.cshtml @@ -2,6 +2,7 @@ + @Model.Title diff --git a/src/Elastic.Markdown/Slices/_ViewModels.cs b/src/Elastic.Markdown/Slices/_ViewModels.cs index 5d4b02cf..3e89a70f 100644 --- a/src/Elastic.Markdown/Slices/_ViewModels.cs +++ b/src/Elastic.Markdown/Slices/_ViewModels.cs @@ -20,6 +20,7 @@ public class IndexViewModel public required string? UrlPathPrefix { get; init; } public required string? GithubEditUrl { get; init; } public required Deployment? Applies { get; init; } + public required bool AllowIndexing { get; init; } } public class LayoutViewModel @@ -33,6 +34,7 @@ public class LayoutViewModel public required string NavigationHtml { get; set; } public required string? UrlPathPrefix { get; set; } public required string? GithubEditUrl { get; set; } + public required bool AllowIndexing { get; init; } private MarkdownFile[]? _parents; public MarkdownFile[] Parents diff --git a/src/docs-builder/Cli/Commands.cs b/src/docs-builder/Cli/Commands.cs index 9554b26c..d9de0d02 100644 --- a/src/docs-builder/Cli/Commands.cs +++ b/src/docs-builder/Cli/Commands.cs @@ -40,6 +40,7 @@ public async Task Serve(string? path = null, Cancel ctx = default) /// Specifies the path prefix for urls /// Force a full rebuild of the destination folder /// Treat warnings as errors and fail the build on warnings + /// Allow indexing and following of html files /// [Command("generate")] [ConsoleAppFilter] @@ -50,6 +51,7 @@ public async Task Generate( string? pathPrefix = null, bool? force = null, bool? strict = null, + bool? allowIndexing = null, Cancel ctx = default ) { @@ -59,7 +61,8 @@ public async Task Generate( { UrlPathPrefix = pathPrefix, Force = force ?? false, - Collector = new ConsoleDiagnosticsCollector(logger, githubActionsService) + Collector = new ConsoleDiagnosticsCollector(logger, githubActionsService), + AllowIndexing = allowIndexing != null }; var set = new DocumentationSet(context); var generator = new DocumentationGenerator(set, logger); @@ -81,6 +84,7 @@ public async Task Generate( /// Specifies the path prefix for urls /// Force a full rebuild of the destination folder /// Treat warnings as errors and fail the build on warnings + /// Allow indexing and following of html files /// [Command("")] [ConsoleAppFilter] @@ -91,7 +95,8 @@ public async Task GenerateDefault( string? pathPrefix = null, bool? force = null, bool? strict = null, + bool? allowIndexing = null, Cancel ctx = default ) => - await Generate(path, output, pathPrefix, force, strict, ctx); + await Generate(path, output, pathPrefix, force, strict, allowIndexing, ctx); }