-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
36 lines (32 loc) · 1020 Bytes
/
Copy pathindex.ts
File metadata and controls
36 lines (32 loc) · 1020 Bytes
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
import { ExtractLinkNode, makeIndexLinkNode } from '@eslibr/lib'
import zbOnlineMapping from './caas-cn-zaobao-online'
import { logger } from '@eslibr/logger'
import postBlogMapping from './blog-post'
const indexMappingList = [zbOnlineMapping, postBlogMapping]
function generateIndexLinkNodeMapping(): Record<
string,
Array<ExtractLinkNode>
> {
return Object.fromEntries(
indexMappingList.map((mapping) => [
mapping.index.toString(),
makeIndexLinkNode(mapping.properties),
]),
)
}
function getIndexLinkNode(): (
index: string,
) => Array<ExtractLinkNode> | undefined {
let result: Record<string, Array<ExtractLinkNode>>
return function (_index: string) {
if (!result) {
result = generateIndexLinkNodeMapping()
}
const node = result[_index]
if (node === undefined) {
logger.warn(`Can't find index node: ${_index}`)
}
return node
}
}
export { getIndexLinkNode, generateIndexLinkNodeMapping, indexMappingList }