mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 07:37:10 +00:00
Add "new" badge and store seen state
This commit is contained in:
16
src/app/components/whatsnew/WhatsNewEntry.tsx
Normal file
16
src/app/components/whatsnew/WhatsNewEntry.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { marked } from 'marked'
|
||||
import type { WhatsNewItem } from '../../services/DataFetcher.js'
|
||||
import { WhatsNewTime } from './WhatsNewTime.jsx'
|
||||
|
||||
interface EntryProps {
|
||||
item: WhatsNewItem,
|
||||
}
|
||||
export function WhatsNewEntry({ item }: EntryProps) {
|
||||
return <article class="whats-new-entry">
|
||||
<a href={item.url} target="_blank">
|
||||
<WhatsNewTime item={item} />
|
||||
<h2>{item.title}</h2>
|
||||
</a>
|
||||
<div class="guide-content" dangerouslySetInnerHTML={{ __html: marked(item.body) }} />
|
||||
</article>
|
||||
}
|
||||
14
src/app/components/whatsnew/WhatsNewTime.tsx
Normal file
14
src/app/components/whatsnew/WhatsNewTime.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useLocale } from '../../contexts/Locale.jsx'
|
||||
import type { WhatsNewItem } from '../../services/DataFetcher.js'
|
||||
|
||||
interface Props {
|
||||
item: WhatsNewItem,
|
||||
short?: boolean,
|
||||
}
|
||||
export function WhatsNewTime({ item, short }: Props) {
|
||||
const { locale } = useLocale()
|
||||
return <time dateTime={item.createdAt} title={Intl.DateTimeFormat(undefined, { dateStyle: 'full', timeStyle: 'long' }).format(new Date(item.createdAt))}>
|
||||
{(!short || item.seenAt !== undefined) && Intl.DateTimeFormat(undefined, { day: 'numeric',month: 'long', year: 'numeric' }).format(new Date(item.createdAt))}
|
||||
{item.seenAt === undefined && <span class="new-badge">{locale('whats_new.new')}</span>}
|
||||
</time>
|
||||
}
|
||||
2
src/app/components/whatsnew/index.ts
Normal file
2
src/app/components/whatsnew/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './WhatsNewEntry.jsx'
|
||||
export * from './WhatsNewTime.jsx'
|
||||
Reference in New Issue
Block a user