Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
docs: overhaul homepage#11345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
docs: overhaul homepage#11345
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This was much more work than I'd hoped it would be. There's no exported way to get blog posts from |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||
import type { Plugin } from '@docusaurus/types'; | ||||
import matter from 'gray-matter'; | ||||
import * as fs from 'node:fs/promises'; | ||||
import readingTime from 'reading-time'; | ||||
import { z } from 'zod'; | ||||
const storageDirectory = 'data'; | ||||
const storageFile = `data/recent-blog-posts.json`; | ||||
const matterSchema = z.object({ | ||||
description: z.string(), | ||||
slug: z.string(), | ||||
title: z.string(), | ||||
}); | ||||
export default async function blogPluginEnhanced(): Promise<Plugin> { | ||||
const blogHandles = (await fs.readdir('blog', { withFileTypes: true })) | ||||
.filter(handle => handle.isFile() && /.mdx?$/.test(handle.name)) | ||||
.map(handle => ({ | ||||
date: new Date(/\d+-\d+-\d+/.exec(handle.name)?.[0] || '1970-01-01'), | ||||
handle, | ||||
})) | ||||
.sort((a, b) => b.date.getTime() - a.date.getTime()) | ||||
.slice(0, 3); | ||||
const blogPosts = await Promise.all( | ||||
blogHandles.map(async ({ date, handle }) => { | ||||
const content = await fs.readFile(`blog/${handle.name}`, 'utf-8'); | ||||
const data = matterSchema.parse(matter(content).data); | ||||
return { | ||||
date, | ||||
description: data.description, | ||||
readingTime: Math.round(readingTime(content).minutes), | ||||
slug: data.slug, | ||||
title: data.title, | ||||
}; | ||||
}), | ||||
); | ||||
await fs.mkdir(storageDirectory, { recursive: true }); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. (unnecessary, it's checked in) Suggested change
| ||||
await fs.writeFile(storageFile, JSON.stringify(blogPosts, null, 2)); | ||||
return { | ||||
name: 'recent-blog-posts', | ||||
}; | ||||
} |
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Heading from '@theme/Heading'; | ||
import React from 'react'; | ||
import styles from './styles.module.css'; | ||
export interface ExplainerSpotlightProps extends React.PropsWithChildren { | ||
header: string; | ||
emoji: string; | ||
href: string; | ||
} | ||
export function ExplainerSpotlight({ | ||
children, | ||
emoji, | ||
header, | ||
href, | ||
}: ExplainerSpotlightProps): React.JSX.Element { | ||
return ( | ||
<a className={styles.explainerSpotlight} href={href}> | ||
<Heading as="h3" className={styles.heading}> | ||
{header} <span>{emoji}</span> | ||
</Heading> | ||
<div>{children}</div> | ||
</a> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.explainerSpotlight { | ||
background: var(--ifm-color-emphasis-100); | ||
border-radius: var(--ifm-global-radius); | ||
color: var(--ifm-heading-color); | ||
padding: 1rem 1.5rem; | ||
text-decoration: none; | ||
transition: box-shadow 0.3s ease; | ||
width: 100%; | ||
} | ||
[data-theme='dark'] .explainerSpotlight { | ||
background: var(--ifm-color-emphasis-200); | ||
} | ||
.explainerSpotlight:hover { | ||
color: var(--ifm-heading-color); | ||
text-decoration: none; | ||
box-shadow: 0 3px 3px 0 var(--gray-border-shadow); | ||
} | ||
.heading { | ||
display: flex; | ||
justify-content: space-between; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import Link from '@docusaurus/Link'; | ||
import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
import Heading from '@theme/Heading'; | ||
import clsx from 'clsx'; | ||
import React from 'react'; | ||
import { ExplainerSpotlight } from '../ExplainerSpotlight'; | ||
import styles from './styles.module.css'; | ||
const explanations = [ | ||
{ | ||
children: | ||
'The parser and services for linting TypeScript code with ESLint, as well as how tools such as Prettier read TypeScript code.', | ||
emoji: '⚙️', | ||
header: 'Language Support', | ||
href: '/getting-started', | ||
}, | ||
{ | ||
children: | ||
'Over 100 rules that check for best practices, likely bugs, and stylistic consistency in modern JavaScript and TypeScript codebases.', | ||
emoji: '🧠', | ||
header: 'Standard Rules', | ||
href: '/rules', | ||
}, | ||
{ | ||
children: | ||
"Industry-leading services that use TypeScript's type APIs to make a more powerful breed of lint rules for deeper insights into code.", | ||
emoji: '⚡️', | ||
header: 'Typed Linting', | ||
href: '/getting-started/typed-linting', | ||
}, | ||
]; | ||
export function Explainers(): React.JSX.Element { | ||
return ( | ||
<section className={clsx('padding-vert--lg', styles.explainers)}> | ||
<Heading as="h2" className="col col--12 text--center"> | ||
<strong>typescript-eslint</strong> enables ESLint, Prettier, and more to | ||
support TypeScript code. | ||
</Heading> | ||
<ul className={clsx('col col--10', styles.explainerSpotlights)}> | ||
{explanations.map(({ header, ...rest }) => ( | ||
<ExplainerSpotlight header={header} key={header} {...rest} /> | ||
))} | ||
</ul> | ||
<div className={styles.explainerTexts}> | ||
<p> | ||
<strong>ESLint</strong> is a linter. It runs a set of rules to find | ||
likely problems and suggested fixes to improve your code. | ||
</p> | ||
<p> | ||
<strong>TypeScript</strong> is a language and a type checker. The | ||
language adds syntax for types to JavaScript. | ||
<br /> | ||
The type checker analyzes code to find mismatches between uses of | ||
values and types. | ||
</p> | ||
<p> | ||
<strong>typescript-eslint</strong> is necessary for JavaScript tools | ||
such as ESLint to work with TypeScript's new syntax. | ||
<br /> | ||
It also adds lint rules for TypeScript, including many that use the | ||
power of types to better analyze code. | ||
</p> | ||
</div> | ||
<div className={styles.buttons}> | ||
<Link | ||
className="button button--primary" | ||
to={useBaseUrl('getting-started')} | ||
> | ||
Learn More | ||
</Link> | ||
<Link | ||
className="button button--primary button--outline" | ||
to={useBaseUrl('rules')} | ||
> | ||
See the Rules | ||
</Link> | ||
</div> | ||
</section> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.explainers { | ||
--ifm-button-size-multiplier: 1.3; | ||
align-items: center; | ||
display: flex; | ||
flex-direction: column; | ||
margin: 1rem; | ||
} | ||
.explainerTexts { | ||
font-size: 1.1rem; | ||
margin: 1rem 2rem; | ||
text-align: left; | ||
display: flex; | ||
gap: 1rem; | ||
flex-direction: column; | ||
} | ||
.explainerTexts p { | ||
margin: 0; | ||
} | ||
.explainerSpotlights { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
margin: 2rem auto 2.5rem; | ||
} | ||
.buttons { | ||
margin: 1rem auto 0; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
} | ||
@media (width >= 996px) { | ||
.explainerSpotlights { | ||
flex-direction: row; | ||
max-width: var(--ifm-container-width); | ||
} | ||
.explainerTexts { | ||
margin: 0.5rem 2rem 2rem; | ||
text-align: center; | ||
} | ||
.buttons { | ||
flex-direction: row; | ||
gap: 2rem; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.buttons { | ||
align-items: center; | ||
display: flex; | ||
width: 100%; | ||
justify-content: center; | ||
} |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.