kremalicious/blog

View on GitHub
src/layouts/Post/Meta.astro

Summary

Maintainability
Test Coverage
---
import type { CollectionEntry } from 'astro:content'
import Tag from '@/components/Tag.astro'
import { slugify } from '@/lib/slugify'
import config from '@config/blog.config'
import DateComponent from './Date.astro'
import styles from './Meta.module.css'

type Props = {
  post: CollectionEntry<'articles' | 'links' | 'photos'>
}

const { collection, data } = Astro.props.post
const { date, updated, author, tags } = data
---

<footer class={styles.entryMeta}>
  <div class={styles.byline}>
    <span class={styles.by}>by</span>
    <a class="fn" rel="author" href={config.author.url}>
      {author || config.author.name}
    </a>
  </div>

  <DateComponent date={date} updated={updated} />

  {
    collection === 'photos' && (
      <div class={styles.type}>
        <a href={`/${slugify(collection)}/`}>{collection}</a>
      </div>
    )
  }

  {
    tags && (
      <div class={styles.tags}>
        {tags.map((tag: string) => (
          <Tag name={slugify(tag)} url={`/tags/${slugify(tag)}/`} />
        ))}
      </div>
    )
  }
</footer>