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