1
0
mirror of https://github.com/actix/actix-website synced 2025-06-29 08:14:58 +02:00

migrate to docusaurus (v2) (#266)

Co-authored-by: ibraheemdev <ibrah1440@gmail.com>
This commit is contained in:
Santiago
2022-07-16 11:59:20 +02:00
committed by GitHub
parent a85b4ff5a3
commit 8393aea71a
85 changed files with 23020 additions and 4357 deletions

View File

@ -0,0 +1,27 @@
import React, { useState, useEffect } from 'react';
import RenderCodeBlock from '@theme/CodeBlock';
const CodeBlock = ({ example, file, section }) => {
const [code, setCode] = useState("");
useEffect(() => {
let isMounted = true;
import(`!!raw-loader!@site/examples/${example}/src/${file || "main.rs"}`)
.then(source => {
source = source
.default
.match(new RegExp(`\/\/ <${section}>\n([\\s\\S]*)\/\/ <\/${section}>`))[1];
if (isMounted) setCode(source)
})
.catch(err => console.log(err));
return () => {
isMounted = false;
}
}, [])
return (
<RenderCodeBlock className="language-rust">{code}</RenderCodeBlock>
)
}
export default CodeBlock;

53
src/css/custom.css Normal file
View File

@ -0,0 +1,53 @@
:root {
--background-color-secondary: #f8f8f8;
--examples-odd-background-color: var(--background-color-secondary);
--logo-filter: unset;
/* docusaurus vars
https://docusaurus.io/docs/styling-layout#styling-your-site-with-infima
*/
--ifm-color-primary: #7036ab;
--ifm-color-primary-dark: #65319a;
--ifm-color-primary-darker: #5f2e91;
--ifm-color-primary-darkest: #4e2678;
--ifm-color-primary-light: #7b3bbc;
--ifm-color-primary-lighter: #8140c3;
--ifm-color-primary-lightest: #925acb;
--ifm-font-size-base: 16px;
--ifm-code-font-size: 90%;
--ifm-background-color: #fff;
--ifm-footer-background-color: var(--ifm-background-surface-color);
--ifm-menu-color-background-active: var(--ifm-color-emphasis-200);
}
html[data-theme='dark'] {
--background-color-secondary: #0a191c;
--examples-odd-background-color: var(--ifm-hero-background-color);
--logo-filter: brightness(0) invert(1);
/* docusaurus vars */
--ifm-background-color: #0a141c;
--ifm-color-primary: #e98ef5;
--ifm-color-primary-dark: #e26af2;
--ifm-color-primary-darker: #df59f0;
--ifm-color-primary-darkest: #d423ec;
--ifm-color-primary-light: #f0b2f8;
--ifm-color-primary-lighter: #f3c3fa;
--ifm-color-primary-lightest: #fef9fe;
--ifm-footer-background-color: #0a141c;
--ifm-navbar-background-color: var(--ifm-background-color);
--ifm-hero-background-color: var(--background-color-secondary);
--ifm-menu-color-background-active: #21243d;
}
.docusaurus-highlight-code-line {
background-color: rgb(72, 77, 91);
display: block;
margin: 0 calc(-1 * var(--ifm-pre-padding));
padding: 0 var(--ifm-pre-padding);
}
.navbar__logo {
filter: var(--logo-filter);
}

19
src/pages/code.md Normal file
View File

@ -0,0 +1,19 @@
---
title: Code
description: Browse and download the sources
---
# Browse the Code
The Actix ecosystem is fully open source on our GitHub organization [@actix](https://github.com/actix).
Here are the most important projects and the link to their github repositories and related resources:
- [actix-web](https://github.com/actix/actix-web), ([API docs](https://docs.rs/actix-web))
- [actix-extras crates](https://github.com/actix/actix-extras#readme)
- [examples repo](https://github.com/actix/examples#readme)
Actix projects are dual licensed under the [MIT] and [Apache 2] licenses.
[MIT]: https://github.com/actix/actix-web/blob/master/LICENSE-MIT
[Apache 2]: https://github.com/actix/actix-web/blob/master/LICENSE-APACHE

View File

@ -0,0 +1,52 @@
---
title: Contributor Covenant Code of Conduct
description: The code of conduct
---
# Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
# Our Standards
Examples of behavior that contributes to creating a positive environment include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
# Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
# Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
# Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at robjtede@icloud.com ([@robjtede]) or jtitor@2k36.org ([@JohnTitor]). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
[@robjtede]: https://github.com/robjtede
[@JohnTitor]: https://github.com/JohnTitor
# Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@ -0,0 +1,13 @@
---
title: Community
description: The best things in life are to be shared
---
# Join us
Want to talk to others about questions? The Actix Web [Discord server](https://discord.gg/NWpN5mmg3x) is the best starting point. We also have a [Gitter room](https://gitter.im/actix/actix-web).
If you think you found a bug it's best to file an issue directly on the repo. [actix/actix-web](https://github.com/actix/actix-web) for the web framework. [actix/actix](https://github.com/actix/actix) for issues with the actor framework
We're a welcoming community so don't be afraid to engage. Interactions are
[governed by our code of conduct](community/coc).

210
src/pages/index.js Normal file
View File

@ -0,0 +1,210 @@
import clsx from 'clsx';
import React from 'react';
import Link from '@docusaurus/Link';
import Layout from '@theme/Layout';
import CodeBlock from '../components/code_block.js';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import styles from './styles.module.scss';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faShieldAlt,
faBatteryFull,
faPuzzlePiece,
faTachometerAlt,
} from '@fortawesome/free-solid-svg-icons';
const Home = () => {
const context = useDocusaurusContext();
const siteConfig = context;
return (
<Layout description={siteConfig.tagline}>
<Hero />
<main className={styles.main}>
<MainExample />
<Highlights />
<Examples />
</main>
</Layout>
);
};
const highlights = [
{
icon: faShieldAlt,
title: 'Type Safe',
description: (
<>
Forget about stringly typed objects, from request to response,
everything has types.
</>
),
},
{
icon: faBatteryFull,
title: 'Feature Rich',
description: (
<>Actix provides a lot of features out of box. HTTP/2, logging, etc.</>
),
},
{
icon: faPuzzlePiece,
title: 'Extensible',
description: (
<>Easily create your own libraries that any Actix application can use.</>
),
},
{
icon: faTachometerAlt,
title: 'Blazingly Fast',
description: (
<>
Actix is blazingly fast. Don't take our word for it -- see for yourself!
</>
),
},
];
const Hero = () => {
const context = useDocusaurusContext();
const { siteConfig } = context;
return (
<header id="hero" className={clsx('hero', styles.banner)}>
<div className="container">
<img
src={useBaseUrl(`img/logo.png`)}
alt="Actix Logo"
className={styles.logo}
/>
<h1 className="hero__title">{siteConfig.title}</h1>
<p className={clsx('hero__subtitle', styles.subtitle)}>
{siteConfig.tagline}
</p>
<div className={styles.buttons}>
<Link
className="button button--primary button--lg"
to={useBaseUrl('docs/')}
>
Get Started
</Link>
</div>
</div>
</header>
);
};
const MainExample = () => (
<div className={styles.main_example}>
<div className={styles.main_example__code}>
<CodeBlock example="main-example" section="main-example" />
</div>
</div>
);
const Highlights = () => {
return (
<>
<section id="highlights" className={styles.highlights}>
<div className="container">
<div className="row">
<div className="col col--11 col--offset-1">
<div className="row">
{highlights.map((highlight, idx) => (
<div
className={clsx('col col--6', styles.highlight)}
key={idx}
>
<div className="item">
<div className={styles.header}>
<div className={styles.icon}>
<FontAwesomeIcon icon={highlight.icon} size="lg" />
</div>
<h2 className={styles.title}>{highlight.title}</h2>
</div>
<p>{highlight.description}</p>
</div>
</div>
))}
</div>
</div>
</div>
</div>
</section>
</>
);
};
const Examples = () => {
return (
<div>
<div className={styles.example}>
<div className={styles.featureText}>
<h3 className={styles.featureTitle}>Flexible Responders</h3>
<p>
Handler functions in actix can return a wide range of objects that
implement the <code>Responder</code> trait. This makes it a breeze
to return consistent responses from your APIs.
</p>
</div>
<div className={styles.example__code}>
<CodeBlock
example="flexible-responders"
section="flexible-responders"
/>
</div>
</div>
<div className={styles.example}>
<div className={styles.featureText}>
<h3 className={styles.featureTitle}>Powerful Extractors</h3>
<p>
Actix comes with a powerful extractor system that extracts data from
the incoming HTTP request and passes it to your view functions. Not
only does this make for a convenient API but it also means that your
view functions can be synchronous code and still benefit from
asynchronous IO handling.
</p>
</div>
<div className={styles.example__code}>
<CodeBlock
example="powerful-extractors"
section="powerful-extractors"
/>
</div>
</div>
<div className={styles.example}>
<div className={styles.featureText}>
<h3 className={styles.featureTitle}>Easy Form Handling</h3>
<p>
Handling multipart/urlencoded form data is easy. Just define a
structure that can be deserialized and actix will handle the rest.
</p>
</div>
<div className={styles.example__code}>
<CodeBlock
example="easy-form-handling"
section="easy-form-handling"
/>
</div>
</div>
<div className={styles.example}>
<div className={styles.featureText}>
<h3 className={styles.featureTitle}>Request Routing</h3>
<p>
An actix app comes with a URL routing system that lets you match on
URLs and invoke individual handlers. For extra flexibility, scopes
can be used.
</p>
</div>
<div className={styles.example__code}>
<CodeBlock example="request-routing" section="request-routing" />
</div>
</div>
</div>
);
};
export default Home;

View File

@ -0,0 +1,183 @@
.main {
section {
padding: 5rem 0;
@media screen and (max-width: 996px) {
padding: 2.5rem 0;
}
}
}
.highlights {
display: flex;
align-items: center;
width: 100%;
padding-top: 3rem;
.highlight {
p {
margin-bottom: 0;
}
&:not(:last-child) {
margin-bottom: 3rem;
}
@media screen and (min-width: 576px) {
margin-bottom: 3rem;
text-align: center;
}
.header {
display: flex;
flex-direction: row;
align-items: center;
margin-bottom: 1rem;
@media screen and (min-width: 576px) {
justify-content: center;
}
.icon {
display: flex;
align-items: center;
margin-right: 1rem;
color: var(--ifm-color-primary);
}
.title {
font-size: 1.25rem;
margin-bottom: 0;
}
}
}
}
.banner {
padding: 4rem 0;
text-align: center;
position: relative;
overflow: hidden;
// background-image: url('/img/jumbotron.jpg');
// background-size: cover;
// color: #fff;
@media screen and (max-width: 966px) {
padding: 2rem;
}
}
.logo {
max-width: 160px;
filter: var(--logo-filter);
}
.buttons {
display: flex;
align-items: center;
justify-content: center;
}
.subtitle {
margin: 0 auto 2rem;
max-width: 500px;
}
.headline {
margin-bottom: 2rem;
}
.category {
display: inline-flex;
align-items: center;
margin-bottom: 1rem;
font-weight: bold;
text-transform: uppercase;
color: var(--ifm-color-primary-light);
}
.title {
max-width: 500px;
font-size: 2rem;
line-height: initial;
@media screen and (min-width: 576px) {
font-size: 2.4rem;
}
}
.subtitle {
margin-top: 2rem;
color: var(--ifm-color-emphasis-600);
}
.main_example {
display: flex;
justify-content: center;
padding-left: 1rem;
padding-right: 1rem;
flex-wrap: wrap;
padding-top: 2rem;
padding-bottom: 2rem;
}
.main_example__code {
width: 100%;
}
@media (min-width: 1024px) {
.main_example__code {
width: unset;
}
}
// features
.example {
display: flex;
width: 100%;
flex-direction: column;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
padding-left: 1rem;
padding-right: 1rem;
padding-top: 2rem;
padding-bottom: 2rem;
}
.example__code {
width: 100%;
}
.featureText {
justify-self: center;
padding-bottom: 1rem;
}
@media (min-width: 1024px) {
.example {
flex-direction: row;
padding-top: 7rem;
padding-bottom: 7rem;
}
.example:nth-child(odd) {
flex-direction: row-reverse;
background-color: var(--examples-odd-background-color);
}
.featureText {
width: 33%;
}
.example__code {
width: unset;
}
}
.featureTitle {
font-size: 36px;
font-weight: 500;
}
// Hide the title in docs pages, we render our own in markdown
article header h1 {
display: none;
}

13
src/plugin.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = function (context, options) {
return {
configureWebpack(config, isServer, utils) {
return {
module: {
rules: [
{ test: /\.rs$/, use: 'raw-loader' },
],
},
};
},
};
};