minearm-website 0.0.3-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -0
  3. package/astro.config.ts +33 -0
  4. package/minearm.ts +174 -0
  5. package/package.json +64 -0
  6. package/public/13.jpg +0 -0
  7. package/public/1937daxue.png +0 -0
  8. package/public/3.png +0 -0
  9. package/public/404.png +0 -0
  10. package/public/5.jpg +0 -0
  11. package/public/BC.png +0 -0
  12. package/public/Chinese.png +0 -0
  13. package/public/avatar.avif +0 -0
  14. package/public/avatar.jpg +0 -0
  15. package/public/c++1.png +0 -0
  16. package/public/docker-hub.png +0 -0
  17. package/public/favicon.png +0 -0
  18. package/public/help1.png +0 -0
  19. package/public/heroimg.jpg +0 -0
  20. package/public/logo.png +0 -0
  21. package/public/mail.png +0 -0
  22. package/public/nahida.png +0 -0
  23. package/public/pojipao.avif +0 -0
  24. package/public/rust1.png +0 -0
  25. package/public/scripts/mdata.json +4 -0
  26. package/public/scripts/utils.js +190 -0
  27. package/public/xmrig.jpg +0 -0
  28. package/src/components/BodyInject.astro +5 -0
  29. package/src/components/HeadInject.astro +16 -0
  30. package/src/components/Search.astro +30 -0
  31. package/src/components/animation/bubbles.astro +82 -0
  32. package/src/components/animation/wave.astro +81 -0
  33. package/src/components/aside/announcement.astro +25 -0
  34. package/src/components/aside/aside.astro +32 -0
  35. package/src/components/aside/asideComps.astro +26 -0
  36. package/src/components/aside/authorInfo.astro +54 -0
  37. package/src/components/aside/blogToc.astro +26 -0
  38. package/src/components/aside/countScript.astro +18 -0
  39. package/src/components/aside/customCard.astro +23 -0
  40. package/src/components/aside/siteInfo.astro +51 -0
  41. package/src/components/client/searchCore.vue +77 -0
  42. package/src/components/client/themeControl.vue +77 -0
  43. package/src/components/footer/Footer.astro +32 -0
  44. package/src/components/header/Header.astro +40 -0
  45. package/src/components/header/HeaderButton.astro +59 -0
  46. package/src/components/header/HeaderItem.astro +63 -0
  47. package/src/components/header/heroWave.astro +19 -0
  48. package/src/components/header/searchBar.astro +21 -0
  49. package/src/components/icons/bilibili.astro +10 -0
  50. package/src/components/icons/c.astro +10 -0
  51. package/src/components/icons/code.astro +37 -0
  52. package/src/components/icons/computer.astro +4 -0
  53. package/src/components/icons/cube.astro +10 -0
  54. package/src/components/icons/game.astro +10 -0
  55. package/src/components/icons/getIcon.astro +64 -0
  56. package/src/components/icons/github.astro +10 -0
  57. package/src/components/icons/hardDriver.astro +10 -0
  58. package/src/components/icons/home.astro +14 -0
  59. package/src/components/icons/icon.ts +33 -0
  60. package/src/components/icons/icons.json +91961 -0
  61. package/src/components/icons/link.astro +4 -0
  62. package/src/components/icons/mail.astro +10 -0
  63. package/src/components/icons/paperPlane.astro +4 -0
  64. package/src/components/icons/pen.astro +14 -0
  65. package/src/components/icons/person.astro +14 -0
  66. package/src/components/icons/searchicon.astro +23 -0
  67. package/src/components/icons/tags.astro +10 -0
  68. package/src/components/icons/toTop.astro +10 -0
  69. package/src/components/icons/tools.astro +1 -0
  70. package/src/components/loading/loading.vue +185 -0
  71. package/src/components/postComment.astro +62 -0
  72. package/src/components/postlist/pagination.astro +40 -0
  73. package/src/components/postlist/postsList.astro +57 -0
  74. package/src/content/blog/default/Extended Search.md +50 -0
  75. package/src/content/blog/default/Mail.md +15 -0
  76. package/src/content/blog/default/history//345/205/254/345/205/203/345/211/215//347/247/246/345/247/213/347/232/207/347/273/237/344/270/200/345/205/255/345/233/275.md +40 -0
  77. package/src/content/blog/default/history//350/277/221/344/273/243/347/257/207//344/270/255/345/233/275/345/205/261/344/272/247/345/205/232/345/205/232/345/217/262.md +2361 -0
  78. package/src/content/blog/default/it/Rust/345/237/272/346/234/254/350/257/255/346/263/225.md +298 -0
  79. package/src/content/config.ts +38 -0
  80. package/src/env.d.ts +148 -0
  81. package/src/layouts/BaseLayout.astro +67 -0
  82. package/src/layouts/DefaultMdLayout.astro +46 -0
  83. package/src/layouts/HomeLayout.astro +27 -0
  84. package/src/layouts/PostLayout.astro +60 -0
  85. package/src/layouts/TagsLayout.astro +44 -0
  86. package/src/layouts/c.astro +42 -0
  87. package/src/layouts/h.astro +60 -0
  88. package/src/pages/404.md +10 -0
  89. package/src/pages/[...page].astro +46 -0
  90. package/src/pages/about/index.md +90 -0
  91. package/src/pages/blog/[...slug].astro +68 -0
  92. package/src/pages/categories/[category]/[...page].astro +45 -0
  93. package/src/pages/categories/index.astro +20 -0
  94. package/src/pages/friends/index.md +24 -0
  95. package/src/pages/rss.xml.js +20 -0
  96. package/src/pages/tags/[tag]/[...page].astro +42 -0
  97. package/src/pages/tags/index.astro +19 -0
  98. package/src/site_config.ts +15 -0
  99. package/src/styles/animation.scss +94 -0
  100. package/src/styles/blog/blog.scss +124 -0
  101. package/src/styles/blog/code.scss +111 -0
  102. package/src/styles/blog/directives.scss +356 -0
  103. package/src/styles/blog/index.scss +4 -0
  104. package/src/styles/blog/post.scss +474 -0
  105. package/src/styles/components/aside.scss +178 -0
  106. package/src/styles/components/footer.scss +74 -0
  107. package/src/styles/components/header.scss +421 -0
  108. package/src/styles/components/heroWave.scss +24 -0
  109. package/src/styles/components/main.scss +275 -0
  110. package/src/styles/components/page-content.scss +147 -0
  111. package/src/styles/components/pagination.scss +121 -0
  112. package/src/styles/components/search.scss +349 -0
  113. package/src/styles/custom.scss +21 -0
  114. package/src/styles/global.scss +167 -0
  115. package/src/styles/mixin.scss +17 -0
  116. package/src/styles/tags/tags.scss +83 -0
  117. package/src/theme_config.ts +178 -0
  118. package/src/utils/generateSearchData.ts +30 -0
  119. package/src/utils/md.ts +114 -0
  120. package/src/utils/processMd.ts +278 -0
  121. package/src/utils/utils.ts +87 -0
  122. package/tsconfig.json +32 -0
  123. package/vercel.json +26 -0
@@ -0,0 +1,278 @@
1
+ import type { Child } from "hastscript";
2
+ import type { Element } from "hastscript/lib/core";
3
+ import { h } from "hastscript";
4
+
5
+ export const processRemark = {
6
+ processBlockquote: function (node: any) {
7
+ const iLeft = h("i", { className: ["fa-solid", "fa-quote-left"] });
8
+ const iRight = h("i", { className: ["fa-solid", "fa-quote-right"] });
9
+
10
+ for (let i = 0; i < node.children.length; i++) {
11
+ if (node.children[i].tagName !== "p") continue;
12
+ node.children.splice(i + 1, 0, iRight);
13
+ node.children.splice(i, 0, iLeft);
14
+ i += 2;
15
+ }
16
+ },
17
+
18
+ processTable: function (node: any, parent: any, index: any) {
19
+ const wrap = h("div.table-wrap", node);
20
+ parent.children.splice(index, 1, wrap);
21
+ },
22
+
23
+ processImg: function (node: any, parent: any, index: any) {
24
+ parent.tagName = "div";
25
+ parent.properties.className = "image";
26
+
27
+ const fancybox = h(
28
+ "a.img-wrap",
29
+ {
30
+ "data-fancybox": "",
31
+ "data-caption": node.properties.alt,
32
+ href: node.properties.src,
33
+ },
34
+ node
35
+ );
36
+
37
+ parent.children.splice(index, 1, fancybox);
38
+
39
+ if (
40
+ index &&
41
+ parent.children.length > index + 1 &&
42
+ parent.children[index + 1].type === "text"
43
+ ) {
44
+ const comment = h("span.img-comment", parent.children[index + 1]);
45
+ parent.children.splice(index + 1, 1, comment);
46
+ }
47
+ },
48
+
49
+ processA: function (node: any) {
50
+ node.properties.className = node.properties.className || "link";
51
+ },
52
+ };
53
+
54
+ export const processRehype = {
55
+ processCode: function (node: any, parent: any, index: any) {
56
+ let lineNumbers = "";
57
+ node.meta = {
58
+ lang: node.lang || "code",
59
+ };
60
+ for (
61
+ let i = 0;
62
+ i < node.value.replace(/\n+$/, "").split("\n").length;
63
+ i++
64
+ ) {
65
+ lineNumbers += '<div class="line-number"></div>';
66
+ }
67
+ const newNode = [
68
+ {
69
+ type: "html",
70
+ value: `<div class='code-block'><div class='code-lang'>${node.meta.lang}</div><div class='code-wrap'>`,
71
+ },
72
+ node,
73
+ {
74
+ type: "html",
75
+ value: `<div class="line-numbers">${lineNumbers}</div></div><div class='code-copy' title='copy code' onclick='hsu.copyCode(event)'><i class="fa-solid fa-copy"></i></div></div>`,
76
+ },
77
+ ];
78
+ parent.children.splice(index, 1, ...newNode);
79
+ },
80
+
81
+ processLink: function (node: any) {
82
+ const icon = {
83
+ type: "html",
84
+ value: '<i class="fa-solid fa-link"></i>',
85
+ };
86
+ node.children.push(icon);
87
+ },
88
+ };
89
+
90
+ export const processDir = {
91
+ dirLink: function (node: any, parent: any) {
92
+ const attributes = node.attributes || {};
93
+ const wrap = hh(
94
+ "a.dir-link",
95
+ {
96
+ href: attributes.link || "javascript:void(0);",
97
+ style: `background: ${attributes.color || "rgba(255, 255, 255, .2)"};`,
98
+ id: attributes.id,
99
+ class: attributes.class,
100
+ },
101
+ h(
102
+ "div.dir-link-logo-wrap",
103
+ h("img.dir-link-logo", {
104
+ src: attributes.logo,
105
+ })
106
+ ),
107
+ h(
108
+ "div.dir-link-content",
109
+ h("div.dir-link-header", node.children[0].value),
110
+ h("div.dir-link-desc", attributes.desc)
111
+ )
112
+ );
113
+ Object.assign(node, wrap);
114
+ },
115
+
116
+ dirLinks: function (node: any) {
117
+ const { children } = node;
118
+ let i, child;
119
+
120
+ for (i = 0; i < children.length; i++) {
121
+ child = children[i];
122
+
123
+ if (child?.data?.directiveLabel) {
124
+ Object.assign(
125
+ child,
126
+ hh("div.dir-links-title", child.children[0].value)
127
+ );
128
+ } else if (child.name === "link") {
129
+ break;
130
+ }
131
+ }
132
+
133
+ const links = children.splice(i);
134
+ children.push(hh("div.dir-links-links", ...links));
135
+ simpleConvert(node, "div.dir-links");
136
+ },
137
+ dirColor: function (node: any) {
138
+ simpleConvert(node, "span.dir-color");
139
+ node.data.hProperties.style =
140
+ (node.data.hProperties.style || "") +
141
+ `color:${node.attributes.color || ""};`;
142
+ node.data.hProperties.style =
143
+ (node.data.hProperties.style || "") +
144
+ `background:${node.attributes.bg || ""};`;
145
+ },
146
+ dirNoteL: function (node: any, index: number | null, parent: any) {
147
+ parent.children.splice(
148
+ index,
149
+ 1,
150
+ hh(
151
+ "div.dir-note-wrap",
152
+ {
153
+ style: `background: ${node.attributes.bg || ""};color: ${
154
+ node.attributes.color || ""
155
+ };border-left-color: ${node.attributes.color || ""}`,
156
+ class: node.attributes.class,
157
+ id: node.attributes.id,
158
+ },
159
+ h("i.dir-note-icon", {
160
+ class: node.attributes.icon,
161
+ }),
162
+ Object.assign(node, hh("span.dir-note", node.children))
163
+ )
164
+ );
165
+ },
166
+ dirTimeline: function (node: any, index: number | null, parent: any) {
167
+ const { title, content } = getTitleAndContent(node);
168
+ const color = node.attributes.color || "";
169
+ const times = h(
170
+ "div.dir-timeline-time",
171
+ {
172
+ style: `color: ${color};`,
173
+ },
174
+ h("div.dir-timeline-line", {
175
+ style: `border-color: ${color};`,
176
+ }),
177
+ ...content
178
+ );
179
+ for (let i = 0; i < times.children.length; i++) {
180
+ let child = times.children[i] as any;
181
+ if (child.type === "containerDirective" && child.name === "time")
182
+ this.dirTime(child, i, times);
183
+ }
184
+ Object.assign(
185
+ title,
186
+ hh(
187
+ "div.dir-timeline-title",
188
+ title?.children ? title.children[0]?.value : ""
189
+ )
190
+ );
191
+ parent.children.splice(index, 1, hh("ul.dir-timeline", title, times));
192
+ },
193
+ dirTime: function (node: any, index: number | null, parent: any) {
194
+ const { title: time, content } = getTitleAndContent(node);
195
+ const color = node.attributes.color || "";
196
+ const timecolor = node.attributes.timecolor || "";
197
+ const bg = node.attributes.bg || "";
198
+ parent.children.splice(
199
+ index,
200
+ 1,
201
+ hh(
202
+ "li.dir-time-wrap",
203
+ {
204
+ class: node.attributes.class || "",
205
+ id: node.attributes.id || "",
206
+ },
207
+ h(
208
+ "div.dir-time",
209
+ {
210
+ style: `color: ${timecolor};`,
211
+ },
212
+ time?.children ? time.children[0]?.value : ""
213
+ ),
214
+ h(
215
+ "div.dir-time-content",
216
+ {
217
+ style: `color: ${color};background: ${bg};`,
218
+ },
219
+ ...content
220
+ ),
221
+ h("div.dir-time-circle", {
222
+ style: `border-color: ${bg};`,
223
+ })
224
+ )
225
+ );
226
+ },
227
+ };
228
+
229
+ function getTitleAndContent(node: any) {
230
+ let title: any = {},
231
+ content: Child[] = [];
232
+ if (node.children[0].data?.directiveLabel === true) {
233
+ title = node.children[0];
234
+ content = node.children.splice(1);
235
+ } else {
236
+ content = node.children.splice(0);
237
+ }
238
+ return {
239
+ title: title,
240
+ content: content,
241
+ };
242
+ }
243
+
244
+ function simpleConvert(node: any, tagName: string, properties?: object) {
245
+ Object.assign(
246
+ node,
247
+ hh(
248
+ tagName,
249
+ {
250
+ class: node.attributes.class,
251
+ id: node.attributes.id,
252
+ ...properties,
253
+ },
254
+ node.children
255
+ )
256
+ );
257
+ }
258
+
259
+ function convertToRemarkFormat(hastNode: any): any {
260
+ if ((hastNode.type as any) === "text") return hastNode;
261
+ const children = hastNode.children as Element[];
262
+ hastNode.data = {
263
+ hName: hastNode.tagName,
264
+ hProperties: hastNode.properties,
265
+ };
266
+ hastNode.children = children?.map(convertToRemarkFormat);
267
+ return hastNode;
268
+ }
269
+
270
+ function hh(
271
+ tagName: string,
272
+ properties?: Record<string, any>,
273
+ ...children: Child[]
274
+ ) {
275
+ // console.log(tagName, properties, children);
276
+ const hastNode = h(tagName, properties, ...children);
277
+ return convertToRemarkFormat(hastNode);
278
+ }
@@ -0,0 +1,87 @@
1
+ export const utils = {
2
+ checkURL: function (URL: string) {
3
+ const regex =
4
+ /\b(https?):\/\/[\-A-Za-z0-9+&@#\/%?=~_|!:,.;]*[\-A-Za-z0-9+&@#\/%=~_|]/i;
5
+ return regex.test(URL);
6
+ },
7
+ replaceLink: function (str: string, customClass?: string): string {
8
+ let regex = /\[(.*?)\]\((.*?)\)/g;
9
+ return str.replace(regex, function (_, text, link) {
10
+ return `<a href="${link}" class="${customClass}">${text}</a>`;
11
+ });
12
+ },
13
+ executeEmbeddedScripts: function (str: string): string {
14
+ const pattern = /\{\{\s*([\s\S]*?)\s*\}\}/g;
15
+
16
+ let result = str.replace(pattern, function (_, match) {
17
+ let func;
18
+ try {
19
+ func = new Function(`return (function(){${match};})()`)();
20
+ } catch (err) {
21
+ console.error(err);
22
+ return "";
23
+ }
24
+ return func;
25
+ });
26
+
27
+ return result;
28
+ },
29
+ formatDate: (date: Date) => {
30
+ var formattedDate = date.toLocaleDateString("zh-CN", {
31
+ year: "numeric",
32
+ month: "2-digit",
33
+ day: "2-digit",
34
+ });
35
+
36
+ // 返回格式化后的日期
37
+ return formattedDate;
38
+ },
39
+ compareDates: (date1: string, date2: string): number => {
40
+ const d1 = new Date(date1);
41
+ const d2 = new Date(date2);
42
+
43
+ return d2.valueOf() - d1.valueOf();
44
+ },
45
+ generateIdFromHeading: (heading: string): string => {
46
+ // 没有找到 remark 官方的处理函数
47
+ return (
48
+ heading
49
+ .trim()
50
+ .toLowerCase()
51
+ // 替换空格为 '-'
52
+ .replace(/[\s]+/g, "-")
53
+ // 除了字母、数字、中文字符、和 '-' 之外的所有字符都被移除
54
+ .replace(/[^\w\u4e00-\u9fa5\-]+/g, "")
55
+ // 替换多个 '-' 为单个 '-'
56
+ .replace(/\-\-+/g, "-")
57
+ );
58
+ },
59
+ extractSummary: (markdown: string): string => {
60
+ // 移除 Markdown 标题标记
61
+ const noHeaders = markdown.replace(/^(#.*\n)*/g, "");
62
+
63
+ // 移除 Markdown 格式化
64
+ const noFormatting = noHeaders.replace(/(\*|\_|`|#)/g, "");
65
+
66
+ // 删除 Markdown 链接和图片
67
+ const noLinksOrImages = noFormatting.replace(/\[([^\]]*)\]\([^\)]*\)/g, "");
68
+
69
+ // 移除行尾的换行符
70
+ const noLinebreaks = noLinksOrImages.replace(/\n/g, " ");
71
+
72
+ // 返回前100个字符
73
+ return noLinebreaks.slice(0, 100);
74
+ },
75
+ cleanContent: function (content: string): string {
76
+ content = content
77
+ .replace(/```[\s\S]*?```/g, "")
78
+ .replace(/`.*?`/g, "")
79
+ .replace(/\[.*?\]\(.*?\)/g, "")
80
+ .replace(/[*#\-_]+/g, " ")
81
+ .replace(/[\n\t]/g, "")
82
+ .replace(/\s+/g, " ")
83
+ .trim();
84
+
85
+ return content;
86
+ },
87
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "ts-node": {
3
+ "esm": true
4
+ },
5
+ "extends": "astro/tsconfigs/strict",
6
+ "compilerOptions": {
7
+ "resolveJsonModule": true,
8
+ "baseUrl": ".",
9
+ "strictNullChecks": true,
10
+ "jsx": "preserve",
11
+ "paths": {
12
+ "@comp/*": [
13
+ "src/components/*"
14
+ ],
15
+ "@ass/*": [
16
+ "src/assets/*"
17
+ ],
18
+ "@style/*": [
19
+ "src/styles/*"
20
+ ],
21
+ "@src/*": [
22
+ "src/*"
23
+ ],
24
+ "@utils/*": [
25
+ "src/utils/*"
26
+ ],
27
+ "@layout/*": [
28
+ "src/layouts/*"
29
+ ]
30
+ }
31
+ }
32
+ }
package/vercel.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "headers": [
3
+ {
4
+ "source": "/sw.js",
5
+ "headers": [
6
+ {
7
+ "key": "Cache-Control",
8
+ "value": "public, max-age=0, must-revalidate"
9
+ }
10
+ ]
11
+ },
12
+ {
13
+ "source": "(.*)",
14
+ "headers": [
15
+ {
16
+ "key": "Cache-Control",
17
+ "value": "public, s-maxage=86400, max-age=86400"
18
+ },
19
+ {
20
+ "key": "Vercel-CDN-Cache-Control",
21
+ "value": "max-age=3600"
22
+ }
23
+ ]
24
+ }
25
+ ]
26
+ }