Skip to content

Commit

Permalink
Add TitleRaw property
Browse files Browse the repository at this point in the history
  • Loading branch information
reakaleek committed Jan 23, 2025
1 parent 4ddc4bb commit e00d555
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/testing/req.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Requirements
# Requirements [link](https://www.elastic.co) `code`
## Requirements [link](https://www.elastic.co) `code`

To follow this tutorial you will need to install the following components:

Expand Down
13 changes: 12 additions & 1 deletion src/Elastic.Markdown/IO/MarkdownFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ public DocumentationGroup? Parent
public string? UrlPathPrefix { get; }
private MarkdownParser MarkdownParser { get; }
public YamlFrontMatter? YamlFrontMatter { get; private set; }
public string? Title { get; private set; }
public string? TitleRaw { get; private set; }

public string? Title
{
get => _title;
private set
{
_title = value?.StripMarkdown();
TitleRaw = value;
}
}
public string? NavigationTitle
{
get => !string.IsNullOrEmpty(_navigationTitle) ? _navigationTitle : Title;
Expand All @@ -65,6 +75,7 @@ public string? NavigationTitle

private bool _instructionsParsed;
private DocumentationGroup? _parent;
private string? _title;

public MarkdownFile[] YieldParents()
{
Expand Down
1 change: 1 addition & 0 deletions src/Elastic.Markdown/Slices/HtmlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public async Task<string> RenderLayout(MarkdownFile markdown, Cancel ctx = defau
var slice = Index.Create(new IndexViewModel
{
Title = markdown.Title ?? "[TITLE NOT SET]",
TitleRaw = markdown.TitleRaw ?? "[TITLE NOT SET]",
MarkdownHtml = html,
PageTocItems = markdown.TableOfContents.Values.ToList(),
Tree = DocumentationSet.Tree,
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Markdown/Slices/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
<section id="elastic-docs-v3">
@* This way it's correctly rendered as <h1>text</h1> instead of <h1><p>text</p></h1> *@
@(new HtmlString(Markdown.ToHtml("# " + Model.Title)))
@(new HtmlString(Markdown.ToHtml("# " + Model.TitleRaw)))
@if (Model.Applies is not null)
{
await RenderPartialAsync(Applies.Create(Model.Applies));
Expand Down
2 changes: 2 additions & 0 deletions src/Elastic.Markdown/Slices/_ViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Elastic.Markdown.Slices;
public class IndexViewModel
{
public required string Title { get; init; }
public required string TitleRaw { get; init; }
public required string MarkdownHtml { get; init; }
public required DocumentationGroup Tree { get; init; }
public required IReadOnlyCollection<PageTocItem> PageTocItems { get; init; }
Expand All @@ -26,6 +27,7 @@ public class IndexViewModel
public class LayoutViewModel
{
public string Title { get; set; } = "Elastic Documentation";
public string RawTitle { get; set; } = "Elastic Documentation";
public required IReadOnlyCollection<PageTocItem> PageTocItems { get; init; }
public required DocumentationGroup Tree { get; init; }
public required MarkdownFile CurrentDocument { get; init; }
Expand Down

0 comments on commit e00d555

Please sign in to comment.