Skip to content

Commit e00d555

Browse files
committed
Add TitleRaw property
1 parent 4ddc4bb commit e00d555

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

docs/testing/req.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Requirements
1+
# Requirements [link](https://www.elastic.co) `code`
2+
## Requirements [link](https://www.elastic.co) `code`
23

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

src/Elastic.Markdown/IO/MarkdownFile.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,17 @@ public DocumentationGroup? Parent
4343
public string? UrlPathPrefix { get; }
4444
private MarkdownParser MarkdownParser { get; }
4545
public YamlFrontMatter? YamlFrontMatter { get; private set; }
46-
public string? Title { get; private set; }
46+
public string? TitleRaw { get; private set; }
47+
48+
public string? Title
49+
{
50+
get => _title;
51+
private set
52+
{
53+
_title = value?.StripMarkdown();
54+
TitleRaw = value;
55+
}
56+
}
4757
public string? NavigationTitle
4858
{
4959
get => !string.IsNullOrEmpty(_navigationTitle) ? _navigationTitle : Title;
@@ -65,6 +75,7 @@ public string? NavigationTitle
6575

6676
private bool _instructionsParsed;
6777
private DocumentationGroup? _parent;
78+
private string? _title;
6879

6980
public MarkdownFile[] YieldParents()
7081
{

src/Elastic.Markdown/Slices/HtmlWriter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public async Task<string> RenderLayout(MarkdownFile markdown, Cancel ctx = defau
5656
var slice = Index.Create(new IndexViewModel
5757
{
5858
Title = markdown.Title ?? "[TITLE NOT SET]",
59+
TitleRaw = markdown.TitleRaw ?? "[TITLE NOT SET]",
5960
MarkdownHtml = html,
6061
PageTocItems = markdown.TableOfContents.Values.ToList(),
6162
Tree = DocumentationSet.Tree,

src/Elastic.Markdown/Slices/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
<section id="elastic-docs-v3">
2020
@* This way it's correctly rendered as <h1>text</h1> instead of <h1><p>text</p></h1> *@
21-
@(new HtmlString(Markdown.ToHtml("# " + Model.Title)))
21+
@(new HtmlString(Markdown.ToHtml("# " + Model.TitleRaw)))
2222
@if (Model.Applies is not null)
2323
{
2424
await RenderPartialAsync(Applies.Create(Model.Applies));

src/Elastic.Markdown/Slices/_ViewModels.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Elastic.Markdown.Slices;
1010
public class IndexViewModel
1111
{
1212
public required string Title { get; init; }
13+
public required string TitleRaw { get; init; }
1314
public required string MarkdownHtml { get; init; }
1415
public required DocumentationGroup Tree { get; init; }
1516
public required IReadOnlyCollection<PageTocItem> PageTocItems { get; init; }
@@ -26,6 +27,7 @@ public class IndexViewModel
2627
public class LayoutViewModel
2728
{
2829
public string Title { get; set; } = "Elastic Documentation";
30+
public string RawTitle { get; set; } = "Elastic Documentation";
2931
public required IReadOnlyCollection<PageTocItem> PageTocItems { get; init; }
3032
public required DocumentationGroup Tree { get; init; }
3133
public required MarkdownFile CurrentDocument { get; init; }

0 commit comments

Comments
 (0)