/
Docs.razor
54 lines (47 loc) · 1.18 KB
/
Docs.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@page "/{Slug:regex(^[a-z-_]+$)}"
@inherits AppComponentBase
@inject MarkdownPages Markdown
@if (doc != null)
{
<PageTitle>@doc.Title</PageTitle>
<div class="mx-auto">
<section class="text-center mt-16 mb-16 md:mb-12">
<h1 class="text-4xl tracking-tight font-extrabold text-gray-900 dark:text-gray-50 sm:text-5xl md:text-6xl">
@doc.Title
</h1>
</section>
<div class="mx-auto prose lg:prose-xl mb-24">
@BlazorHtml.Raw(doc.Preview)
</div>
</div>
}
else
{
<div class="mt-3 mb-20 mx-auto max-w-fit">
@if (error != null)
{
<ErrorSummary Status=@error />
}
else
{
<Loading />
}
</div>
}
@code {
[Parameter]
public required string Slug { get; set; }
MarkdownFileInfo? doc;
ResponseStatus? error;
void load()
{
doc = Markdown.GetBySlug(Slug);
if (doc == null)
{
error = new() { Message = $"_pages/{Slug}.md was not found" };
return;
}
}
protected override void OnInitialized() => load();
protected override void OnParametersSet() => load();
}