-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (36 loc) · 1.17 KB
/
index.js
File metadata and controls
52 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const core = require("@actions/core");
const { Toolkit } = require("actions-toolkit");
const cheerio = require("cheerio");
const axios = require("axios");
const MAX_LINES = core.getInput("MAX_LINES");
const baseUrl = "https://weiyun0912.github.io";
async function getBlogOutline() {
const { data } = await axios.get(
"https://weiyun0912.github.io/Wei-Docusaurus/docs/intro"
);
const $ = cheerio.load(data);
const outline = [];
const Logs = $("h1:contains('Logs')").next().children();
Logs.each((_, el) => {
const logDetail = {
title: "",
link: "",
};
const link = baseUrl + $(el).children().attr("href");
logDetail.title = $(el).text();
if (link.includes(" ")) {
logDetail.link = link.replace(" ", "%20");
} else {
logDetail.link = link;
}
outline.push(logDetail);
});
const outlineFilter = outline.slice(0, MAX_LINES);
console.log(outlineFilter);
return outlineFilter;
}
Toolkit.run(async (tools) => {
tools.log.success("Success");
await getBlogOutline();
tools.exit.success("Test Success");
});