Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

レイアウトの修正 #295

Merged
merged 3 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/components/SeasonList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ export type Section = {
season: Season;
};

export function getSectionArray() {
export function getSectionArray(showUnpublishedSeason: boolean) {
let articles = content.articles;
if (!showUnpublishedSeason) {
articles = articles.filter(
(article) => dayjs(article.date) <= dayjs() && article.url !== null,
);
}

const oldestSection: Section = { fiscalYear: 2023, season: 0 };

const newestSection = dateToSection(
content.articles
articles
.map((article) => dayjs(article.date))
.reduce((max, date) => (date.isAfter(max) ? date : max)),
);
Expand Down Expand Up @@ -95,10 +102,14 @@ export function sectionToSlug(section: Section): string {
return `${section.fiscalYear}${seasonName}`;
}

type Props = { selected?: Section; linkDest: string };
type Props = {
selected?: Section;
linkDest: string;
showUnpublishedSeason?: boolean;
};

const { selected, linkDest } = Astro.props;
const sections = getSectionArray();
const { selected, linkDest, showUnpublishedSeason } = Astro.props;
const sections = getSectionArray(showUnpublishedSeason ?? true);
---

<div class="grid grid-cols-4 gap-4 my-6">
Expand Down
4 changes: 2 additions & 2 deletions src/pages/archives/[section].astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SeasonList, {
import Base from "../../layouts/Base.astro";

export function getStaticPaths() {
return getSectionArray().map((section) => ({
return getSectionArray(true).map((section) => ({
params: {
section: sectionToSlug(section),
},
Expand Down Expand Up @@ -48,7 +48,7 @@ const articles = content.articles

<Base
title={`Vim 駅伝 - アーカイブ - ${displaySectionName(section)}`}
slug={`/archives/${sectionToSlug(section)}`}
slug={`/archives/`}
>
<SeasonList selected={section} linkDest="archives" />
{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ranking.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const articles = content.articles
---

<Base title="Vim 駅伝 - ランキング" slug="/ranking/">
<SeasonList linkDest="ranking" />
<SeasonList linkDest="ranking" showUnpublishedSeason={false} />

<section class="py-4">
<h2>記事投稿数ランキング(総合)</h2>
Expand Down
10 changes: 7 additions & 3 deletions src/pages/ranking/[section].astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Base from "../../layouts/Base.astro";
import RankChart from "../../components/RankChart.svelte";

export function getStaticPaths() {
return getSectionArray().map((section) => ({
return getSectionArray(false).map((section) => ({
params: {
section: sectionToSlug(section),
},
Expand Down Expand Up @@ -50,9 +50,13 @@ const articles = content.articles

<Base
title={`Vim 駅伝 - ランキング - ${displaySectionName(section)}`}
slug={`/ranking/${sectionToSlug(section)}`}
slug={`/ranking/`}
>
<SeasonList selected={section} linkDest="ranking" />
<SeasonList
selected={section}
linkDest="ranking"
showUnpublishedSeason={false}
/>
<section class="py-4">
<h2>記事投稿数ランキング({displaySectionName(section)})</h2>
<RankChart articles={articles} client:only="svelte" />
Expand Down
4 changes: 2 additions & 2 deletions src/pages/runners/[runner].astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const runnersArticles = newArticles
.filter((article) => article.githubUser === runner)
.sort((a, b) => dayjs(a.date).unix() - dayjs(b.date).unix())
.map((article, index) => ({
index: index + 1,
index: index,
published: dayjs(article.date) <= dayjs() && article.url !== null,
shortDate: dayjs(article.date).format("M/D"),
year: dayjs(article.date).format("YYYY"),
Expand All @@ -36,7 +36,7 @@ const runnersArticles = newArticles
<>
<h2
class={
article.index === 1 ||
article.index === 0 ||
article.year !== runnersArticles[article.index - 1].year
? "text-2xl font-bold mt-8 mb-4"
: "hidden"
Expand Down