-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
91 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
import type { FullBangumi } from 'bgmd/dist/types'; | ||
import { calendar as rawCalendar } from 'bgmd/calendar'; | ||
import { stringifySearchURL } from 'animegarden'; | ||
import { APP_HOST } from '~build/meta'; | ||
const first = (new Date().getDay() + 6) % 7; | ||
const calendar = rawCalendar.map((_, idx) => { | ||
const index = (idx + first) % 7; | ||
return { | ||
index: index + 1, | ||
text: ['一', '二', '三', '四', '五', '六', '日'][index], | ||
bangumis: rawCalendar[index] | ||
}; | ||
}); | ||
function getPosterImage(bgm: FullBangumi) { | ||
if (bgm.tmdb?.poster_path) { | ||
return `https://www.themoviedb.org/t/p/w300_and_h450_bestv2${bgm.tmdb.poster_path}`; | ||
} else if (bgm.bangumi?.images) { | ||
return bgm.bangumi.images.large; | ||
} | ||
} | ||
function getDisplayName(bgm: FullBangumi) { | ||
if (bgm.bangumi) { | ||
return bgm.bangumi.name_cn || bgm.name; | ||
} | ||
return bgm.name; | ||
} | ||
function getSearchURL(bgm: FullBangumi) { | ||
const url = stringifySearchURL('https://' + APP_HOST, { | ||
include: [[bgm.name, ...bgm.alias]], | ||
after: new Date(new Date(bgm.air_date).getTime() - 7 * 24 * 60 * 60 * 1000) | ||
}); | ||
return `${url.pathname}${url.search}`; | ||
} | ||
--- | ||
|
||
<div class="space-y-4 w-full mb-8"> | ||
{ | ||
calendar.map((cal) => ( | ||
<div class="w-full pt-4 bg-gray-100 rounded-md" id={`星期${cal.text}`}> | ||
<a | ||
class="block px-6 text-xl font-bold mb-4 select-none border-l-[4px] border-[#0ca]" | ||
href={`#星期${cal.text}`} | ||
> | ||
星期{cal.text} | ||
</a> | ||
<div class="px-6 pb-2 flex w-full space-x-6 overflow-x-auto"> | ||
{cal.bangumis.map((bgm) => ( | ||
<a href={getSearchURL(bgm)} class="block w-max"> | ||
<div class="w-150px h-225px flex items-center select-none"> | ||
<img | ||
src={getPosterImage(bgm)} | ||
alt="" | ||
class="rounded-md max-h-225px hover:(shadow-box)" | ||
/> | ||
</div> | ||
<div class="w-150px truncate py-2"> | ||
<span class="font-bold text-sm text-link-active">{getDisplayName(bgm)}</span> | ||
</div> | ||
</a> | ||
))} | ||
</div> | ||
</div> | ||
)) | ||
} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
import Layout from '../layouts/Layout.astro'; | ||
import AnimePanel from '../components/Anime.astro'; | ||
--- | ||
|
||
<Layout title="Anime Garden"> | ||
<div class="mt-4vh w-full"> | ||
<AnimePanel /> | ||
</div> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters