MCPcopy Index your code
hub / github.com/adobe/react-spectrum / PostList

Function PostList

packages/dev/s2-docs/src/PostList.tsx:7–72  ·  view source on GitHub ↗
({currentPage, pages}: {currentPage: Page; pages: Page[]})

Source from the content-addressed store, hash-verified

5import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
6
7export function PostList({currentPage, pages}: {currentPage: Page; pages: Page[]}) {
8 let posts = pages.sort((a, b) => {
9 return new Date(b.exports?.date).getTime() - new Date(a.exports?.date).getTime();
10 });
11 let feedUrl = currentPage.url.replace(/\/(index.html)?$/, '.xml');
12
13 return (
14 <>
15 {/* React hoists this into the <head> */}
16 <link
17 rel="alternate"
18 type="application/atom+xml"
19 title={`${getLibraryLabel(getLibraryFromPage(currentPage))} ${currentPage.tableOfContents?.[0].title}`}
20 href={feedUrl}
21 />
22 <div className={style({marginTop: 8})}>
23 <Link isStandalone isQuiet href={feedUrl} target="_blank">
24 <span className={style({display: 'inline-flex', alignItems: 'center', columnGap: 4})}>
25 <RSSIcon />
26 Subscribe
27 </span>
28 </Link>
29 </div>
30 <div
31 itemScope
32 itemType="https://schema.org/Blog"
33 className={style({marginY: 48, display: 'flex', flexDirection: 'column', gap: 40})}>
34 <div itemProp="publisher" itemScope itemType="https://schema.org/Organization" hidden>
35 <meta itemProp="name" content="Adobe" />
36 <meta itemProp="url" content="https://www.adobe.com" />
37 <meta itemProp="logo" content="https://www.adobe.com/favicon.ico" />
38 </div>
39 {posts.map(post => (
40 <article
41 key={post.name}
42 itemProp="blogPost"
43 itemScope
44 itemType="https://schema.org/BlogPosting">
45 <header className={style({marginBottom: 12})}>
46 <h2 itemProp="headline" className={style({font: 'title-xl', margin: 0})}>
47 <Link href={post.url}>
48 {post.tableOfContents?.[0]?.title || post.exports?.title}
49 </Link>
50 </h2>
51 {post.exports?.author && (
52 <Byline
53 author={post.exports?.author}
54 authorLink={post.exports?.authorLink}
55 date={post.exports?.date}
56 />
57 )}
58 {post.exports?.date && !post.exports.author && <Time date={post.exports.date} />}
59 </header>
60 <meta itemProp="url" content={post.url} />
61 <p itemProp="description" className={style({font: 'body', margin: 0})}>
62 {renderHTMLfromMarkdown(post.exports?.description, {
63 forceInline: true,
64 forceBlock: false

Callers

nothing calls this directly

Calls 4

getLibraryLabelFunction · 0.90
getLibraryFromPageFunction · 0.90
renderHTMLfromMarkdownFunction · 0.90
sortMethod · 0.65

Tested by

no test coverage detected