与NextJS集成 #757
Eliot00
started this conversation in
Show and tell
与NextJS集成
#757
Replies: 2 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
2 replies
-
"use client";
import { getConfig } from "@/core/config";
import { useEffect, useState } from "react";
export default function Comment() {
const [loadingStatus, setLoadingStatus] = useState<"loading" | "error">(
"loading",
);
const config = getConfig();
useEffect(() => {
if (config.twikoo) {
import("twikoo")
.then(({ default: init }) => {
init({
envId: config.twikoo?.envId!,
el: "#tcomment",
});
})
.catch((error) => {
setLoadingStatus("error");
console.error(`Failed to load twikoo: ${error}`);
});
}
});
if (config.twikoo) {
return (
<div id="tcomment">
{loadingStatus === "loading" && <div>正在加载评论...</div>}
{loadingStatus === "error" && <div>评论加载失败</div>}
</div>
);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
原文
Beta Was this translation helpful? Give feedback.
All reactions