From 27174a3e10b0136578079f972578c2afbd9cac6c Mon Sep 17 00:00:00 2001
From: white0dew <1373685219@qq.com>
Date: Wed, 19 Jun 2024 23:45:19 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E4=B8=BB?=
=?UTF-8?q?=E9=A1=B5=EF=BC=8C=E5=B0=9D=E8=AF=95=E4=BD=BF=E7=94=A8fallback?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/s/[...slug]/page.tsx | 10 ++++
components/home/ProductShow.tsx | 12 ++---
lib/friend-links.ts | 84 +++++++++++++++++++++++++++++++++
3 files changed, 100 insertions(+), 6 deletions(-)
create mode 100644 lib/friend-links.ts
diff --git a/app/s/[...slug]/page.tsx b/app/s/[...slug]/page.tsx
index 64b3126..f2e8592 100644
--- a/app/s/[...slug]/page.tsx
+++ b/app/s/[...slug]/page.tsx
@@ -19,6 +19,7 @@ import siteMetadata from "@/assets/siteMetadata";
import MDViewer from "@/components/markdown/MarkdownView";
import Image from "next/image";
import { ContentPrefixPath } from "@/constants/path";
+import { Suspense } from "react";
export const dynamicParams = true;
export const revalidate = 60 * 60 * 1; //60*60*1 s
@@ -181,6 +182,13 @@ export async function generateMetadata({
};
}
+const LoadingSpinner = () => (
+
+ {/* 你可以使用你喜欢的加载指示器样式 */}
+
Loading...
+
+);
+
export default function ArticlePage({
params,
}: {
@@ -195,6 +203,7 @@ export default function ArticlePage({
}
// mylog(curArticle?.body.raw)
return (
+ // }>
+ //
);
}
diff --git a/components/home/ProductShow.tsx b/components/home/ProductShow.tsx
index 2238aff..51d869b 100644
--- a/components/home/ProductShow.tsx
+++ b/components/home/ProductShow.tsx
@@ -8,38 +8,38 @@ import Link from "next/link";
// TODO 改成语雀可配置
const products = [
{
- name: "程序员自我修养",
+ name: "🔥程序员自我修养",
description:
"软技能同样重要。提升沟通、团队协作能力,培养解决问题的思维,助你成为更全面的开发者。",
path: "/s/self_improve/screct_qas",
},
// ...更多产品
{
- name: "编程语言",
+ name: "📚编程语言",
description:
"掌握流行的编程语言是开发者的基础。详解Java、Golang、Python、JavaScript等语言特性,助你深入理解语法和应用场景。",
path: "/s/language",
},
{
- name: "计算机基础",
+ name: "💻计算机基础",
description:
"精炼的计算机基础讲解,包括数据结构、算法、计算机网络等计算机基础知识,帮助你通过技术面试的第一关。",
path: "/s/cs_base",
},
{
- name: "实践项目",
+ name: "🧰实践项目",
description:
"实战项目经验分享,包括项目规划、开发到部署的全过程,提升你的项目构建与管理能力。",
path: "/s/project",
},
{
- name: "大厂面经",
+ name: "💹大厂面经",
description:
"来自一线大厂的真实面试经验总结,涵盖前端、后端到AI等多个领域,为你的求职之路增添砝码。",
path: "/s/interview/chat_view",
},
{
- name: "区区算法",
+ name: "⬇️区区算法",
description:
"汲取大厂资深面试官的智慧精华,提供全面的前端、后端及人工智能面试策略,助你在职场竞争中脱颖而出。",
path: "/s/algorithm/hogrunp9g0bggri2",
diff --git a/lib/friend-links.ts b/lib/friend-links.ts
new file mode 100644
index 0000000..64e591b
--- /dev/null
+++ b/lib/friend-links.ts
@@ -0,0 +1,84 @@
+const fs = require("fs");
+// function extractWebsiteInfoFromMarkdown(markdown: string): WebsiteInfo[] {
+// // 移除YAML头部
+// const contentWithoutYaml = markdown.replace(/---[\s\S]?---/, '');
+// console.log("contentWithoutYaml",contentWithoutYaml)
+// // 定义正则表达式来匹配所需信息
+// const regex = /> 网站名称:(.?)\n> 网站介绍:(.?)\n> 网站地址:(.?)\n> 网站头图:(.*?)(?=\n|$)/g;
+
+// // 存储所有匹配的信息
+// const websitesInfo: WebsiteInfo[] = [];
+// let match;
+
+// // 使用循环来找到所有匹配项
+// while ((match = regex.exec(contentWithoutYaml))) {
+// const [_, name, description, url, imageUrl] = match;
+// websitesInfo.push({
+// name: name.trim(),
+// description: description.trim(),
+// url: url.trim(),
+// imageUrl: imageUrl.trim(),
+// });
+// }
+
+// // 返回提取的网站信息
+// return websitesInfo;
+// }
+
+interface WebsiteInfo {
+ name: string;
+ description: string;
+ url: string;
+ imageUrl: string;
+}
+
+function extractInfoFromMarkdownTable(markdownTable: string): WebsiteInfo[] {
+ // 分割字符串为行
+ const lines = markdownTable.split("\n").filter((line) => line.trim() !== "");
+
+ // 假设第一行是标题,从第三行开始是数据(第二行是分隔符)
+ const dataLines = lines.slice(2);
+
+ // 提取信息
+ const websites: WebsiteInfo[] = dataLines.map((line) => {
+ // 移除行首尾的 "|" 字符,然后按 "|" 分割每列
+ const columns = line
+ .slice(1, -1)
+ .split("|")
+ .map((col) => col.trim());
+
+ // 根据列的位置提取数据
+ return {
+ name: columns[1],
+ description: columns[2],
+ url: columns[3],
+ imageUrl: columns[4],
+ };
+ });
+
+ return websites;
+}
+
+// 示例使用
+const markdownTable = `
+网站名称 网站介绍 网站地址 网站头图
+OfferNow 让每个人了解计算机、编程、AI1111fasfasfafafsafasfafasfsfasfafsafaafas https://www.offernow.cn https://offernow.cn/img1.png
+OfferNow2 让每个人了解计算机、编程、AI2 https://www.offernow.cn2 https://offernow.cn/img2.png
+`;
+const websitesInfo = extractInfoFromMarkdownTable(markdownTable);
+console.log(websitesInfo);
+// 将提取的信息保存为JSON文件
+const saveInfoAsJson = (data: object[], filePath: string) => {
+ const jsonData = JSON.stringify(data, null, 2); // 格式化JSON字符串,使其更易于阅读
+
+ fs.writeFile(filePath, jsonData, "utf8", (err: any) => {
+ if (err) {
+ console.error("An error occurred while writing JSON Object to File.");
+ return console.error(err);
+ }
+ console.log("JSON file has been saved.");
+ });
+};
+
+// 调用函数,保存信息到websitesInfo.json文件
+saveInfoAsJson(websitesInfo, "./public/websitesInfo.json");