feat: remove the path attribute requirement from comments
This commit is contained in:
parent
5adf3bc560
commit
4ab42f9543
4 changed files with 7 additions and 20 deletions
|
@ -8,15 +8,11 @@ import Giscus from "./helper/comments/Giscus.astro";
|
|||
const method = siteConfig.comments.type
|
||||
|
||||
const FediverseConfig = siteConfig.comments.fediverse
|
||||
interface Props {
|
||||
path?: string;
|
||||
}
|
||||
|
||||
let { path='/' } = Astro.props;
|
||||
---
|
||||
{method === 'artalk' && <Artalk path={path} />}
|
||||
{method === 'giscus' && <Giscus/>}
|
||||
{method === 'artalk' && <Artalk />}
|
||||
{method === 'giscus' && <Giscus />}
|
||||
<!-- if prerender === true is set then render from client -->
|
||||
{(method === 'fediverse' && !FediverseConfig.renderOnServer ) && <FediverseComments path={path} /> }
|
||||
{(method === 'fediverse' && FediverseConfig.renderOnServer ) && <FediverseComments server:defer path={path} ><p>Loading comments...</p></FediverseComments> }
|
||||
{(method === 'fediverse' && !FediverseConfig.renderOnServer ) && <FediverseComments /> }
|
||||
{(method === 'fediverse' && FediverseConfig.renderOnServer ) && <FediverseComments server:defer><p>Loading comments...</p></FediverseComments> }
|
||||
{method === 'hatsu' && <HatsuComments /> }
|
|
@ -2,12 +2,10 @@
|
|||
import {siteConfig} from "../../../config";
|
||||
import 'artalk/Artalk.css';
|
||||
const ArtalkInstanceDomain = siteConfig.comments.artalk.instanceDomain
|
||||
|
||||
const { path } = Astro.props;
|
||||
---
|
||||
<div>
|
||||
<!-- Artalk -->
|
||||
<div id="comments" data-path={path} data-server={ArtalkInstanceDomain}></div>
|
||||
<div id="comments" data-path={Astro.url.pathname} data-server={ArtalkInstanceDomain}></div>
|
||||
<script>
|
||||
import Artalk from "artalk";
|
||||
const atkElement = document.querySelector('#comments');
|
||||
|
|
|
@ -14,15 +14,8 @@ const {
|
|||
|
||||
const serverRender = fediverseConfig.renderOnServer
|
||||
|
||||
interface Props {
|
||||
path: string;
|
||||
}
|
||||
|
||||
const { path } = Astro.props;
|
||||
|
||||
// Create the full URL to search for
|
||||
const fullSiteUrl = Astro.url.host;
|
||||
const postUrl = `https://${fullSiteUrl}${path.startsWith('/') ? path : '/' + path}`;
|
||||
const postUrl = Astro.url.href;
|
||||
|
||||
// Define the search API endpoint based on configuration
|
||||
let searchEndpoint: string;
|
||||
|
|
|
@ -62,7 +62,7 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `
|
|||
<ReplyViaEmail title={entry.data.title} email={authorInfo.email} />
|
||||
<br>
|
||||
<a href="/blog">← Back to posts</a>
|
||||
{!noscript && <h2>Comments</h2> <Comments path={`blog/${slug}`} />}
|
||||
{!noscript && <h2>Comments</h2> <Comments />}
|
||||
{!noscript &&
|
||||
<script>
|
||||
import "katex/dist/contrib/copy-tex.js"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue