refactor: remove references to hljs

This commit is contained in:
Oliver Booth 2023-08-08 01:17:23 +01:00
parent 6524a4f618
commit b9e7e938ba
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61
3 changed files with 52 additions and 4 deletions

View File

@ -1,9 +1,14 @@
@page "/blog/{year:int}/{month:int}/{day:int}/{slug}"
@page "/blog/{year:int}/{month:int}/{day:int}/{slug}"
@using Humanizer
@model OliverBooth.Pages.Blog.Article
@if (Model.Post is { } post)
{
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">
<li class="breadcrumb-item">
@ -21,6 +26,11 @@
<abbr data-bs-toggle="tooltip" data-bs-title="@post.Published.ToString("f")">
@post.Published.Humanize()
</abbr>
@if (post.EnableComments)
{
<span>&bull;</span>
<a href="#disqus_thread" data-disqus-identifier="@disqusId">0 Comments</a>
}
</p>
<article>
@ -29,4 +39,36 @@
<hr>
@if (post.EnableComments)
{
<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.postId = "@(post.WordPressId ?? post.Id)";
};
(function() {
const d = document, s = d.createElement("script");
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>
}
}

View File

@ -1,4 +1,4 @@
using Markdig;
using Markdig;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
@ -20,6 +20,14 @@ public class Article : PageModel
public Author Author { get; private set; }
/// <summary>
/// Gets a value indicating whether the post is a legacy WordPress post.
/// </summary>
/// <value>
/// <see langword="true" /> if the post is a legacy WordPress post; otherwise, <see langword="false" />.
/// </value>
public bool IsWordPressLegacyPost => Post?.WordPressId.HasValue ?? false;
public BlogPost Post { get; private set; } = new();
public string SanitizeContent(string content)

View File

@ -1,5 +1,3 @@
declare const hljs: any;
(() => {
hljs.highlightAll();
})();