Skip to content

Commit

Permalink
blog: add webmention counter
Browse files Browse the repository at this point in the history
  • Loading branch information
manila committed Mar 18, 2024
1 parent ecd9474 commit 74d5fe9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/theme/BlogPostItem/Footer/LikesAndComments/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, {useState, useEffect} from 'react';

export default function LikesAndComments(props) {
const [webmentionCount, setWebmentionCount] = useState(0);

useEffect(() => {
fetch(`https://webmention.io/api/count?target=${window.location.href}`)
.then(response => response.json())
.then(data => setWebmentionCount(data.count))
.catch(error => console.log(error))
}, [])

return (<><p>{webmentionCount} Webmentions(s)</p></>)
}
12 changes: 12 additions & 0 deletions src/theme/BlogPostItem/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import Footer from '@theme-original/BlogPostItem/Footer';
import LikesAndComments from '@site/src/theme/BlogPostItem/Footer/LikesAndComments';

export default function FooterWrapper(props) {
return (
<>
<Footer {...props} />
<LikesAndComments {...props} />
</>
);
}

0 comments on commit 74d5fe9

Please sign in to comment.