dan
2 years ago
committed by
GitHub
11 changed files with 41 additions and 390 deletions
@ -1,26 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. |
|
||||
*/ |
|
||||
|
|
||||
import * as React from 'react'; |
|
||||
import sidebarReference from 'sidebarReference.json'; |
|
||||
import {MarkdownPage, MarkdownProps} from './MarkdownPage'; |
|
||||
import {Page} from './Page'; |
|
||||
import {RouteItem} from './useRouteMeta'; |
|
||||
|
|
||||
interface PageFrontmatter { |
|
||||
title: string; |
|
||||
status: string; |
|
||||
} |
|
||||
|
|
||||
export default function withAPI(p: PageFrontmatter) { |
|
||||
function LayoutAPI(props: MarkdownProps<PageFrontmatter>) { |
|
||||
return <MarkdownPage {...props} meta={p} />; |
|
||||
} |
|
||||
LayoutAPI.appShell = AppShell; |
|
||||
return LayoutAPI; |
|
||||
} |
|
||||
|
|
||||
function AppShell(props: {children: React.ReactNode}) { |
|
||||
return <Page routeTree={sidebarReference as RouteItem} {...props} />; |
|
||||
} |
|
@ -1,26 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. |
|
||||
*/ |
|
||||
|
|
||||
import * as React from 'react'; |
|
||||
import sidebarHome from 'sidebarHome.json'; |
|
||||
import {MarkdownPage, MarkdownProps} from './MarkdownPage'; |
|
||||
import {Page} from './Page'; |
|
||||
import {RouteItem} from './useRouteMeta'; |
|
||||
|
|
||||
interface PageFrontmatter { |
|
||||
title: string; |
|
||||
status: string; |
|
||||
} |
|
||||
|
|
||||
export default function withDocs(p: PageFrontmatter) { |
|
||||
function LayoutHome(props: MarkdownProps<PageFrontmatter>) { |
|
||||
return <MarkdownPage {...props} meta={p} />; |
|
||||
} |
|
||||
LayoutHome.appShell = AppShell; |
|
||||
return LayoutHome; |
|
||||
} |
|
||||
|
|
||||
function AppShell(props: {children: React.ReactNode}) { |
|
||||
return <Page routeTree={sidebarHome as RouteItem} {...props} />; |
|
||||
} |
|
@ -1,24 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. |
|
||||
*/ |
|
||||
|
|
||||
import * as React from 'react'; |
|
||||
import {MarkdownPage, MarkdownProps} from './MarkdownPage'; |
|
||||
import {RouteItem} from 'components/Layout/useRouteMeta'; |
|
||||
import {Page} from './Page'; |
|
||||
import sidebarLearn from '../../sidebarLearn.json'; |
|
||||
interface PageFrontmatter { |
|
||||
title: string; |
|
||||
} |
|
||||
|
|
||||
export default function withLearn(meta: PageFrontmatter) { |
|
||||
function LayoutLearn(props: MarkdownProps<PageFrontmatter>) { |
|
||||
return <MarkdownPage {...props} meta={meta} />; |
|
||||
} |
|
||||
LayoutLearn.appShell = AppShell; |
|
||||
return LayoutLearn; |
|
||||
} |
|
||||
|
|
||||
function AppShell(props: {children: React.ReactNode}) { |
|
||||
return <Page {...props} routeTree={sidebarLearn as RouteItem} />; |
|
||||
} |
|
@ -1,120 +0,0 @@ |
|||||
/* |
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. |
|
||||
*/ |
|
||||
|
|
||||
// @ts-ignore
|
|
||||
import {MDXContext} from '@mdx-js/react'; |
|
||||
import recentPostsRouteTree from 'blogIndexRecent.json'; |
|
||||
import {DocsPageFooter} from 'components/DocsFooter'; |
|
||||
import {ExternalLink} from 'components/ExternalLink'; |
|
||||
import {MDXComponents} from 'components/MDX/MDXComponents'; |
|
||||
import {Seo} from 'components/Seo'; |
|
||||
import {Toc} from 'components/Layout/Toc'; |
|
||||
import format from 'date-fns/format'; |
|
||||
import {useRouter} from 'next/router'; |
|
||||
import * as React from 'react'; |
|
||||
import {getAuthor} from 'utils/getAuthor'; |
|
||||
import toCommaSeparatedList from 'utils/toCommaSeparatedList'; |
|
||||
import {Page} from './Page'; |
|
||||
import {RouteItem, useRouteMeta} from './useRouteMeta'; |
|
||||
import {useTwitter} from './useTwitter'; |
|
||||
|
|
||||
interface PageFrontmatter { |
|
||||
id?: string; |
|
||||
title: string; |
|
||||
author: string[]; |
|
||||
date?: string; |
|
||||
} |
|
||||
|
|
||||
interface LayoutPostProps { |
|
||||
/** Sidebar/Nav */ |
|
||||
routes: RouteItem[]; |
|
||||
/** Markdown frontmatter */ |
|
||||
meta: PageFrontmatter; |
|
||||
/** The mdx */ |
|
||||
children: React.ReactNode; |
|
||||
} |
|
||||
|
|
||||
/** Return the date of the current post given the path */ |
|
||||
function getDateFromPath(path: string) { |
|
||||
// All paths are /blog/year/month/day/title
|
|
||||
const [year, month, day] = path |
|
||||
.substr(1) // first `/`
|
|
||||
.split('/') // make an array
|
|
||||
.slice(1) // ignore blog
|
|
||||
.map((i) => parseInt(i, 10)); // convert to numbers
|
|
||||
|
|
||||
return { |
|
||||
date: format(new Date(year, month, day), 'MMMM dd, yyyy'), |
|
||||
dateTime: [year, month, day].join('-'), |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
function LayoutPost({meta, children}: LayoutPostProps) { |
|
||||
const {pathname} = useRouter(); |
|
||||
const {date, dateTime} = getDateFromPath(pathname); |
|
||||
const {route, nextRoute, prevRoute} = useRouteMeta(); |
|
||||
const anchors = React.Children.toArray(children) |
|
||||
.filter( |
|
||||
(child: any) => |
|
||||
child.props?.mdxType && ['h2', 'h3'].includes(child.props.mdxType) |
|
||||
) |
|
||||
.map((child: any) => ({ |
|
||||
url: '#' + child.props.id, |
|
||||
depth: parseInt(child.props.mdxType.replace('h', ''), 0), |
|
||||
text: child.props.children, |
|
||||
})); |
|
||||
useTwitter(); |
|
||||
return ( |
|
||||
<> |
|
||||
<div className="w-full px-12"> |
|
||||
<div className="h-full mx-auto max-w-4xl relative pt-16 w-full overflow-x-hidden"> |
|
||||
<Seo title={meta.title} /> |
|
||||
<h1 className="mb-6 pt-8 text-4xl md:text-5xl font-bold leading-snug tracking-tight text-primary dark:text-primary-dark"> |
|
||||
{meta.title} |
|
||||
</h1> |
|
||||
<p className="mb-6 text-lgtext-secondary dark:text-secondary-dark"> |
|
||||
By{' '} |
|
||||
{toCommaSeparatedList(meta.author, (author) => ( |
|
||||
<ExternalLink |
|
||||
href={getAuthor(author).url} |
|
||||
className="text-link dark:text-link-dark underline font-bold"> |
|
||||
{getAuthor(author).name} |
|
||||
</ExternalLink> |
|
||||
))} |
|
||||
<span className="mx-2">·</span> |
|
||||
<span className="lead inline-flex text-gray-50"> |
|
||||
<time dateTime={dateTime}>{date}</time> |
|
||||
</span> |
|
||||
</p> |
|
||||
|
|
||||
<MDXContext.Provider value={MDXComponents}> |
|
||||
{children} |
|
||||
</MDXContext.Provider> |
|
||||
<DocsPageFooter |
|
||||
route={route} |
|
||||
nextRoute={nextRoute} |
|
||||
prevRoute={prevRoute} |
|
||||
/> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div className="w-full lg:max-w-xs h-full hidden 2xl:block"> |
|
||||
<Toc headings={anchors} /> |
|
||||
</div> |
|
||||
</> |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
function AppShell(props: {children: React.ReactNode}) { |
|
||||
return <Page routeTree={recentPostsRouteTree as RouteItem} {...props} />; |
|
||||
} |
|
||||
|
|
||||
export default function withLayoutPost(meta: any) { |
|
||||
function LayoutPostWrapper(props: LayoutPostProps) { |
|
||||
return <LayoutPost {...props} meta={meta} />; |
|
||||
} |
|
||||
|
|
||||
LayoutPostWrapper.appShell = AppShell; |
|
||||
|
|
||||
return LayoutPostWrapper; |
|
||||
} |
|
@ -0,0 +1,9 @@ |
|||||
|
--- |
||||
|
title: Server Error |
||||
|
--- |
||||
|
|
||||
|
Something went very wrong. |
||||
|
|
||||
|
Sorry about that! |
||||
|
|
||||
|
You can file a bug [here.](https://github.com/reactjs/reactjs.org/issues/new) |
@ -1,71 +0,0 @@ |
|||||
import blogIndex from 'blogIndex.json'; |
|
||||
import blogIndexRecentRouteTree from 'blogIndexRecent.json'; |
|
||||
import {ExternalLink} from 'components/ExternalLink'; |
|
||||
import {IconRss} from 'components/Icon/IconRss'; |
|
||||
import {Page} from 'components/Layout/Page'; |
|
||||
import format from 'date-fns/format'; |
|
||||
import parseISO from 'date-fns/parseISO'; |
|
||||
import Link from 'next/link'; |
|
||||
import * as React from 'react'; |
|
||||
import {getAuthor} from 'utils/getAuthor'; |
|
||||
import {removeFromLast} from 'utils/removeFromLast'; |
|
||||
import toCommaSeparatedList from 'utils/toCommaSeparatedList'; |
|
||||
|
|
||||
export default function Archive() { |
|
||||
return ( |
|
||||
<div className="mx-auto max-w-5xl container px-4 sm:px-6 lg:px-8 pt-16"> |
|
||||
<header className="py-16 "> |
|
||||
<div className="flex items-center justify-between"> |
|
||||
<h1 className="text-5xl font-bold">Blog Archive</h1> |
|
||||
<a |
|
||||
href="/feed.xml" |
|
||||
className="p-2 betterhover:hover:bg-gray-20 transition duration-150 ease-in-out rounded-lg inline-flex items-center"> |
|
||||
<IconRss className="w-5 h-5 mr-2" /> |
|
||||
RSS |
|
||||
</a> |
|
||||
</div> |
|
||||
<p className="text-gray-70 text-2xl"> |
|
||||
Historical archive of React news, announcements, and release notes. |
|
||||
</p> |
|
||||
</header> |
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 pb-40"> |
|
||||
{blogIndex.routes.map((post) => ( |
|
||||
<div key={post.path}> |
|
||||
<h3 className="font-bold text-xl "> |
|
||||
<Link href={removeFromLast(post.path, '.')}> |
|
||||
<a>{post.title}</a> |
|
||||
</Link> |
|
||||
</h3> |
|
||||
<div className="flex items-center"> |
|
||||
<div> |
|
||||
<p className="text-sm leading-5 text-gray-80"> |
|
||||
By{' '} |
|
||||
{toCommaSeparatedList(post.author, (author) => ( |
|
||||
<ExternalLink |
|
||||
href={getAuthor(author).url} |
|
||||
className="font-bold betterhover:hover:underline"> |
|
||||
<span>{getAuthor(author).name}</span> |
|
||||
</ExternalLink> |
|
||||
))} |
|
||||
</p> |
|
||||
<div className="flex text-sm leading-5 text-gray-50"> |
|
||||
<time dateTime={post.date}> |
|
||||
{format(parseISO(post.date), 'MMMM dd, yyyy')} |
|
||||
</time> |
|
||||
<span className="mx-1">·</span> |
|
||||
<span>{post.readingTime}</span> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
))} |
|
||||
</div> |
|
||||
</div> |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
Archive.displayName = 'Index'; |
|
||||
|
|
||||
Archive.appShell = function AppShell(props: {children: React.ReactNode}) { |
|
||||
return <Page routeTree={blogIndexRecentRouteTree} {...props} />; |
|
||||
}; |
|
@ -1,95 +0,0 @@ |
|||||
import blogIndexRecentRouteTree from 'blogIndexRecent.json'; |
|
||||
import {ExternalLink} from 'components/ExternalLink'; |
|
||||
import {IconRss} from 'components/Icon/IconRss'; |
|
||||
import {Page} from 'components/Layout/Page'; |
|
||||
import styles from 'components/MDX/MDXComponents.module.css'; |
|
||||
import {Seo} from 'components/Seo'; |
|
||||
import format from 'date-fns/format'; |
|
||||
import parseISO from 'date-fns/parseISO'; |
|
||||
import Link from 'next/link'; |
|
||||
import * as React from 'react'; |
|
||||
import {getAuthor} from 'utils/getAuthor'; |
|
||||
import {removeFromLast} from 'utils/removeFromLast'; |
|
||||
import toCommaSeparatedList from 'utils/toCommaSeparatedList'; |
|
||||
|
|
||||
export default function RecentPosts() { |
|
||||
return ( |
|
||||
<> |
|
||||
<div className="w-full px-12"> |
|
||||
<div className="max-w-4xl mx-auto w-full container pt-10"> |
|
||||
<header className="pt-14 pb-8"> |
|
||||
<div className="flex items-center justify-between"> |
|
||||
<Seo |
|
||||
title="Blog" |
|
||||
description="Offical React.js news, announcements, and release notes." |
|
||||
/> |
|
||||
<h1 className="text-5xl font-bold text-primary dark:text-primary-dark mb-8"> |
|
||||
Blog |
|
||||
</h1> |
|
||||
<a |
|
||||
href="/feed.xml" |
|
||||
className="p-2 betterhover:hover:bg-gray-20 transition duration-150 ease-in-out rounded-lg inline-flex items-center"> |
|
||||
<IconRss className="w-5 h-5 mr-2" /> |
|
||||
RSS |
|
||||
</a> |
|
||||
</div> |
|
||||
<p className="text-primary dark:text-primary-dark text-xl leading-large"> |
|
||||
Offical React.js news, announcements, and release notes. |
|
||||
</p> |
|
||||
</header> |
|
||||
<div className="space-y-12 pb-40"> |
|
||||
{blogIndexRecentRouteTree.routes.map((post) => ( |
|
||||
<div key={post.path}> |
|
||||
<h3 className="font-bold leading-8 text-primary dark:text-primary-dark text-2xl mb-2 hover:underline"> |
|
||||
<Link href={removeFromLast(post.path, '.')}> |
|
||||
<a>{post.title}</a> |
|
||||
</Link> |
|
||||
</h3> |
|
||||
<div |
|
||||
className={styles.markdown + ' mb-0'} |
|
||||
dangerouslySetInnerHTML={{__html: post.excerpt.trim()}} |
|
||||
/> |
|
||||
<div className="flex items-center"> |
|
||||
<div> |
|
||||
<p className="text-sm leading-5 text-gray-80"> |
|
||||
By{' '} |
|
||||
{toCommaSeparatedList(post.author, (author) => ( |
|
||||
<ExternalLink |
|
||||
href={getAuthor(author).url} |
|
||||
className="font-bold betterhover:hover:underline"> |
|
||||
<span>{getAuthor(author).name}</span> |
|
||||
</ExternalLink> |
|
||||
))} |
|
||||
</p> |
|
||||
<div className="flex text-sm leading-5 text-gray-50"> |
|
||||
<time dateTime={post.date}> |
|
||||
{format(parseISO(post.date), 'MMMM dd, yyyy')} |
|
||||
</time> |
|
||||
<span className="mx-1">·</span> |
|
||||
<span>{post.readingTime}</span> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
))} |
|
||||
<div className="text-center"> |
|
||||
<Link href="/blog/all"> |
|
||||
<a className="p-2 text-center bg-card dark:bg-card-dark font-bold betterhover:hover:bg-secondary-button dark:bg-secondary-button-dark transition duration-150 ease-in-out rounded-lg inline-flex items-center"> |
|
||||
View all articles |
|
||||
</a> |
|
||||
</Link> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
|
||||
<div className="pt-20 w-full lg:max-w-xs lg:sticky top-0 h-full hidden xl:block"></div> |
|
||||
</> |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
RecentPosts.displayName = 'Index'; |
|
||||
|
|
||||
RecentPosts.appShell = function AppShell(props: {children: React.ReactNode}) { |
|
||||
return <Page routeTree={blogIndexRecentRouteTree} {...props} />; |
|
||||
}; |
|
Loading…
Reference in new issue