All files / src/pages 404.astro

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                                                                               
---
import Layout from '../layouts/Layout.astro';
import Card from '../components/Card/index.tsx';
import { getCollection } from 'astro:content';
 
const allPosts = await getCollection('blog');
const latestPosts = allPosts
  .sort((a, b) => new Date(b.data.date).getTime() - new Date(a.data.date).getTime())
  .slice(0, 5);
---
 
<Layout
  title="404 Not Found"
  description="ページが見つかりませんでした"
  noindex={true}
>
  <div class="container">
    <div class="row">
      <div class="col" style="padding:4rem 2rem; text-align:center;">
        <h1>404 Not Found...</h1>
        <p><a href="/">ホームに戻る</a></p>
      </div>
    </div>
    <div class="row">
      <div class="col-12">
        <h3 style="margin-bottom:1.5rem;">最近の記事</h3>
      </div>
      {latestPosts.map((post, index) => {
        const url = post.slug;
        return (
          <div class="col-sm-12 pb-4">
            <Card
              client:load
              title={post.data.title}
              date={post.data.date.toISOString()}
              url={`/${url}/`}
              headerImage={post.data.headerImage}
              description={post.data.description}
              tags={post.data.tags || []}
              index={index}
            />
          </div>
        );
      })}
    </div>
  </div>
</Layout>