diff options
-rw-r--r-- | assets/css/main.css | 12 | ||||
-rw-r--r-- | assets/css/utils.css | 1 | ||||
-rw-r--r-- | layouts/_default/_markup/render-heading.html | 2 | ||||
-rw-r--r-- | layouts/partials/breadcrumbs.html | 4 | ||||
-rw-r--r-- | wiki/contributors.md | 81 |
5 files changed, 94 insertions, 6 deletions
diff --git a/assets/css/main.css b/assets/css/main.css index 6e57bcf..54c98cb 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -38,7 +38,7 @@ h6 { } .heading { - a { + .anchor { text-decoration: none; font-weight: normal; color: var(--content-secondary); @@ -47,7 +47,7 @@ h6 { font-family: var(--font-mono); } - &:hover a { + &:hover .anchor { visibility: visible; } } @@ -512,8 +512,14 @@ figcaption { /* breadcrumbs */ .breadcrumbs { - font-size: .8em; + font-size: small; margin-bottom: calc(-0.5 * var(--h1-margin-top)); + font-family: var(--font-mono); +} + +.breadcrumbs span { + margin-right: -5px; + margin-left: -5px; } /* Comments */ diff --git a/assets/css/utils.css b/assets/css/utils.css index 1c32ab7..f53c655 100644 --- a/assets/css/utils.css +++ b/assets/css/utils.css @@ -1,5 +1,6 @@ .flex { display: flex; + flex-wrap: wrap; } .bold { diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html index 44430d6..2699634 100644 --- a/layouts/_default/_markup/render-heading.html +++ b/layouts/_default/_markup/render-heading.html @@ -1,4 +1,4 @@ <h{{ .Level }} class="heading" id="{{ .Anchor }}"> {{ .Text }} - <a href="#{{ .Anchor }}">#</a> + <a class="anchor" href="#{{ .Anchor }}">#</a> </h{{ .Level }}> diff --git a/layouts/partials/breadcrumbs.html b/layouts/partials/breadcrumbs.html index 30a4df1..5c4fb62 100644 --- a/layouts/partials/breadcrumbs.html +++ b/layouts/partials/breadcrumbs.html @@ -2,8 +2,8 @@ <div class="breadcrumbs"> {{ range .Ancestors.Reverse }} <a href="{{ .RelPermalink }}">{{ .Title }}</a> - <span class="breadcrumbs-separator"> > </span> + <span class="breadcrumbs-separator"> / </span> {{ end }} - <a class="breadcrumbs-current" href="{{ .RelPermalink }}">{{ .Title }}</a> + <a href="{{ .RelPermalink }}">{{ .Title }}</a> </div> {{ end }}
\ No newline at end of file diff --git a/wiki/contributors.md b/wiki/contributors.md new file mode 100644 index 0000000..3443c07 --- /dev/null +++ b/wiki/contributors.md @@ -0,0 +1,81 @@ +--- +title: "Contributors" +date: "2025-01-01" +summary: "List of Typo's contributors" +description: "List of Typo's contributors" +toc: false +readTime: false +autonumber: false +math: false +showTags: false +hidePagination: true +hideBackToTop: false +--- + +The theme has accumulated <span id="star-count">over 300</span> stars on Github, and +currently counts <span id="contributors-count">over 20</span> contributors: + +<ul id="contributors-list" style="list-style-type: none; padding: 0; margin-top: 2rem"></ul> + +<script> + async function fetchGitHubData() { + const cacheKey = "githubData"; + const cacheExpiryKey = "githubDataExpiry"; + const cacheExpiryTime = 3600 * 1000; // 1 hour in milliseconds + + // Check if cached data exists and is still valid + const cachedData = localStorage.getItem(cacheKey); + const cachedExpiry = localStorage.getItem(cacheExpiryKey); + const now = new Date().getTime(); + + if (cachedData && cachedExpiry && now < cachedExpiry) { + const { starCount, contributors } = JSON.parse(cachedData); + updateUI(starCount, contributors); + return; + } + + try { + // Fetch star count + const repoResponse = await fetch("https://api.github.com/repos/tomfran/typo"); + const repoData = await repoResponse.json(); + const starCount = repoData.stargazers_count; + + // Fetch contributors + const contributorsResponse = await fetch("https://api.github.com/repos/tomfran/typo/contributors"); + const contributors = await contributorsResponse.json(); + + // Cache data + localStorage.setItem(cacheKey, JSON.stringify({ starCount, contributors })); + localStorage.setItem(cacheExpiryKey, now + cacheExpiryTime); + + updateUI(starCount, contributors); + + } catch (error) { + console.error("Error fetching GitHub data:", error); + document.getElementById("star-count").textContent = "Failed to fetch star count."; + document.getElementById("contributors-count").textContent = "Failed to fetch contributors count."; + } + } + + function updateUI(starCount, contributors) { + document.getElementById("star-count").textContent = `${starCount}`; + document.getElementById("contributors-count").textContent = `${contributors.length}`; + + const contributorsList = document.getElementById("contributors-list"); + contributorsList.innerHTML = ""; + + contributors.forEach(contributor => { + const listItem = document.createElement("li"); + listItem.style.marginBottom = ".5rem"; + listItem.innerHTML = ` + <span style="display: flex; align-items: bottom;"> + <img src="${contributor.avatar_url}" alt="${contributor.login}" width="30" height="30" style="margin-right: 10px; border-radius: 50%;"> + <a href="${contributor.html_url}">${contributor.login}</a> - ${contributor.contributions} + </span> + `; + contributorsList.appendChild(listItem); + }); + } + + fetchGitHubData(); +</script> |