-
-
Notifications
You must be signed in to change notification settings - Fork 2.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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JoshuaKGoldberg
wants to merge
7
commits into
typescript-eslint:main
Choose a base branch
from
JoshuaKGoldberg:homepage-overhaul
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+568
−279
Open
docs: overhaul homepage #11345
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e7c3b86
docs: overhaul homepage
JoshuaKGoldberg 4bf2e04
Merge branch 'main' into homepage-overhaul
JoshuaKGoldberg 11b3e19
Update packages/website/plugins/recent-blog-posts/index.ts
JoshuaKGoldberg dd13941
recent-blog-posts/index.ts in knip
JoshuaKGoldberg 5f0678e
Remove unused variable
JoshuaKGoldberg 780c238
Deduplicate Zod
JoshuaKGoldberg 7a2aeb5
Small CSS tweaks
JoshuaKGoldberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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 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.writeFile(storageFile, JSON.stringify(blogPosts, null, 2)); | ||
|
||
return { | ||
name: 'recent-blog-posts', | ||
}; | ||
} |
65 changes: 0 additions & 65 deletions
65
packages/website/src/components/FinancialContributors/index.tsx
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
packages/website/src/components/home/ExplainerSpotlight/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 className={styles.emoji}>{emoji}</span> | ||
</Heading> | ||
<div>{children}</div> | ||
</a> | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/website/src/components/home/ExplainerSpotlight/styles.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.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; | ||
} | ||
|
||
.emoji { | ||
user-select: none; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/website/src/components/home/Explainers/styles.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.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) { | ||
.explainers { | ||
margin-bottom: 2rem; | ||
} | ||
|
||
.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; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
@docusaurus/plugin-content-docs
that I could find. https://www.cheehow.dev/blog/2024/04/01/show-recent-posts-in-docusaurus has a suggested strategy & links to more info. I did that at first but kept hitting tricky edge cases with the plugin. So in the end I just went with this more direct approach: manually re-reading and re-parsing the files. 🤷