Skip to content

Commit 2d86207

Browse files
committed
Add hit counter
1 parent 94fdb26 commit 2d86207

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/theme/BlogPostItem/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@ import { useBlogPost } from '@docusaurus/theme-common/internal'
55

66
export default function BlogPostItemWrapper(props) {
77
const { metadata, isBlogPostPage } = useBlogPost();
8-
const { frontMatter } = metadata;
8+
const { frontMatter, permalink } = metadata;
99
const { disable_comments } = frontMatter;
1010

11+
const hitUrl = `https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=${encodeURI(window.location.href)}&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=true`;
12+
1113
return (
1214
<>
1315
<BlogPostItem {...props} />
1416
{(!disable_comments && isBlogPostPage) && (
1517
<>
1618
<br />
19+
<img src={hitUrl} />
1720
<Giscus />
1821
</>
1922
)}

src/theme/DocItem/Layout/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default function DocItemLayout({ children }) {
3636
const { metadata } = useDoc();
3737
const { unlisted, frontMatter, slug } = metadata;
3838
let { disable_comments } = frontMatter;
39+
const hitUrl = `https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=${encodeURI(window.location.href)}&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=true`;
3940

4041
if (slug.includes("/reference/")) {
4142
// Disable comments for all library reference pages
@@ -57,6 +58,7 @@ export default function DocItemLayout({ children }) {
5758
<>
5859
<br />
5960
<br />
61+
<img src={hitUrl} />
6062
<Giscus />
6163
</>
6264
)}

0 commit comments

Comments
 (0)