Skip to content

Commit

Permalink
Merge pull request #2931 from ClickHouse/gj-protect-stars
Browse files Browse the repository at this point in the history
Defining stars value up front and adding fallback
  • Loading branch information
gingerwizard authored Dec 19, 2024
2 parents f780bd9 + f0de626 commit 7b3210c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions plugins/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ async function chHeader(context, opts) {
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 ?? 36500
let stars = 38000;
try {
const githubData = await fetch(
'https://api.github.com/repos/ClickHouse/ClickHouse'
)
const data = await githubData.json()
stars = data?.stargazers_count ?? stars
} catch (error) {
console.warn('Failed to fetch GitHub stars:', error)
}
return {
github: {
stars
Expand Down

0 comments on commit 7b3210c

Please sign in to comment.