Skip to content

Commit 3bab749

Browse files
committed
AI-generate home page
1 parent bf74cc7 commit 3bab749

2 files changed

Lines changed: 187 additions & 22 deletions

File tree

src/components/HomepageFeatures/index.tsx

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,62 @@ type FeatureItem = {
1111

1212
const FeatureList: FeatureItem[] = [
1313
{
14-
title: 'Easy to Use',
14+
title: 'Modular Component System',
1515
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
1616
description: (
1717
<>
18-
Docusaurus was designed from the ground up to be easily installed and
19-
used to get your website up and running quickly.
18+
Decouple interface definitions from implementations using provider traits.
19+
Write multiple context-generic providers that can coexist without conflicts.
2020
</>
2121
),
2222
},
2323
{
24-
title: 'Focus on What Matters',
24+
title: 'Highly Expressive Macros',
2525
Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
2626
description: (
2727
<>
28-
Docusaurus lets you focus on your docs, and we&apos;ll do the chores. Go
29-
ahead and move your docs into the <code>docs</code> directory.
28+
Write abstract programs generic over contexts without managing long lists
29+
of generic parameters. Achieve expressiveness rivaling dynamic languages.
3030
</>
3131
),
3232
},
3333
{
34-
title: 'Powered by React',
34+
title: 'Type-Safe Composition',
3535
Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
3636
description: (
3737
<>
38-
Extend or customize your website layout by reusing React. Docusaurus can
39-
be extended while reusing the same header and footer.
38+
All component wiring is verified at compile time. Missing dependencies are
39+
caught early, with no runtime errors possible from CGP constructs.
40+
</>
41+
),
42+
},
43+
{
44+
title: 'No-Std Friendly',
45+
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
46+
description: (
47+
<>
48+
Build fully abstract programs without concrete dependencies. Deploy to
49+
embedded systems, kernels, WebAssembly, or symbolic execution platforms.
50+
</>
51+
),
52+
},
53+
{
54+
title: 'Zero-Cost Abstraction',
55+
Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
56+
description: (
57+
<>
58+
All CGP operations happen at compile time using Rust's type system.
59+
No runtime overhead, upholding Rust's zero-cost abstraction guarantee.
60+
</>
61+
),
62+
},
63+
{
64+
title: 'Bypass Coherence Rules',
65+
Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
66+
description: (
67+
<>
68+
Enable overlapping and orphan trait implementations without restriction.
69+
Define implementations for types you don't own and traits you don't control.
4070
</>
4171
),
4272
},
@@ -60,6 +90,9 @@ export default function HomepageFeatures(): ReactNode {
6090
return (
6191
<section className={styles.features}>
6292
<div className="container">
93+
<Heading as="h2" className={clsx(styles.featuresTitle, 'text--center')}>
94+
Why Context-Generic Programming?
95+
</Heading>
6396
<div className="row">
6497
{FeatureList.map((props, idx) => (
6598
<Feature key={idx} {...props} />

src/pages/index.tsx

Lines changed: 145 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,174 @@ import type {ReactNode} from 'react';
22
import clsx from 'clsx';
33
import Link from '@docusaurus/Link';
44
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5+
import useBaseUrl from '@docusaurus/useBaseUrl';
56
import Layout from '@theme/Layout';
67
import HomepageFeatures from '@site/src/components/HomepageFeatures';
78
import Heading from '@theme/Heading';
89

910
import styles from './index.module.css';
1011

11-
function HomepageHeader() {
12-
const {siteConfig} = useDocusaurusContext();
12+
function HeroBanner() {
13+
return (
14+
<div className={styles.hero} data-theme="dark">
15+
<div className={styles.heroInner}>
16+
<Heading as="h1" className={styles.heroProjectTagline}>
17+
<img
18+
alt="Context-Generic Programming"
19+
className={styles.heroLogo}
20+
src={useBaseUrl('/img/docusaurus.png')}
21+
width="200"
22+
height="200"
23+
/>
24+
<span className={styles.heroTitleTextHtml}>
25+
Build <b>modular</b> Rust applications with <b>zero-cost</b> abstractions
26+
</span>
27+
</Heading>
28+
<div className={styles.indexCtas}>
29+
<Link className="button button--primary button--lg" to="/docs">
30+
Get Started
31+
</Link>
32+
<Link
33+
className="button button--secondary button--lg margin-left--md"
34+
to="/docs/tutorials/hello">
35+
Tutorial - 10 min ⏱️
36+
</Link>
37+
<span className={styles.indexCtasGitHubButtonWrapper}>
38+
<iframe
39+
className={styles.indexCtasGitHubButton}
40+
src="https://ghbtns.com/github-btn.html?user=contextgeneric&amp;repo=cgp&amp;type=star&amp;count=true&amp;size=large"
41+
width={160}
42+
height={30}
43+
title="GitHub Stars"
44+
/>
45+
</span>
46+
</div>
47+
</div>
48+
</div>
49+
);
50+
}
51+
52+
function CodeExampleSection() {
1353
return (
14-
<header className={clsx('hero hero--primary', styles.heroBanner)}>
54+
<div className={clsx(styles.section, styles.sectionAlt)}>
1555
<div className="container">
16-
<Heading as="h1" className="hero__title">
17-
{siteConfig.title}
56+
<div className="row">
57+
<div className="col col--6">
58+
<Heading as="h2">Bypass Coherence Restrictions</Heading>
59+
<p>
60+
CGP enables you to write <b>overlapping</b> and <b>orphan</b> implementations
61+
of any trait, breaking free from Rust's coherence rules while maintaining
62+
type safety.
63+
</p>
64+
<p>
65+
Annotate any trait with <code>#[cgp_component]</code>, write named implementations
66+
with <code>#[cgp_impl]</code>, and selectively enable them using{' '}
67+
<code>delegate_components!</code>.
68+
</p>
69+
</div>
70+
<div className="col col--6">
71+
<div className={styles.codeExample}>
72+
<pre>
73+
{`#[cgp_component(HashProvider)]
74+
pub trait Hash { ... }
75+
76+
#[cgp_impl(HashWithDisplay)]
77+
impl HashProvider
78+
where
79+
Self: Display,
80+
{ ... }
81+
82+
delegate_components! {
83+
MyData {
84+
HashProviderComponent: HashWithDisplay,
85+
}
86+
}`}
87+
</pre>
88+
</div>
89+
</div>
90+
</div>
91+
</div>
92+
</div>
93+
);
94+
}
95+
96+
function ProblemsSection() {
97+
return (
98+
<div className={styles.section}>
99+
<div className="container">
100+
<Heading as="h2" className="text--center margin-bottom--xl">
101+
Common Rust Problems, Solved
18102
</Heading>
19-
<p className="hero__subtitle">{siteConfig.tagline}</p>
103+
<div className="row">
104+
<div className="col col--4">
105+
<div className={styles.problemCard}>
106+
<Heading as="h3">⚡ No More Monolithic Traits</Heading>
107+
<p>
108+
Break down large traits into small, focused components.
109+
Compose features without trait bounds propagating everywhere.
110+
</p>
111+
</div>
112+
</div>
113+
<div className="col col--4">
114+
<div className={styles.problemCard}>
115+
<Heading as="h3">🔄 Overlapping Implementations</Heading>
116+
<p>
117+
Implement traits in multiple ways without newtype wrappers.
118+
Choose the right implementation for your context.
119+
</p>
120+
</div>
121+
</div>
122+
<div className="col col--4">
123+
<div className={styles.problemCard}>
124+
<Heading as="h3">🎯 Decouple Dependencies</Heading>
125+
<p>
126+
Write core logic independent of error handling, async runtimes,
127+
or serialization libraries. Wire them up at the edges.
128+
</p>
129+
</div>
130+
</div>
131+
</div>
132+
</div>
133+
</div>
134+
);
135+
}
136+
137+
function CallToActionSection() {
138+
return (
139+
<div className={clsx(styles.section, styles.sectionAlt)}>
140+
<div className="container text--center">
141+
<Heading as="h2">Ready to Get Started?</Heading>
142+
<p className="margin-bottom--lg">
143+
CGP is in active development and perfect for early adopters who want to
144+
experiment with advanced Rust patterns.
145+
</p>
20146
<div className={styles.buttons}>
147+
<Link className="button button--primary button--lg" to="/docs">
148+
Read the Docs
149+
</Link>
21150
<Link
22-
className="button button--secondary button--lg"
23-
to="/docs/intro">
24-
Docusaurus Tutorial - 5min ⏱️
151+
className="button button--secondary button--lg margin-left--md"
152+
to="/docs/contribute">
153+
Contribute to CGP
25154
</Link>
26155
</div>
27156
</div>
28-
</header>
157+
</div>
29158
);
30159
}
31160

32161
export default function Home(): ReactNode {
33162
const {siteConfig} = useDocusaurusContext();
34163
return (
35164
<Layout
36-
title={`Home`}
37-
description="Context-Generic Programming (CGP) Project Homepage">
38-
<HomepageHeader />
165+
title={siteConfig.tagline}
166+
description="Context-Generic Programming (CGP) - A modular programming paradigm for Rust">
39167
<main>
168+
<HeroBanner />
40169
<HomepageFeatures />
170+
<CodeExampleSection />
171+
<ProblemsSection />
172+
<CallToActionSection />
41173
</main>
42174
</Layout>
43175
);

0 commit comments

Comments
 (0)