/
githubmirror
/
hugo
Обзор
Документация
Войти
/
githubmirror
/
hugo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/layouts/_partials/helpers/funcs/get-github-info.html
28 строк
917 B
Bjørn Erik Pedersen
Merge commit 'c23d97904fd31ef745bece57133aa1b9275ec20c'
21 май 2026, 13:22
21 май 2026, 13:22
5f01b06
Код
Авторство
О чём код?
{{ $url := "https://api.github.com/repos/gohugoio/hugo" }} {{ $cacheKey := print $url (now.Format "2006-01-02") }} {{ $headers := dict }} {{ with os.Getenv "HUGO_GH_TOKEN" }} {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} {{ end }} {{ $opts := dict "headers" $headers "key" $cacheKey }} {{ $githubRepoInfo := dict }} {{ with try (resources.GetRemote $url $opts) }} {{ with .Err }} {{ warnf "Failed to get GitHub repo info: %s" . }} {{ else with (.Value | transform.Unmarshal) }} {{ $githubRepoInfo = dict "html_url" .html_url "stargazers_url" .stargazers_url "watchers_count" .watchers_count "stargazers_count" .stargazers_count "forks_count" .forks_count "contributors_url" .contributors_url "releases_url" .releases_url "forks_count" .forks_count }} {{ else }} {{ errorf "Unable to get remote resource %q" $url }} {{ end }} {{ end }} {{ return $githubRepoInfo }}