Compare commits
5 Commits
6243898db3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| baf88a1ca1 | |||
| d122f19ead | |||
| b570c9e621 | |||
| b4caa00827 | |||
| 1364698b81 |
@@ -1,3 +1,11 @@
|
|||||||
|
# Milkblogs
|
||||||
|
|
||||||
|
这是网站 [milkfunc.top](https://milkfunc.top) 的源码仓库。
|
||||||
|
|
||||||
|
本项目是 [saicaca/fuwari](https://github.com/saicaca/fuwari) 的一个 Fork。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# 🍥Fuwari
|
# 🍥Fuwari
|
||||||

|

|
||||||

|

|
||||||
|
|||||||
+13
-10
@@ -4,9 +4,9 @@ import tailwind from "@astrojs/tailwind";
|
|||||||
import { pluginCollapsibleSections } from "@expressive-code/plugin-collapsible-sections";
|
import { pluginCollapsibleSections } from "@expressive-code/plugin-collapsible-sections";
|
||||||
import { pluginLineNumbers } from "@expressive-code/plugin-line-numbers";
|
import { pluginLineNumbers } from "@expressive-code/plugin-line-numbers";
|
||||||
import swup from "@swup/astro";
|
import swup from "@swup/astro";
|
||||||
|
import { defineConfig } from "astro/config";
|
||||||
import expressiveCode from "astro-expressive-code";
|
import expressiveCode from "astro-expressive-code";
|
||||||
import icon from "astro-icon";
|
import icon from "astro-icon";
|
||||||
import { defineConfig } from "astro/config";
|
|
||||||
import rehypeAutolinkHeadings from "rehype-autolink-headings";
|
import rehypeAutolinkHeadings from "rehype-autolink-headings";
|
||||||
import rehypeComponents from "rehype-components"; /* Render the custom directive content */
|
import rehypeComponents from "rehype-components"; /* Render the custom directive content */
|
||||||
import rehypeKatex from "rehype-katex";
|
import rehypeKatex from "rehype-katex";
|
||||||
@@ -16,14 +16,15 @@ import remarkGithubAdmonitionsToDirectives from "remark-github-admonitions-to-di
|
|||||||
import remarkMath from "remark-math";
|
import remarkMath from "remark-math";
|
||||||
import remarkSectionize from "remark-sectionize";
|
import remarkSectionize from "remark-sectionize";
|
||||||
import { expressiveCodeConfig } from "./src/config.ts";
|
import { expressiveCodeConfig } from "./src/config.ts";
|
||||||
|
import { pluginCustomCopyButton } from "./src/plugins/expressive-code/custom-copy-button.js";
|
||||||
import { pluginLanguageBadge } from "./src/plugins/expressive-code/language-badge.ts";
|
import { pluginLanguageBadge } from "./src/plugins/expressive-code/language-badge.ts";
|
||||||
import { AdmonitionComponent } from "./src/plugins/rehype-component-admonition.mjs";
|
import { AdmonitionComponent } from "./src/plugins/rehype-component-admonition.mjs";
|
||||||
|
import { GiteaCardComponent } from "./src/plugins/rehype-component-gitea-card.mjs";
|
||||||
import { GithubCardComponent } from "./src/plugins/rehype-component-github-card.mjs";
|
import { GithubCardComponent } from "./src/plugins/rehype-component-github-card.mjs";
|
||||||
import { GitlabCardComponent } from "./src/plugins/rehype-component-gitlab-card.mjs";
|
import { GitlabCardComponent } from "./src/plugins/rehype-component-gitlab-card.mjs";
|
||||||
import { parseDirectiveNode } from "./src/plugins/remark-directive-rehype.js";
|
import { parseDirectiveNode } from "./src/plugins/remark-directive-rehype.js";
|
||||||
import { remarkExcerpt } from "./src/plugins/remark-excerpt.js";
|
import { remarkExcerpt } from "./src/plugins/remark-excerpt.js";
|
||||||
import { remarkReadingTime } from "./src/plugins/remark-reading-time.mjs";
|
import { remarkReadingTime } from "./src/plugins/remark-reading-time.mjs";
|
||||||
import { pluginCustomCopyButton } from "./src/plugins/expressive-code/custom-copy-button.js";
|
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@@ -62,12 +63,12 @@ export default defineConfig({
|
|||||||
pluginCollapsibleSections(),
|
pluginCollapsibleSections(),
|
||||||
pluginLineNumbers(),
|
pluginLineNumbers(),
|
||||||
pluginLanguageBadge(),
|
pluginLanguageBadge(),
|
||||||
pluginCustomCopyButton()
|
pluginCustomCopyButton(),
|
||||||
],
|
],
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
wrap: true,
|
wrap: true,
|
||||||
overridesByLang: {
|
overridesByLang: {
|
||||||
'shellsession': {
|
shellsession: {
|
||||||
showLineNumbers: false,
|
showLineNumbers: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -77,7 +78,8 @@ export default defineConfig({
|
|||||||
borderRadius: "0.75rem",
|
borderRadius: "0.75rem",
|
||||||
borderColor: "none",
|
borderColor: "none",
|
||||||
codeFontSize: "0.875rem",
|
codeFontSize: "0.875rem",
|
||||||
codeFontFamily: "'JetBrains Mono Variable', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
codeFontFamily:
|
||||||
|
"'JetBrains Mono Variable', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace",
|
||||||
codeLineHeight: "1.5rem",
|
codeLineHeight: "1.5rem",
|
||||||
frames: {
|
frames: {
|
||||||
editorBackground: "var(--codeblock-bg)",
|
editorBackground: "var(--codeblock-bg)",
|
||||||
@@ -88,19 +90,19 @@ export default defineConfig({
|
|||||||
editorActiveTabIndicatorBottomColor: "var(--primary)",
|
editorActiveTabIndicatorBottomColor: "var(--primary)",
|
||||||
editorActiveTabIndicatorTopColor: "none",
|
editorActiveTabIndicatorTopColor: "none",
|
||||||
editorTabBarBorderBottomColor: "var(--codeblock-topbar-bg)",
|
editorTabBarBorderBottomColor: "var(--codeblock-topbar-bg)",
|
||||||
terminalTitlebarBorderBottomColor: "none"
|
terminalTitlebarBorderBottomColor: "none",
|
||||||
},
|
},
|
||||||
textMarkers: {
|
textMarkers: {
|
||||||
delHue: 0,
|
delHue: 0,
|
||||||
insHue: 180,
|
insHue: 180,
|
||||||
markHue: 250
|
markHue: 250,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
frames: {
|
frames: {
|
||||||
showCopyToClipboardButton: false,
|
showCopyToClipboardButton: false,
|
||||||
}
|
},
|
||||||
}),
|
}),
|
||||||
svelte(),
|
svelte(),
|
||||||
sitemap(),
|
sitemap(),
|
||||||
],
|
],
|
||||||
markdown: {
|
markdown: {
|
||||||
@@ -122,6 +124,7 @@ export default defineConfig({
|
|||||||
components: {
|
components: {
|
||||||
github: GithubCardComponent,
|
github: GithubCardComponent,
|
||||||
gitlab: GitlabCardComponent,
|
gitlab: GitlabCardComponent,
|
||||||
|
gitea: GiteaCardComponent,
|
||||||
note: (x, y) => AdmonitionComponent(x, y, "note"),
|
note: (x, y) => AdmonitionComponent(x, y, "note"),
|
||||||
tip: (x, y) => AdmonitionComponent(x, y, "tip"),
|
tip: (x, y) => AdmonitionComponent(x, y, "tip"),
|
||||||
important: (x, y) => AdmonitionComponent(x, y, "important"),
|
important: (x, y) => AdmonitionComponent(x, y, "important"),
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
version="1.1"
|
||||||
|
style="display:block"
|
||||||
|
viewBox="0 0 716.8 716.8"
|
||||||
|
width="350"
|
||||||
|
height="350"
|
||||||
|
id="svg33"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<defs
|
||||||
|
id="defs33" />
|
||||||
|
<path
|
||||||
|
fill="#a6d4eb"
|
||||||
|
d="m 230.10802,139.23103 c 0.173,-13.411 -0.96,-28.877 8.814,-39.464 7.389,-8.005 18.272,-9.119004 28.64,-9.535004 41.032,-1.648 82.724,-0.106 123.82,-0.127 l 51.813,0.005 c 9.99,0.009 20.354,-0.545 30.284,0.642 7.653,0.914004 14.525,1.979004 20.314,7.525004 11.444,10.963 10.268,26.372 10.306,40.893 20.284,22.728 80.22904,79.49803 98.66104,97.93003 18.432,18.432 25.14761,30.00191 31.43809,40.24191 7.26713,11.82983 9.52191,31.43809 9.52191,41.67809 v 38.91201 94.20805 65.536 c 10e-4,14.69 -0.23001,28.624 -1.59001,43.264 -0.782,8.42 -3.747,17.17 -7.872,24.55 -10.418,18.63 -27.289,27.15 -47.187,32.63 -35.013,9.63 -70.759,17.52 -106.085,25.98 -22.107,5.3 -45.268,12.64 -67.805,14.96 -23.727,2.43 -48.67,-1.44 -72.252,-4.03 l -76.089,-8.33 -78.493,-8.48 c 0,0 -74.79071,-12.3292 -78.44136,-14.048 -13.049651,-6.144 -18.812691,-11.6037 -27.385651,-20.48 -10.11256,-14.3288 -10.24,-59.392 -10.24,-59.392 v -137.4782 c 0,0 0,-77.56185 6.90598,-98.0259 3.25353,-9.64097 6.815,-19.442 12.834,-27.611 9.333,-12.667 21.849001,-23.489 32.985001,-34.589 l 68.867,-68.201 c 12.5,-12.35099 26.354,-24.48999 37.404,-38.11699 0.281,-0.346 0.554,-0.698 0.832,-1.047 z"
|
||||||
|
id="path2"
|
||||||
|
style="display:inline" />
|
||||||
|
<path
|
||||||
|
style="display:block;fill:#cccccc;fill-opacity:1;stroke:#6e6e6e;stroke-width:0.774048;stroke-opacity:0"
|
||||||
|
d="m 643.78868,330.39021 c 0,0 -0.35178,-27.03287 -1.7741,-31.92725 -1.41983,-4.88581 -2.53508,-9.81373 -4.8689,-14.84037 -2.14477,-4.61948 -7.01648,17.29298 -9.90194,10.72496 -2.78722,-6.3444 8.79403,15.24875 11.35565,18.61884 1.69708,2.23269 5.25664,7.36569 5.18929,17.42382 z"
|
||||||
|
id="path38" />
|
||||||
|
<path
|
||||||
|
fill="#1699e5"
|
||||||
|
d="m 230.10802,139.23103 c 0.173,-13.411 -0.96,-28.877 8.814,-39.464 7.389,-8.005 18.272,-9.119004 28.64,-9.535004 41.032,-1.648 82.724,-0.106 123.82,-0.127 l 51.813,0.005 c 9.99,0.009 20.354,-0.545 30.284,0.642 7.653,0.914004 14.525,1.979004 20.314,7.525004 11.444,10.963 10.268,26.372 10.306,40.893 10.00576,11.21135 47.44216,46.71115 78.18104,77.45003 16.80034,16.80034 32.89095,31.77052 43.008,45.056 8.38232,11.00748 10.65371,18.36352 12.288,22.528 6.49877,15.35792 0.88259,22.55707 -16.72729,26.34557 -4.18558,0.90047 0.0934,0.33432 0.0934,0.33432 0,0 -202.05086,7.30405 -202.12128,7.62834 -8.051,-0.129 -20.41086,-4.64727 -27.04386,-8.89427 -1.578,-1.013 -3.142,-2.048 -4.692,-3.103 -28.013,-25.054 -54.115,-52.835 -80.861,-79.286 -10.732,-10.613 -21.971,-24.411 -34.612,-32.58 -3.714,-2.401 -8.647,-2.935 -12.982,-2.788 -3.381,0.115 -7.33,0.805 -10.208,2.695 -12.667,8.319 -32.616,30.853 -44.309,42.37 -21.983,21.653 -45.778,42.738 -66.251,65.739 -4.011,4.507 -10.029,11.238 -11.317,17.186 -3.39,15.649 -2.063,33.535 -2.07,49.515 l -0.022,65.934 v 85.5 c 0.001,15.02 -0.704,30.38 0.283,45.35 0.518,7.85 2.921,13.39 8.976,18.6 1.308,1.13 1.246,1.05 2.436,1.88 -1.319,0.21 -1.48,0.26 -3.026,0.31 -13.189,0.44 -35.741001,-0.5 -47.443001,-7.45 -8.61367,-5.112 -10.59682,-8.2601 -11.30298,-14.7099 -1.898,-17.38 -4.139,-33.66 -4.096,-51.2 v -106.7582 c -0.049,-23.95 2.18598,-76.5539 6.90598,-98.0259 2.184,-9.938 6.815,-19.442 12.834,-27.611 9.333,-12.667 21.849001,-23.489 32.985001,-34.589 l 68.867,-68.201 c 12.5,-12.35099 26.354,-24.48999 37.404,-38.11699 0.281,-0.346 0.554,-0.698 0.832,-1.047 z"
|
||||||
|
id="path3"
|
||||||
|
style="display:inline" />
|
||||||
|
<path
|
||||||
|
fill="#f3f2f2"
|
||||||
|
d="m 136.14802,586.63002 c -1.19,-0.83 -1.128,-0.75 -2.436,-1.88 -6.055,-5.21 -8.458,-10.75 -8.976,-18.6 -0.987,-14.97 -0.282,-30.33 -0.283,-45.35 v -85.5 l 0.022,-65.934 c 0.007,-15.98 -1.32,-33.866 2.07,-49.515 1.288,-5.948 7.306,-12.679 11.317,-17.186 20.473,-23.001 44.268,-44.086 66.251,-65.739 11.693,-11.517 31.642,-34.051 44.309,-42.37 2.878,-1.89 6.827,-2.58 10.208,-2.695 4.335,-0.147 9.268,0.387 12.982,2.788 12.641,8.169 23.88,21.967 34.612,32.58 26.746,26.451 52.848,54.232 80.861,79.286 4.8,8.603 10.233,17.332 11.609,27.264 1.523,10.987 0.698,22.953 0.697,34.049 l -0.031,62.252 -0.072,101.49 c -0.003,18 0.671,36.25 -0.165,54.22 -0.253,5.43 -0.87,11.25 -2.449,16.46 -1.195,3.94 -3.813,6.36 -7.439,8.29 -3.468,1.85 -7.303,2.76 -11.215,2.97 -8.998,0.46 -37.971,-2.6 -46.568,-5.26 -4.434,-1.36 -8.121,-3.91 -10.245,-8.12 -5.068,-10.04 -2.472,-89.92 -2.485,-108.16 -0.009,-13.37 1.595,-28.51 -3.21,-41.18 -3.167,-8.35 -8.504,-13.62 -16.891,-16.65 -12.332,-4.45 -54.592,-8.54 -68.103,-7.35 -4.431,0.38 -8.929,1.52 -12.868,3.62 -7.818,4.17 -13,12.05 -15.438,20.4 -4.64,15.9 -2.087,80.66 -1.963,101.59 0.047,8.05 0.897,16.85 -0.424,24.78 -0.807,4.84 -2.773,10.51 -7.328,13.05 -11.859,6.63 -42.977,-1.63 -56.349,-3.6 z"
|
||||||
|
id="path4"
|
||||||
|
style="display:inline" />
|
||||||
|
<rect
|
||||||
|
style="display:inline;fill:#ffffff;fill-opacity:1;stroke:#6e6e6e;stroke-width:0.774048;stroke-opacity:0"
|
||||||
|
id="rect36"
|
||||||
|
width="186.88643"
|
||||||
|
height="6.1440268"
|
||||||
|
x="253.31686"
|
||||||
|
y="134.70003"
|
||||||
|
ry="2.976815"
|
||||||
|
rx="0" />
|
||||||
|
<rect
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:#6e6e6e;stroke-width:0.774048;stroke-opacity:0"
|
||||||
|
id="rect37"
|
||||||
|
width="36.879272"
|
||||||
|
height="6.1439657"
|
||||||
|
x="449.16003"
|
||||||
|
y="134.70003"
|
||||||
|
ry="3.0085199" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { profileConfig } from "../config";
|
import { profileConfig } from "../config";
|
||||||
import { url } from "../utils/url-utils";
|
import { url } from "../utils/url-utils";
|
||||||
|
import Recorded from "./Recorded.astro";
|
||||||
|
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
---
|
---
|
||||||
@@ -14,8 +15,6 @@ const currentYear = new Date().getFullYear();
|
|||||||
© <span id="copyright-year">{currentYear}</span> {profileConfig.name}. All Rights Reserved. /
|
© <span id="copyright-year">{currentYear}</span> {profileConfig.name}. All Rights Reserved. /
|
||||||
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href={url('rss.xml')}>RSS</a> /
|
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href={url('rss.xml')}>RSS</a> /
|
||||||
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href={url('sitemap-index.xml')}>Sitemap</a><br>
|
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href={url('sitemap-index.xml')}>Sitemap</a><br>
|
||||||
Powered by
|
<Recorded />
|
||||||
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://astro.build">Astro</a> &
|
|
||||||
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://github.com/saicaca/fuwari">Fuwari</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<a
|
||||||
|
class="whitespace-nowrap inline-flex items-center max-w-full overflow-hidden"
|
||||||
|
target="_blank"
|
||||||
|
href={"https://beian.miit.gov.cn/"}>鲁ICP备2025144068号-1</a
|
||||||
|
><br />
|
||||||
|
<a
|
||||||
|
class="whitespace-nowrap inline-flex items-center max-w-full overflow-hidden"
|
||||||
|
target="_blank"
|
||||||
|
href={"https://beian.mps.gov.cn/#/query/webSearch?code=37011302000501"}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="/recorded.png"
|
||||||
|
class="w-4 h-4 mr-1.5"
|
||||||
|
alt="备案图标"
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
鲁公网安备37011302000501号</a
|
||||||
|
><br />
|
||||||
@@ -1,10 +1,55 @@
|
|||||||
# About
|
<div class="logo-container">
|
||||||
This is the demo site for [Fuwari](https://github.com/saicaca/fuwari).
|
<img src="/image.svg" alt="icon" class="logo-icon">
|
||||||
|
<span class="logo-text">
|
||||||
|
MilkBlogs<span class="logo-dot">.</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
::github{repo="saicaca/fuwari"}
|
<style>
|
||||||
|
.logo-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
::gitlab{repo="CapaCake/milkblogs-fuwari" service="https://git.milkfunc.top"}
|
box-sizing: border-box;
|
||||||
> ### Sources of images used in this site
|
}
|
||||||
> - [Unsplash](https://unsplash.com/)
|
|
||||||
> - [星と少女](https://www.pixiv.net/artworks/108916539) by [Stella](https://www.pixiv.net/users/93273965)
|
.logo-icon {
|
||||||
> - [Rabbit - v1.4 Showcase](https://civitai.com/posts/586908) by [Rabbit_YourMajesty](https://civitai.com/user/Rabbit_YourMajesty)
|
height: clamp(3rem, 5vw, 8rem); /* 与文字大小保持一致的比例 */
|
||||||
|
width: auto;
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-right: clamp(5px, 1vw, 20px); /* 间距也响应式 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-text {
|
||||||
|
font-size: clamp(3rem, 5vw, 8rem);
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-dot {
|
||||||
|
color: #ff1e00ff
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
## 👋 Hi,欢迎来到MilkBlogs!
|
||||||
|
|
||||||
|
我是一名**电子信息专业**学生 ,立志成为一名优秀的**嵌入式系统工程师**。
|
||||||
|
## 🏗技术栈
|
||||||
|
* 📟 嵌入式 MCU 开发 (Bare-metal & RTOS)
|
||||||
|
* 🐧 嵌入式 Linux
|
||||||
|
* <...> C / C++ , Python ,Shell , Rust (探索中)
|
||||||
|
## 🚀开源
|
||||||
|
网站项目已开源
|
||||||
|
::gitea{repo="CapaCake/milkblogs-fuwari" service="https://git.milkfunc.top"}
|
||||||
|
## 📬建立联系
|
||||||
|
如果你有什么问题,欢迎交流:
|
||||||
|
* **GitHub**: [@CapaCake](https://github.com/CapaCake)
|
||||||
|
* **Blog**: [milkfunc.top](https://milkfunc.top)
|
||||||
|
* **Email**: [executor.cat@outlook.com](executor.cat@outlook.com)
|
||||||
|
## 🥂鸣谢
|
||||||
|
本站基于以下优秀的开源项目构建:
|
||||||
|
* **Framework**: [Astro](https://astro.build/)
|
||||||
|
* **BlogTemplate**: [Fuwari](https://github.com/saicaca/fuwari)
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/// <reference types="mdast" />
|
||||||
|
import { h } from "hastscript";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Gitea Card component.
|
||||||
|
*
|
||||||
|
* @param {Object} properties - The properties of the component.
|
||||||
|
* @param {string} properties.repo - The Gitea repository in the format "owner/repo".
|
||||||
|
* @param {string} properties.service - (optional) Third-Party Gitea service provider.
|
||||||
|
* @param {import('mdast').RootContent[]} children - The children elements of the component.
|
||||||
|
* @returns {import('mdast').Parent} The created Gitea Card component.
|
||||||
|
*/
|
||||||
|
export function GiteaCardComponent(properties, children) {
|
||||||
|
if (Array.isArray(children) && children.length !== 0)
|
||||||
|
return h("div", { class: "hidden" }, [
|
||||||
|
'Invalid directive. ("gitea" directive must be leaf type "::gitea{repo="owner/repo"}")',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!properties.repo || !properties.repo.includes("/"))
|
||||||
|
return h(
|
||||||
|
"div",
|
||||||
|
{ class: "hidden" },
|
||||||
|
'Invalid repository. ("repo" attributte must be in the format "owner/repo")',
|
||||||
|
);
|
||||||
|
|
||||||
|
const repo = properties.repo;
|
||||||
|
const service = properties?.service || "https://gitea.com";
|
||||||
|
const cardUuid = `GC${Math.random().toString(36).slice(-6)}`;
|
||||||
|
|
||||||
|
const nAvatar = h(`div#${cardUuid}-avatar`, { class: "gc-avatar" });
|
||||||
|
const nLanguage = h(
|
||||||
|
`span#${cardUuid}-language`,
|
||||||
|
{ class: "gc-language" },
|
||||||
|
"Waiting...",
|
||||||
|
);
|
||||||
|
|
||||||
|
const nTitle = h("div", { class: "gc-titlebar" }, [
|
||||||
|
h("div", { class: "gc-titlebar-left" }, [
|
||||||
|
h("div", { class: "gc-owner" }, [
|
||||||
|
nAvatar,
|
||||||
|
h("div", { class: "gc-user" }, repo.split("/")[0]),
|
||||||
|
]),
|
||||||
|
h("div", { class: "gc-divider" }, "/"),
|
||||||
|
h("div", { class: "gc-repo" }, repo.split("/")[1]),
|
||||||
|
]),
|
||||||
|
h("div", { class: "gitea-logo" }),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const nDescription = h(
|
||||||
|
`div#${cardUuid}-description`,
|
||||||
|
{ class: "gc-description" },
|
||||||
|
"Waiting for Gitea API...",
|
||||||
|
);
|
||||||
|
|
||||||
|
const nStars = h(`div#${cardUuid}-stars`, { class: "gc-stars" }, "00K");
|
||||||
|
const nForks = h(`div#${cardUuid}-forks`, { class: "gc-forks" }, "0K");
|
||||||
|
|
||||||
|
const nScript = h(
|
||||||
|
`script#${cardUuid}-script`,
|
||||||
|
{ type: "text/javascript", defer: true },
|
||||||
|
`
|
||||||
|
fetch('${service}/api/v1/repos/${repo}', { referrerPolicy: "no-referrer" }).then(response => response.json()).then(data => {
|
||||||
|
document.getElementById('${cardUuid}-description').innerText = data.description?.replace(/:[a-zA-Z0-9_]+:/g, '') || "Description not set";
|
||||||
|
document.getElementById('${cardUuid}-language').innerText = data.language;
|
||||||
|
document.getElementById('${cardUuid}-forks').innerText = Intl.NumberFormat('en-us', { notation: "compact", maximumFractionDigits: 1 }).format(data.forks_count).replaceAll("\\u202f", '');
|
||||||
|
document.getElementById('${cardUuid}-stars').innerText = Intl.NumberFormat('en-us', { notation: "compact", maximumFractionDigits: 1 }).format(data.stars_count).replaceAll("\\u202f", '');
|
||||||
|
const avatarEl = document.getElementById('${cardUuid}-avatar');
|
||||||
|
avatarEl.style.backgroundImage = 'url(' + data.owner.avatar_url + ')';
|
||||||
|
avatarEl.style.backgroundColor = 'transparent';
|
||||||
|
document.getElementById('${cardUuid}-card').classList.remove("fetch-waiting");
|
||||||
|
console.log("[GITEA-CARD] Loaded card for ${repo} | ${cardUuid}.")
|
||||||
|
}).catch(err => {
|
||||||
|
const c = document.getElementById('${cardUuid}-card');
|
||||||
|
c?.classList.add("fetch-error");
|
||||||
|
console.warn("[GITEA-CARD] (Error) Loading card for ${repo} | ${cardUuid}.")
|
||||||
|
})
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
|
||||||
|
return h(
|
||||||
|
`a#${cardUuid}-card`,
|
||||||
|
{
|
||||||
|
class: "card-github fetch-waiting no-styling",
|
||||||
|
href: `${service}/${repo}`,
|
||||||
|
target: "_blank",
|
||||||
|
repo,
|
||||||
|
},
|
||||||
|
[
|
||||||
|
nTitle,
|
||||||
|
nDescription,
|
||||||
|
h("div", { class: "gc-infobar" }, [nStars, nForks, nLanguage]),
|
||||||
|
nScript,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -163,7 +163,7 @@ a.card-github
|
|||||||
.gc-language
|
.gc-language
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
.gc-stars, .gc-forks, .gc-license, .github-logo, .gitlab-logo
|
.gc-stars, .gc-forks, .gc-license, .github-logo, .gitlab-logo, .gitea-logo
|
||||||
font-weight: 500
|
font-weight: 500
|
||||||
font-size: 0.875rem
|
font-size: 0.875rem
|
||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
@@ -214,6 +214,14 @@ a.card-github
|
|||||||
margin-right: 0
|
margin-right: 0
|
||||||
mask-image: url("https://images.ctfassets.net/xz1dnu24egyd/4V92fFTJOIlTPHHzSdfxem/3fdc9f0d82f08ed4c355c6e4126b870c/gitlab-logo-600.svg")
|
mask-image: url("https://images.ctfassets.net/xz1dnu24egyd/4V92fFTJOIlTPHHzSdfxem/3fdc9f0d82f08ed4c355c6e4126b870c/gitlab-logo-600.svg")
|
||||||
|
|
||||||
|
.gitea-logo
|
||||||
|
font-size: 1.25rem
|
||||||
|
|
||||||
|
&:before
|
||||||
|
background-color: var(--tw-prose-headings)
|
||||||
|
margin-right: 0
|
||||||
|
mask-image: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 640 640%22%3E%3Cpath fill=%22%23609926%22 d=%22M622.7 149.8c-4.1-4.1-9.6-4-9.6-4s-117.2 6.6-177.9 8c-13.3 0.3-26.5 0.6-39.6 0.7c0 39.1 0 78.2 0 117.2c-5.5-2.6-11.1-5.3-16.6-7.9c0-36.4-0.1-109.2-0.1-109.2c-29 0.4-89.2-2.2-89.2-2.2s-141.4-7.1-156.8-8.5c-9.8-0.6-22.5-2.1-39 1.5c-8.7 1.8-33.5 7.4-53.8 26.9C-4.9 212.4 6.6 276.2 8 285.8c1.7 11.7 6.9 44.2 31.7 72.5c45.8 56.1 144.4 54.8 144.4 54.8s12.1 28.9 30.6 55.5c25 33.1 50.7 58.9 75.7 62c63 0 188.9-0.1 188.9-0.1s12 0.1 28.3-10.3c14-8.5 26.5-23.4 26.5-23.4s12.9-13.8 30.9-45.3c5.5-9.7 10.1-19.1 14.1-28c0 0 55.2-117.1 55.2-231.1C633.2 157.9 624.7 151.8 622.7 149.8z M125.6 353.9c-25.9-8.5-36.9-18.7-36.9-18.7S69.6 321.8 60 295.4c-16.5-44.2-1.4-71.2-1.4-71.2s8.4-22.5 38.5-30c13.8-3.7 31-3.1 31-3.1s7.1 59.4 15.7 94.2c7.2 29.2 24.8 77.7 24.8 77.7S142.5 359.9 125.6 353.9z M425.9 461.5c0 0-6.1 14.5-19.6 15.4c-5.8 0.4-10.3-1.2-10.3-1.2s-0.3-0.1-5.3-2.1l-112.9-55c0 0-10.9-5.7-12.8-15.6c-2.2-8.1 2.7-18.1 2.7-18.1L322 273c0 0 4.8-9.7 12.2-13c0.6-0.3 2.3-1 4.5-1.5c8.1-2.1 18 2.8 18 2.8l110.7 53.7c0 0 12.6 5.7 15.3 16.2c1.9 7.4-0.5 14-1.8 17.2C474.6 363.8 425.9 461.5 425.9 461.5z%22/%3E%3Cpath fill=%22%23609926%22 d=%22M326.8 380.1c-8.2 0.1-15.4 5.8-17.3 13.8c-1.9 8 2 16.3 9.1 20c7.7 4 17.5 1.8 22.7-5.4c5.1-7.1 4.3-16.9-1.8-23.1l24-49.1c1.5 0.1 3.7 0.2 6.2-0.5c4.1-0.9 7.1-3.6 7.1-3.6c4.2 1.8 8.6 3.8 13.2 6.1c4.8 2.4 9.3 4.9 13.4 7.3c0.9 0.5 1.8 1.1 2.8 1.9c1.6 1.3 3.4 3.1 4.7 5.5c1.9 5.5-1.9 14.9-1.9 14.9c-2.3 7.6-18.4 40.6-18.4 40.6c-8.1-0.2-15.3 5-17.7 12.5c-2.6 8.1 1.1 17.3 8.9 21.3c7.8 4 17.4 1.7 22.5-5.3c5-6.8 4.6-16.3-1.1-22.6c1.9-3.7 3.7-7.4 5.6-11.3c5-10.4 13.5-30.4 13.5-30.4c0.9-1.7 5.7-10.3 2.7-21.3c-2.5-11.4-12.6-16.7-12.6-16.7c-12.2-7.9-29.2-15.2-29.2-15.2s0-4.1-1.1-7.1c-1.1-3.1-2.8-5.1-3.9-6.3c4.7-9.7 9.4-19.3 14.1-29c-4.1-2-8.1-4-12.2-6.1c-4.8 9.8-9.7 19.7-14.5 29.5c-6.7-0.1-12.9 3.5-16.1 9.4c-3.4 6.3-2.7 14.1 1.9 19.8C343.2 346.5 335 363.3 326.8 380.1z%22/%3E%3C/svg%3E")
|
||||||
|
|
||||||
a.card-github.fetch-waiting
|
a.card-github.fetch-waiting
|
||||||
pointer-events: none
|
pointer-events: none
|
||||||
opacity: 0.7
|
opacity: 0.7
|
||||||
@@ -247,7 +255,7 @@ a.card-github.fetch-error
|
|||||||
100%
|
100%
|
||||||
opacity: 0.15
|
opacity: 0.15
|
||||||
|
|
||||||
.card-github, .gc-description, .gc-titlebar, .gc-stars, .gc-forks, .gc-license, .gc-avatar, .github-logo, .gitlab-logo
|
.card-github, .gc-description, .gc-titlebar, .gc-stars, .gc-forks, .gc-license, .gc-avatar, .github-logo, .gitlab-logo, .gitea-logo
|
||||||
transition-property: all
|
transition-property: all
|
||||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1)
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1)
|
||||||
transition-duration: 0.15s
|
transition-duration: 0.15s
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
&:hover, &:active {
|
&:hover, &:active {
|
||||||
@apply decoration-transparent;
|
@apply decoration-transparent;
|
||||||
background: var(--btn-plain-bg-hover);
|
background: var(--btn-plain-bg-hover);
|
||||||
border-bottom: 1px dashed var(--link-hover);
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user