style: guard clause article page

This commit is contained in:
Oliver Booth 2023-08-08 01:34:27 +01:00
parent 83e5757429
commit b584bb84a2
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61
1 changed files with 64 additions and 60 deletions

View File

@ -2,12 +2,17 @@
@using Humanizer
@model OliverBooth.Pages.Blog.Article
@if (Model.Post is { } post)
@if (Model.Post is not { } post)
{
return;
}
@{
bool isLegacyPost = Model.IsWordPressLegacyPost;
string disqusDomain = isLegacyPost ? "https://blog.oliverbooth.dev" : "https://oliverbooth.dev/blog";
string disqusId = isLegacyPost ? $"{post.WordPressId} {disqusDomain}/?p={post.WordPressId}" : post.Id.ToString();
var disqusUrl = $"{disqusDomain}/{post.Published:yyyy/MM/dd}/{post.Slug}/";
}
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
@ -44,9 +49,9 @@
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = "@(disqusUrl)";
this.page.identifier = "@(disqusId)";
this.page.title = "@(post.Title)";
this.page.url = "@disqusUrl";
this.page.identifier = "@disqusId";
this.page.title = "@post.Title";
this.page.postId = "@(post.WordPressId ?? post.Id)";
};
@ -71,4 +76,3 @@
{
<p class="text-center text-muted">Comments are not enabled for this post.</p>
}
}