-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathrsshub.ts
More file actions
51 lines (47 loc) · 1.52 KB
/
Copy pathrsshub.ts
File metadata and controls
51 lines (47 loc) · 1.52 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
import type { DocItem, MiniSearchResult } from "../types";
function formatResult(searchResults: Array<MiniSearchResult>, home: string) {
return searchResults.map((item) => {
const title =
item.titles
.map((t) =>
t
.replace(/<Site.*\/>/, "")
.replace(/{(.*?)}/g, "")
.trim(),
)
.join(" > ") || item.title;
const url = `${home}${item.url.replace("src/", "").replace("zh/", "")}#${item.titles[item.titles.length - 1]
.replace(/.*{#(.*?)}/g, "$1")
.replace(/<Site.*\/>/, "")
.trim()
.replace(/\s+/g, "-")
.replace("-", "-")
.replace(/-+/g, "-")
.toLowerCase()}`;
return {
title,
url,
content: item.content,
id: item.id,
};
});
}
const rsshub: DocItem = {
"en-US": {
icon: "../assets/logo/rsshub.png",
type: "minisearch",
homepage: "https://docs.rsshub.app/en/",
dataUrl:
"https://raw.githubusercontent.com/Fatpandac/SearchSource/refs/heads/main/search-index/RSSHub/en-US/search-index.json",
formatter: (searchResults) => formatResult(searchResults, "https://docs.rsshub.app/"),
},
"zh-CN": {
icon: "../assets/logo/rsshub.png",
type: "minisearch",
homepage: "https://docs.rsshub.app/",
dataUrl:
"https://raw.githubusercontent.com/Fatpandac/SearchSource/refs/heads/main/search-index/RSSHub/zh-CN/search-index.json",
formatter: (searchResults) => formatResult(searchResults, "https://docs.rsshub.app/zh/"),
},
};
export default rsshub;