diff --git a/docs/source/elastic/semantic-search/amazon-bedrock.md b/docs/source/elastic/semantic-search/amazon-bedrock.md index 969501ac..57fd5d36 100644 --- a/docs/source/elastic/semantic-search/amazon-bedrock.md +++ b/docs/source/elastic/semantic-search/amazon-bedrock.md @@ -1,5 +1,6 @@ --- title: "Semantic search with the inference API" +navigation_title: "Amazon Bedrock" --- Semantic search helps you find data based on the intent and contextual meaning of a search query, instead of a match on query terms (lexical search). diff --git a/docs/source/elastic/semantic-search/azure-ai-studio.md b/docs/source/elastic/semantic-search/azure-ai-studio.md index bb3e3db3..d9ec6de3 100644 --- a/docs/source/elastic/semantic-search/azure-ai-studio.md +++ b/docs/source/elastic/semantic-search/azure-ai-studio.md @@ -1,5 +1,6 @@ --- title: "Semantic search with the inference API" +navigation_title: "Azure AI Studio" --- Semantic search helps you find data based on the intent and contextual meaning of a search query, instead of a match on query terms (lexical search). diff --git a/docs/source/elastic/semantic-search/azure-openai.md b/docs/source/elastic/semantic-search/azure-openai.md index 4033acde..5a3e8077 100644 --- a/docs/source/elastic/semantic-search/azure-openai.md +++ b/docs/source/elastic/semantic-search/azure-openai.md @@ -1,5 +1,6 @@ --- title: "Semantic search with the inference API" +navigation_title: "Azure OpenAI" --- Semantic search helps you find data based on the intent and contextual meaning of a search query, instead of a match on query terms (lexical search). diff --git a/docs/source/elastic/semantic-search/cohere.md b/docs/source/elastic/semantic-search/cohere.md index 3287f3b0..9909a7e8 100644 --- a/docs/source/elastic/semantic-search/cohere.md +++ b/docs/source/elastic/semantic-search/cohere.md @@ -1,5 +1,6 @@ --- title: "Semantic search with the inference API" +navigation_title: "Cohere" --- Semantic search helps you find data based on the intent and contextual meaning of a search query, instead of a match on query terms (lexical search). diff --git a/docs/source/elastic/semantic-search/elser.md b/docs/source/elastic/semantic-search/elser.md index 3a38e5fe..475c2482 100644 --- a/docs/source/elastic/semantic-search/elser.md +++ b/docs/source/elastic/semantic-search/elser.md @@ -1,5 +1,6 @@ --- title: "Semantic search with the inference API" +navigation_title: "ELSER" --- Semantic search helps you find data based on the intent and contextual meaning of a search query, instead of a match on query terms (lexical search). diff --git a/src/Elastic.Markdown/IO/MarkdownFile.cs b/src/Elastic.Markdown/IO/MarkdownFile.cs index dfd8d29f..36ae6efe 100644 --- a/src/Elastic.Markdown/IO/MarkdownFile.cs +++ b/src/Elastic.Markdown/IO/MarkdownFile.cs @@ -16,7 +16,7 @@ namespace Elastic.Markdown.IO; public class MarkdownFile : DocumentationFile { private readonly SlugHelper _slugHelper = new(); - private string? _tocTitle; + private string? _navigationTitle; public MarkdownFile(IFileInfo sourceFile, IDirectoryInfo rootPath, MarkdownParser parser, BuildContext context) : base(sourceFile, rootPath) @@ -32,10 +32,10 @@ public MarkdownFile(IFileInfo sourceFile, IDirectoryInfo rootPath, MarkdownParse private FrontMatterParser FrontMatterParser { get; } = new(); public YamlFrontMatter? YamlFrontMatter { get; private set; } public string? Title { get; private set; } - public string? TocTitle + public string? NavigationTitle { - get => !string.IsNullOrEmpty(_tocTitle) ? _tocTitle : Title; - set => _tocTitle = value; + get => !string.IsNullOrEmpty(_navigationTitle) ? _navigationTitle : Title; + private set => _navigationTitle = value; } public List TableOfContents { get; } = new(); @@ -53,6 +53,7 @@ public async Task ParseFullAsync(Cancel ctx) var raw = string.Join(Environment.NewLine, yaml.Lines.Lines); YamlFrontMatter = FrontMatterParser.Deserialize(raw); Title = YamlFrontMatter.Title; + NavigationTitle = YamlFrontMatter.NavigationTitle; } var contents = document diff --git a/src/Elastic.Markdown/Myst/FrontMatterParser.cs b/src/Elastic.Markdown/Myst/FrontMatterParser.cs index 1beae4d2..7b4e8778 100644 --- a/src/Elastic.Markdown/Myst/FrontMatterParser.cs +++ b/src/Elastic.Markdown/Myst/FrontMatterParser.cs @@ -12,7 +12,12 @@ public partial class YamlFrontMatterStaticContext; [YamlSerializable] public class YamlFrontMatter { + [YamlMember(Alias = "title")] public string? Title { get; set; } + + [YamlMember(Alias = "navigation_title")] + public string? NavigationTitle { get; set; } + [YamlMember(Alias = "sub")] public Dictionary? Properties { get; set; } } @@ -25,7 +30,6 @@ public YamlFrontMatter Deserialize(string yaml) var deserializer = new StaticDeserializerBuilder(new YamlFrontMatterStaticContext()) .IgnoreUnmatchedProperties() - .WithNamingConvention(CamelCaseNamingConvention.Instance) .Build(); var frontMatter = deserializer.Deserialize(input); diff --git a/src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml b/src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml index 77ae7d45..cfa4a2a6 100644 --- a/src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml +++ b/src/Elastic.Markdown/Slices/Layout/_TocTreeNav.cshtml @@ -2,13 +2,13 @@ @foreach (var file in Model.SubTree.FilesInOrder) { var current = file == Model.CurrentDocument ? " current" : string.Empty; -
  • @file.TocTitle
  • +
  • @file.NavigationTitle
  • } @foreach (var g in Model.SubTree.GroupsInOrder) { var current = g.HoldsCurrent(Model.CurrentDocument) ? " current" : string.Empty; var currentFile = g.Index == Model.CurrentDocument ? " current" : string.Empty; -
  • @g.Index?.TocTitle@if (@g.FilesInOrder.Count > 0 || g.GroupsInOrder.Count > 0) {
      @await RenderPartialAsync(Elastic.Markdown.Slices.Layout._TocTreeNav.Create(new NavigationTreeItem +
    • @g.Index?.NavigationTitle@if (@g.FilesInOrder.Count > 0 || g.GroupsInOrder.Count > 0) {
        @await RenderPartialAsync(Elastic.Markdown.Slices.Layout._TocTreeNav.Create(new NavigationTreeItem { Level = g.Level, CurrentDocument = Model.CurrentDocument, diff --git a/tests/Elastic.Markdown.Tests/Directives/YamlFrontMatterTests.cs b/tests/Elastic.Markdown.Tests/Directives/YamlFrontMatterTests.cs index 18da1ee1..18b39a10 100644 --- a/tests/Elastic.Markdown.Tests/Directives/YamlFrontMatterTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/YamlFrontMatterTests.cs @@ -10,10 +10,25 @@ public class YamlFrontMatterTests(ITestOutputHelper output) : DirectiveTest(outp """ --- title: Elastic Docs v3 +navigation_title: "Documentation Guide" +sub: + key: "value" --- """ ) { [Fact] - public void Test1() => File.Title.Should().Be("Elastic Docs v3"); + public void ReadsTitle() => File.Title.Should().Be("Elastic Docs v3"); + + [Fact] + public void ReadsNavigationTitle() => File.NavigationTitle.Should().Be("Documentation Guide"); + + [Fact] + public void ReadsSubstitutions() + { + File.YamlFrontMatter.Should().NotBeNull(); + File.YamlFrontMatter!.Properties.Should().NotBeEmpty() + .And.HaveCount(1) + .And.ContainKey("key"); + } }