Skip to content

Commit 296dc21

Browse files
authored
feat: Add Server Info (fastfetch) (#30)
1 parent 5cbf8b7 commit 296dc21

File tree

5 files changed

+90
-0
lines changed

5 files changed

+90
-0
lines changed

package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@vuepress/plugin-feed": "^2.0.0-rc.52",
1717
"@vuepress/plugin-prismjs": "^2.0.0-rc.52",
1818
"@vuepress/plugin-pwa": "^2.0.0-rc.52",
19+
"ansi-to-html": "^0.7.2",
1920
"asciinema-player": "^3.8.1",
2021
"git-describe": "^4.1.1",
2122
"marked": "^14.1.2",

src/.vuepress/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { defineClientConfig } from "vuepress/client";
22
import GithubIssues from "./components/GithubIssues.vue";
33
import GitHubPRList from './components/GitHubPRList.vue';
44
import AsciinemaPlayer from './components/AsciinemaPlayer.vue';
5+
import Fastfetch from "./components/Fastfetch.vue";
56

67

78
export default defineClientConfig({
89
enhance: ({ app, router, siteData }) => {
910
app.component('GitHubPRList', GitHubPRList);
1011
app.component("GithubIssues", GithubIssues);
1112
app.component('AsciinemaPlayer', AsciinemaPlayer);
13+
app.component('Fastfetch',Fastfetch);
1214
},
1315
});
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div class="fastfetch-output" v-html="markdownOutput"></div>
3+
</template>
4+
5+
<script>
6+
import { ref, onMounted } from 'vue';
7+
import Convert from 'ansi-to-html';
8+
import { marked } from 'marked';
9+
10+
export default {
11+
name: 'Fastfetch',
12+
setup() {
13+
const output = ref('');
14+
const markdownOutput = ref('');
15+
const convert = new Convert();
16+
17+
const fetchData = async () => {
18+
try {
19+
const response = await fetch('https://blogapi.pysio.online/fastfetch');
20+
const data = await response.json();
21+
output.value = data.output;
22+
formatOutput();
23+
} catch (error) {
24+
console.error('Error fetching ', error);
25+
}
26+
};
27+
28+
const formatOutput = () => {
29+
// Convert ANSI to HTML
30+
let html = convert.toHtml(output.value);
31+
32+
// Wrap the HTML in a Markdown code block
33+
const markdownCode = "```bash\n" + html + "\n```";
34+
35+
// Use marked to convert Markdown to HTML
36+
markdownOutput.value = marked(markdownCode);
37+
};
38+
39+
onMounted(() => {
40+
fetchData();
41+
});
42+
43+
return {
44+
markdownOutput
45+
};
46+
}
47+
}
48+
</script>
49+
50+
<style scoped>
51+
.fastfetch-output {
52+
font-family: monospace;
53+
white-space: pre-wrap;
54+
word-wrap: break-word;
55+
}
56+
</style>

src/intro.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ title: 关于本站
33
icon: fa-regular fa-circle-info
44
article: false
55
---
6+
## Server Info
7+
8+
<Fastfetch />
9+
610
## 仓库以及构建状态
711
![Vue-blog](https://socialify.git.ci/pysio2007/Vue-blog/image?description=1&descriptionEditable=Pysio%27s%20Home%20%E4%B8%80%E4%B8%AA%E6%B8%A9%E6%9A%96%E7%9A%84%E5%AE%B6&forks=1&language=1&name=1&owner=1&pattern=Circuit%20Board&pulls=1&stargazers=1&theme=Auto)
812
[![Build Docker Image](https://github.com/pysio2007/Vue-blog/actions/workflows/bulid-docker.yml/badge.svg)](https://github.com/pysio2007/Vue-blog/actions/workflows/bulid-docker.yml)

0 commit comments

Comments
 (0)