mirror of
https://github.com/huqi-pr/trending-in-one.git
synced 2024-11-17 13:58:28 +08:00
🎨
This commit is contained in:
parent
225f9af73f
commit
554db3f3d7
12
mod.ts
12
mod.ts
@ -5,11 +5,11 @@ import { weiboSearch } from "./weibo-search.ts";
|
||||
import { toutiaoSearch } from "./toutiao-search.ts";
|
||||
|
||||
export async function init() {
|
||||
await zhihuVideo();
|
||||
await zhihuQuestions();
|
||||
await zhihuSearch();
|
||||
await weiboSearch();
|
||||
await toutiaoSearch();
|
||||
await zhihuVideo();
|
||||
await zhihuQuestions();
|
||||
await zhihuSearch();
|
||||
await weiboSearch();
|
||||
await toutiaoSearch();
|
||||
}
|
||||
|
||||
init()
|
||||
init();
|
||||
|
@ -155,7 +155,10 @@ Deno.test("createArchive4Question", function (): void {
|
||||
{ title: "hello", url: "world" },
|
||||
];
|
||||
|
||||
assertStringIncludes(createArchive4Question(words, "2020-02-02"), "# 2020-02-02");
|
||||
assertStringIncludes(
|
||||
createArchive4Question(words, "2020-02-02"),
|
||||
"# 2020-02-02",
|
||||
);
|
||||
assertStringIncludes(createArchive4Question(words, "2020-02-02"), "共 2 条");
|
||||
});
|
||||
|
||||
@ -178,7 +181,10 @@ Deno.test("createArchive4Video", function (): void {
|
||||
{ title: "hello", url: "world" },
|
||||
];
|
||||
|
||||
assertStringIncludes(createArchive4Video(words, "2020-02-02"), "# 2020-02-02");
|
||||
assertStringIncludes(
|
||||
createArchive4Video(words, "2020-02-02"),
|
||||
"# 2020-02-02",
|
||||
);
|
||||
assertStringIncludes(createArchive4Video(words, "2020-02-02"), "共 2 条");
|
||||
});
|
||||
|
||||
|
15
utils.ts
15
utils.ts
@ -68,12 +68,14 @@ export async function createReadme4Video(words: Question[]): Promise<string> {
|
||||
);
|
||||
}
|
||||
|
||||
export async function createReadme4Question(words: Question[]): Promise<string> {
|
||||
export async function createReadme4Question(
|
||||
words: Question[],
|
||||
): Promise<string> {
|
||||
const readme = await Deno.readTextFile("./README.md");
|
||||
return readme.replace(
|
||||
/<!-- BEGIN ZHIHUQUESTIONS -->[\W\w]*<!-- END ZHIHUQUESTIONS -->/,
|
||||
createQuestionList(words),
|
||||
);
|
||||
/<!-- BEGIN ZHIHUQUESTIONS -->[\W\w]*<!-- END ZHIHUQUESTIONS -->/,
|
||||
createQuestionList(words),
|
||||
);
|
||||
}
|
||||
|
||||
export async function createReadme4Search(
|
||||
@ -155,7 +157,10 @@ ${
|
||||
<!-- END TOUTIAO -->`;
|
||||
}
|
||||
|
||||
export function createArchive4Question(words: Question[], date: string): string {
|
||||
export function createArchive4Question(
|
||||
words: Question[],
|
||||
date: string,
|
||||
): string {
|
||||
return `# ${date}\n
|
||||
共 ${words.length} 条\n
|
||||
${createQuestionList(words)}
|
||||
|
@ -6,7 +6,11 @@ import { exists } from "std/fs/mod.ts";
|
||||
// import { config } from 'dotenv/mod.ts'
|
||||
|
||||
import type { ZhihuQuestionList, Question } from "./types.ts";
|
||||
import { createArchive4Question, createReadme4Question, mergeQuestions } from "./utils.ts";
|
||||
import {
|
||||
createArchive4Question,
|
||||
createReadme4Question,
|
||||
mergeQuestions,
|
||||
} from "./utils.ts";
|
||||
|
||||
const response = await fetch(
|
||||
"https://www.zhihu.com/api/v3/feed/topstory/hot-lists/total?limit=100",
|
||||
|
@ -5,7 +5,11 @@ import { join } from "std/path/mod.ts";
|
||||
import { exists } from "std/fs/mod.ts";
|
||||
|
||||
import type { ZhihuVideoList, Question } from "./types.ts";
|
||||
import { createArchive4Video, createReadme4Video, mergeQuestions } from "./utils.ts";
|
||||
import {
|
||||
createArchive4Video,
|
||||
createReadme4Video,
|
||||
mergeQuestions,
|
||||
} from "./utils.ts";
|
||||
|
||||
const response = await fetch(
|
||||
"https://www.zhihu.com/api/v3/feed/topstory/hot-lists/zvideo?limit=100",
|
||||
|
Loading…
Reference in New Issue
Block a user