style: guard clause article page
This commit is contained in:
parent
83e5757429
commit
b584bb84a2
@ -2,73 +2,77 @@
|
|||||||
@using Humanizer
|
@using Humanizer
|
||||||
@model OliverBooth.Pages.Blog.Article
|
@model OliverBooth.Pages.Blog.Article
|
||||||
|
|
||||||
@if (Model.Post is { } post)
|
@if (Model.Post is not { } post)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@{
|
||||||
bool isLegacyPost = Model.IsWordPressLegacyPost;
|
bool isLegacyPost = Model.IsWordPressLegacyPost;
|
||||||
string disqusDomain = isLegacyPost ? "https://blog.oliverbooth.dev" : "https://oliverbooth.dev/blog";
|
string disqusDomain = isLegacyPost ? "https://blog.oliverbooth.dev" : "https://oliverbooth.dev/blog";
|
||||||
string disqusId = isLegacyPost ? $"{post.WordPressId} {disqusDomain}/?p={post.WordPressId}" : post.Id.ToString();
|
string disqusId = isLegacyPost ? $"{post.WordPressId} {disqusDomain}/?p={post.WordPressId}" : post.Id.ToString();
|
||||||
var disqusUrl = $"{disqusDomain}/{post.Published:yyyy/MM/dd}/{post.Slug}/";
|
var disqusUrl = $"{disqusDomain}/{post.Published:yyyy/MM/dd}/{post.Slug}/";
|
||||||
|
}
|
||||||
|
|
||||||
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
|
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li class="breadcrumb-item">
|
<li class="breadcrumb-item">
|
||||||
<a asp-page="/blog/index">Blog</a>
|
<a asp-page="/blog/index">Blog</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="breadcrumb-item active" aria-current="page">@post.Title</li>
|
<li class="breadcrumb-item active" aria-current="page">@post.Title</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<h1>@post.Title</h1>
|
|
||||||
<p class="text-muted">
|
|
||||||
<img class="blog-author-icon" src="https://gravatar.com/avatar/@Model.Author?.AvatarHash?s=28">
|
|
||||||
@Model.Author?.Name
|
|
||||||
•
|
|
||||||
<abbr data-bs-toggle="tooltip" data-bs-title="@post.Published.ToString("f")">
|
|
||||||
@post.Published.Humanize()
|
|
||||||
</abbr>
|
|
||||||
@if (post.EnableComments)
|
|
||||||
{
|
|
||||||
<span>•</span>
|
|
||||||
<a href="#disqus_thread" data-disqus-identifier="@disqusId">0 Comments</a>
|
|
||||||
}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<article>
|
|
||||||
@Html.Raw(Model.SanitizeContent(post.Body))
|
|
||||||
</article>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
|
<h1>@post.Title</h1>
|
||||||
|
<p class="text-muted">
|
||||||
|
<img class="blog-author-icon" src="https://gravatar.com/avatar/@Model.Author?.AvatarHash?s=28">
|
||||||
|
@Model.Author?.Name
|
||||||
|
•
|
||||||
|
<abbr data-bs-toggle="tooltip" data-bs-title="@post.Published.ToString("f")">
|
||||||
|
@post.Published.Humanize()
|
||||||
|
</abbr>
|
||||||
@if (post.EnableComments)
|
@if (post.EnableComments)
|
||||||
{
|
{
|
||||||
<div id="disqus_thread"></div>
|
<span>•</span>
|
||||||
<script>
|
<a href="#disqus_thread" data-disqus-identifier="@disqusId">0 Comments</a>
|
||||||
var disqus_config = function () {
|
}
|
||||||
this.page.url = "@(disqusUrl)";
|
</p>
|
||||||
this.page.identifier = "@(disqusId)";
|
|
||||||
this.page.title = "@(post.Title)";
|
|
||||||
this.page.postId = "@(post.WordPressId ?? post.Id)";
|
|
||||||
};
|
|
||||||
|
|
||||||
(function() {
|
<article>
|
||||||
const d = document, s = d.createElement("script");
|
@Html.Raw(Model.SanitizeContent(post.Body))
|
||||||
s.async = true;
|
</article>
|
||||||
s.type = "text/javascript";
|
|
||||||
s.src = "https://oliverbooth-dev.disqus.com/embed.js";
|
<hr>
|
||||||
s.setAttribute("data-timestamp", + new Date());
|
|
||||||
(d.head || d.body).appendChild(s);
|
@if (post.EnableComments)
|
||||||
})();
|
{
|
||||||
</script>
|
<div id="disqus_thread"></div>
|
||||||
<script id="dsq-count-scr" src="https://oliverbooth-dev.disqus.com/count.js" async></script>
|
<script>
|
||||||
<noscript>
|
var disqus_config = function () {
|
||||||
Please enable JavaScript to view the
|
this.page.url = "@disqusUrl";
|
||||||
<a href="https://disqus.com/?ref_noscript" rel="nofollow">
|
this.page.identifier = "@disqusId";
|
||||||
comments powered by Disqus.
|
this.page.title = "@post.Title";
|
||||||
</a>
|
this.page.postId = "@(post.WordPressId ?? post.Id)";
|
||||||
</noscript>
|
};
|
||||||
}
|
|
||||||
else
|
(function() {
|
||||||
{
|
const d = document, s = d.createElement("script");
|
||||||
<p class="text-center text-muted">Comments are not enabled for this post.</p>
|
s.async = true;
|
||||||
}
|
s.type = "text/javascript";
|
||||||
|
s.src = "https://oliverbooth-dev.disqus.com/embed.js";
|
||||||
|
s.setAttribute("data-timestamp", + new Date());
|
||||||
|
(d.head || d.body).appendChild(s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<script id="dsq-count-scr" src="https://oliverbooth-dev.disqus.com/count.js" async></script>
|
||||||
|
<noscript>
|
||||||
|
Please enable JavaScript to view the
|
||||||
|
<a href="https://disqus.com/?ref_noscript" rel="nofollow">
|
||||||
|
comments powered by Disqus.
|
||||||
|
</a>
|
||||||
|
</noscript>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p class="text-center text-muted">Comments are not enabled for this post.</p>
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user