forked from ClickHouse/clickhouse-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.js
33 lines (30 loc) · 1000 Bytes
/
header.js
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
// A JavaScript function that returns an object.
// `context` is provided by Docusaurus. Example: siteConfig can be accessed from context.
// `opts` is the user-defined options.
const menuItems = require('./menuItems.json')
const fetch = require('node-fetch');
async function chHeader(context, opts) {
return {
name: 'ch-header-plugin',
async loadContent() {
// The loadContent hook is executed after siteConfig and env has been loaded.
// You can return a JavaScript object that will be passed to contentLoaded hook.
const githubData = await fetch(
'https://api.github.com/repos/ClickHouse/ClickHouse'
)
const data = await githubData.json()
const stars = data?.stargazers_count ?? 28203
return {
github: {
stars
},
menuItems
}
},
async contentLoaded({content, actions}) {
const {setGlobalData} = actions;
setGlobalData(content)
},
};
}
module.exports = chHeader;