From 540bd938f2ef6fe683c79b511ecf74333b9992e6 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 17 Feb 2023 21:48:34 +0100 Subject: [PATCH] remove unused Footer + fix AvatarList (still unused) --- .../src/components/Footer/AvatarList.astro | 244 +++++++++--------- website/src/components/Footer/Footer.astro | 19 -- .../RightSidebar/RightSidebar.astro | 2 + website/src/layouts/MainLayout.astro | 2 - 4 files changed, 123 insertions(+), 144 deletions(-) delete mode 100644 website/src/components/Footer/Footer.astro diff --git a/website/src/components/Footer/AvatarList.astro b/website/src/components/Footer/AvatarList.astro index b75589f5..86bbcc87 100644 --- a/website/src/components/Footer/AvatarList.astro +++ b/website/src/components/Footer/AvatarList.astro @@ -1,66 +1,64 @@ --- // fetch all commits for just this page's path type Props = { - path: string; + path: string; }; const { path } = Astro.props as Props; -const resolvedPath = `examples/docs/${path}`; -const url = `https://api.github.com/repos/withastro/astro/commits?path=${resolvedPath}`; -const commitsURL = `https://github.com/withastro/astro/commits/main/${resolvedPath}`; +const resolvedPath = `website/src/pages${path}.mdx`; +const url = `https://api.github.com/repos/tidalcycles/strudel/commits?path=${resolvedPath}`; +const commitsURL = `https://github.com/tidalcycles/strudel/commits/main/${resolvedPath}`; type Commit = { - author: { - id: string; - login: string; - }; + author: { + id: string; + login: string; + }; }; async function getCommits(url: string) { - try { - const token = import.meta.env.SNOWPACK_PUBLIC_GITHUB_TOKEN ?? 'hello'; - if (!token) { - throw new Error( - 'Cannot find "SNOWPACK_PUBLIC_GITHUB_TOKEN" used for escaping rate-limiting.' - ); - } + try { + const token = import.meta.env.SNOWPACK_PUBLIC_GITHUB_TOKEN ?? 'hello'; + if (!token) { + throw new Error('Cannot find "SNOWPACK_PUBLIC_GITHUB_TOKEN" used for escaping rate-limiting.'); + } - const auth = `Basic ${Buffer.from(token, 'binary').toString('base64')}`; + const auth = `Basic ${Buffer.from(token, 'binary').toString('base64')}`; - const res = await fetch(url, { - method: 'GET', - headers: { - Authorization: auth, - 'User-Agent': 'astro-docs/1.0', - }, - }); + const res = await fetch(url, { + method: 'GET', + headers: { + Authorization: auth, + 'User-Agent': 'astro-docs/1.0', + }, + }); - const data = await res.json(); + const data = await res.json(); - if (!res.ok) { - throw new Error( - `Request to fetch commits failed. Reason: ${res.statusText} - Message: ${data.message}` - ); - } + if (!res.ok) { + throw new Error( + `Request to fetch commits failed. Reason: ${res.statusText} + Message: ${data.message}`, + ); + } - return data as Commit[]; - } catch (e) { - console.warn(`[error] /src/components/AvatarList.astro + return data as Commit[]; + } catch (e) { + console.warn(`[error] /src/components/AvatarList.astro ${(e as any)?.message ?? e}`); - return [] as Commit[]; - } + return [] as Commit[]; + } } function removeDups(arr: Commit[]) { - const map = new Map(); + const map = new Map(); + for (let item of arr) { + const author = item.author; + // Deduplicate based on author.id + //map.set(author.id, { login: author.login, id: author.id }); + author && map.set(author.id, { login: author.login, id: author.id }); + } - for (let item of arr) { - const author = item.author; - // Deduplicate based on author.id - map.set(author.id, { login: author.login, id: author.id }); - } - - return [...map.values()]; + return [...map.values()]; } const data = await getCommits(url); @@ -70,102 +68,102 @@ const additionalContributors = unique.length - recentContributors.length; // lis --- -
-
    - { - recentContributors.map((item) => ( -
  • - - {`Contributor - -
  • - )) - } -
- { - additionalContributors > 0 && ( - - {`and ${additionalContributors} additional contributor${ - additionalContributors > 1 ? 's' : '' - }.`} - - ) - } - {unique.length === 0 && Contributors} +
+
    + { + recentContributors.map((item) => ( +
  • + + {`Contributor + +
  • + )) + } +
+ { + additionalContributors > 0 && ( + + {`and ${additionalContributors} additional contributor${ + additionalContributors > 1 ? 's' : '' + }.`} + + ) + } + {unique.length === 0 && Contributors}
diff --git a/website/src/components/Footer/Footer.astro b/website/src/components/Footer/Footer.astro deleted file mode 100644 index 1ec756b8..00000000 --- a/website/src/components/Footer/Footer.astro +++ /dev/null @@ -1,19 +0,0 @@ ---- -import AvatarList from './AvatarList.astro'; -type Props = { - path: string; -}; -const { path } = Astro.props as Props; ---- - -
- -
- - diff --git a/website/src/components/RightSidebar/RightSidebar.astro b/website/src/components/RightSidebar/RightSidebar.astro index e6031e4d..ba193d24 100644 --- a/website/src/components/RightSidebar/RightSidebar.astro +++ b/website/src/components/RightSidebar/RightSidebar.astro @@ -2,6 +2,7 @@ import TableOfContents from './TableOfContents'; import MoreMenu from './MoreMenu.astro'; import type { MarkdownHeading } from 'astro'; +import AvatarList from '../Footer/AvatarList.astro'; type Props = { headings: MarkdownHeading[]; @@ -17,4 +18,5 @@ currentPage = currentPage.endsWith('/') ? currentPage.slice(0, -1) : currentPage diff --git a/website/src/layouts/MainLayout.astro b/website/src/layouts/MainLayout.astro index f4cf091a..ac268cab 100644 --- a/website/src/layouts/MainLayout.astro +++ b/website/src/layouts/MainLayout.astro @@ -7,7 +7,6 @@ import LeftSidebar from '../components/LeftSidebar/LeftSidebar.astro'; import RightSidebar from '../components/RightSidebar/RightSidebar.astro'; import * as CONFIG from '../config'; import type { MarkdownHeading } from 'astro'; -import Footer from '../components/Footer/Footer.astro'; import '../docs/docs.css'; type Props = { @@ -49,7 +48,6 @@ const githubEditUrl = `${CONFIG.GITHUB_EDIT_URL}/${currentFile}`;
-