Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Add table of contents
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMagee committed May 5, 2021
1 parent 2eaa6ce commit 77919a1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public abstract class PostTemplate : ITemplate
public abstract Post Post { get; }

public abstract string TemplateName { get; }

public string? Index { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Reddit2Kindle.Functions/Reddit2Kindle.Functions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
<PreserveCompilationContext>true</PreserveCompilationContext>
<NoWarn>8509</NoWarn>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentEmail.SendGrid" Version="3.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/Reddit2Kindle.Functions/Templates/LinkPost.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
<div class="container">
<div class="page-header">
<h1>@Model.Post.Title</h1>
<h1 id="@(Model.Index ?? "")">@Model.Post.Title</h1>
<span>@Model.Post.Author</span>
</div>
@if (!string.IsNullOrWhiteSpace(Model.Article))
Expand Down
2 changes: 1 addition & 1 deletion src/Reddit2Kindle.Functions/Templates/SelfPost.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
<div class="container">
<div class="page-header">
<h1>@Model.Post.Title</h1>
<h1 id="@(Model.Index ?? "")">@Model.Post.Title</h1>
<span>@Model.Post.Author</span>
</div>
@if (!string.IsNullOrWhiteSpace(Model.Post.SelfTextHTML))
Expand Down
25 changes: 25 additions & 0 deletions src/Reddit2Kindle.Functions/Templates/Subreddit.cshtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
@inherits RazorLight.TemplatePage<Reddit2Kindle.Functions.Contracts.Templates.SubredditTemplate>

@{
foreach (var tuple in Model.Templates.Select((template, index) => new
{
template,
index
}))
{
tuple.template.Index = tuple.index.ToString();
}
}

<div class="container">
<div class="page-header">
<h1>Table of Contents</h1>
</div>
<ol>
@foreach (var template in Model.Templates)
{
<li>
<a href="#@(template.Index)">@(template.Post.Title)</a>
</li>
}
</ol>
</div>

@foreach (var template in Model.Templates)
{
await IncludeAsync(template.TemplateName, template);
Expand Down

0 comments on commit 77919a1

Please sign in to comment.