-
setup(valaxy) {
valaxy.hook("vue-router:extendRoute",async (route) => {
if (route.meta.frontmatter.excerpt_type === "ai") {
try {
let path = route.components.get("default") as string;
const md = fs.readFileSync(path, "utf-8");
const { content } = matter(md);
let resp = await axios.post(
"https://summary.mcenjoy.workers.dev/api/summary?token=******",
{
content: content.replaceAll(/<[^>]+>/gm, ""),
},
{
headers: {
"Content-Type": "application/json",
},
proxy: {
host: "127.0.0.1",
port: 8888,
protocol: "http"
},
},
);
route.meta.frontmatter.ai_excerpt = resp.data.summary;
consola.info(`[${pkg.name}]:`,route.meta.frontmatter)
} catch (e) {
consola.error(`[${pkg.name}]:`,e);
}
}
});
}, 这样添加不成功
|
Beta Was this translation helpful? Give feedback.
Answered by
mcoo
Jun 23, 2024
Replies: 1 comment 1 reply
Answer selected by
YunYouJun
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
solved