1
0
mirror of https://github.com/actix/actix-website synced 2024-11-23 16:31:08 +01:00

prettier js/html

This commit is contained in:
Rob Ede 2023-11-01 15:32:44 +00:00
parent 0d0e7f4433
commit ee701e0e23
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
10 changed files with 122 additions and 117 deletions

View File

@ -1,6 +1,6 @@
tabWidth: 2 tabWidth: 2
overrides: overrides:
- files: ['*.md'] - files: ["*.md"]
options: options:
proseWrap: never proseWrap: never
printWidth: 9999 printWidth: 9999

View File

@ -1,3 +1,3 @@
module.exports = { module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
}; };

View File

@ -1,42 +1,43 @@
const path = require('path'); const path = require("path");
module.exports = { module.exports = {
title: 'Actix', title: "Actix",
tagline: 'Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust', tagline:
url: 'https://actix.rs', "Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust",
baseUrl: '/', url: "https://actix.rs",
onBrokenLinks: 'throw', baseUrl: "/",
onBrokenMarkdownLinks: 'warn', onBrokenLinks: "throw",
favicon: 'img/logo.png', onBrokenMarkdownLinks: "warn",
organizationName: 'actix', // Usually your GitHub org/user name. favicon: "img/logo.png",
projectName: 'actix-web', // Usually your repo name. organizationName: "actix", // Usually your GitHub org/user name.
projectName: "actix-web", // Usually your repo name.
themeConfig: { themeConfig: {
navbar: { navbar: {
title: 'Actix', title: "Actix",
logo: { logo: {
alt: 'Actix Logo', alt: "Actix Logo",
src: 'img/logo-icon.png', src: "img/logo-icon.png",
width: 32, width: 32,
height: 32, height: 32,
}, },
items: [ items: [
{ {
to: 'docs', to: "docs",
activeBasePath: 'docs', activeBasePath: "docs",
label: 'Documentation', label: "Documentation",
position: 'left', position: "left",
}, },
{ {
to: 'community', to: "community",
activeBasePath: 'community', activeBasePath: "community",
label: 'Community', label: "Community",
position: 'left', position: "left",
}, },
{ {
to: 'code', to: "code",
activeBasePath: 'code', activeBasePath: "code",
label: 'Code', label: "Code",
position: 'left', position: "left",
}, },
], ],
}, },
@ -45,26 +46,25 @@ module.exports = {
}, },
prism: { prism: {
// dracula is closest to docs.rs, where keywords are highlighted // dracula is closest to docs.rs, where keywords are highlighted
theme: require('prism-react-renderer/themes/dracula'), theme: require("prism-react-renderer/themes/dracula"),
additionalLanguages: ['rust', 'toml'], additionalLanguages: ["rust", "toml"],
defaultLanguage: 'rust' defaultLanguage: "rust",
}, },
colorMode: { colorMode: {
respectPrefersColorScheme: true, respectPrefersColorScheme: true,
} },
}, },
plugins: ["docusaurus-plugin-sass"], plugins: ["docusaurus-plugin-sass"],
presets: [ presets: [
[ [
'@docusaurus/preset-classic', "@docusaurus/preset-classic",
{ {
docs: { docs: {
sidebarPath: require.resolve('./sidebars.js'), sidebarPath: require.resolve("./sidebars.js"),
editUrl: editUrl: "https://github.com/actix/actix-website/edit/master/",
'https://github.com/actix/actix-website/edit/master/',
}, },
theme: { theme: {
customCss: require.resolve('./src/css/custom.css'), customCss: require.resolve("./src/css/custom.css"),
}, },
}, },
], ],

View File

@ -1,7 +1,7 @@
<!doctype htmtl> <!DOCTYPE htmtl>
<html> <html>
<head> <head>
<meta charset=utf-8> <meta charset="utf-8" />
<title>Forms</title> <title>Forms</title>
</head> </head>
@ -14,17 +14,17 @@
let payload = { let payload = {
timestamp: 12345, timestamp: 12345,
kind: "this is a kind", kind: "this is a kind",
tags: ['tag1', 'tag2', 'tag3'], tags: ["tag1", "tag2", "tag3"],
} };
function submitJson() { function submitJson() {
fetch('http://localhost:8080/event', { fetch("http://localhost:8080/event", {
method: 'POST', method: "POST",
headers: { headers: {
'Accept': 'application/json', Accept: "application/json",
'Content-Type': 'application/json' "Content-Type": "application/json",
}, },
body: JSON.stringify(payload) body: JSON.stringify(payload),
}) })
.then(function (res) { .then(function (res) {
return res.json(); return res.json();
@ -32,7 +32,7 @@
.then(function (data) { .then(function (data) {
let expected = { let expected = {
...payload, ...payload,
id: 1 id: 1,
}; };
console.log("expected: ", expected); console.log("expected: ", expected);
console.log("received: ", data); console.log("received: ", data);

View File

@ -1,44 +1,44 @@
module.exports = { module.exports = {
docs: { docs: {
Introduction: ['welcome', 'whatis'], Introduction: ["welcome", "whatis"],
Basics: [ Basics: [
'getting-started', "getting-started",
'application', "application",
'server', "server",
'extractors', "extractors",
'handlers', "handlers",
], ],
Advanced: [ Advanced: [
'errors', "errors",
'url-dispatch', "url-dispatch",
'request', "request",
'response', "response",
'testing', "testing",
'middleware', "middleware",
'static-files', "static-files",
], ],
Protocols: ['websockets', 'http2'], Protocols: ["websockets", "http2"],
Patterns: ['autoreload', 'databases', 'shuttle'], Patterns: ["autoreload", "databases", "shuttle"],
Diagrams: ['http_server_init', 'conn_lifecycle'], Diagrams: ["http_server_init", "conn_lifecycle"],
Actix: [ Actix: [
'actix/sec-0-quick-start', "actix/sec-0-quick-start",
'actix/sec-1-getting-started', "actix/sec-1-getting-started",
'actix/sec-2-actor', "actix/sec-2-actor",
'actix/sec-3-address', "actix/sec-3-address",
'actix/sec-4-context', "actix/sec-4-context",
'actix/sec-5-arbiter', "actix/sec-5-arbiter",
'actix/sec-6-sync-arbiter', "actix/sec-6-sync-arbiter",
], ],
'API Documentation': [ "API Documentation": [
{ {
type: 'link', type: "link",
label: 'actix', label: "actix",
href: 'https://docs.rs/actix/latest/actix/', href: "https://docs.rs/actix/latest/actix/",
}, },
{ {
type: 'link', type: "link",
label: 'actix-web', label: "actix-web",
href: 'https://docs.rs/actix-web/latest/actix_web/', href: "https://docs.rs/actix-web/latest/actix_web/",
}, },
], ],
}, },

View File

@ -1,21 +1,21 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from "react";
import RenderCodeBlock from '@theme/CodeBlock'; import RenderCodeBlock from "@theme/CodeBlock";
const CodeBlock = ({ example, file, section, language }) => { const CodeBlock = ({ example, file, section, language }) => {
const [code, setCode] = useState(''); const [code, setCode] = useState("");
useEffect(() => { useEffect(() => {
let isMounted = true; let isMounted = true;
const path = const path =
file === 'manifest' ? 'Cargo.toml' : `src/${file ?? 'main.rs'}`; file === "manifest" ? "Cargo.toml" : `src/${file ?? "main.rs"}`;
import(`!!raw-loader!@site/examples/${example}/${path}`) import(`!!raw-loader!@site/examples/${example}/${path}`)
.then((source) => { .then((source) => {
source = source.default.match( source = source.default.match(
new RegExp( new RegExp(
`(?:\/\/|#) <${section}>\n([\\s\\S]*)(?:\/\/|#) <\/${section}>` `(?:\/\/|#) <${section}>\n([\\s\\S]*)(?:\/\/|#) <\/${section}>`,
) ),
)[1]; )[1];
if (isMounted) setCode(source); if (isMounted) setCode(source);
@ -28,7 +28,7 @@ const CodeBlock = ({ example, file, section, language }) => {
}, []); }, []);
return ( return (
<RenderCodeBlock className={`language-${language ?? 'rust'}`}> <RenderCodeBlock className={`language-${language ?? "rust"}`}>
{code} {code}
</RenderCodeBlock> </RenderCodeBlock>
); );

View File

@ -20,7 +20,7 @@
--ifm-menu-color-background-active: var(--ifm-color-emphasis-200); --ifm-menu-color-background-active: var(--ifm-color-emphasis-200);
} }
html[data-theme='dark'] { html[data-theme="dark"] {
--background-color-secondary: #0a191c; --background-color-secondary: #0a191c;
--examples-odd-background-color: var(--ifm-hero-background-color); --examples-odd-background-color: var(--ifm-hero-background-color);
--logo-filter: brightness(0) invert(1); --logo-filter: brightness(0) invert(1);
@ -47,7 +47,6 @@ html[data-theme='dark'] {
padding: 0 var(--ifm-pre-padding); padding: 0 var(--ifm-pre-padding);
} }
.navbar__logo { .navbar__logo {
filter: var(--logo-filter); filter: var(--logo-filter);
} }

View File

@ -1,18 +1,18 @@
import clsx from 'clsx'; import clsx from "clsx";
import React from 'react'; import React from "react";
import Link from '@docusaurus/Link'; import Link from "@docusaurus/Link";
import Layout from '@theme/Layout'; import Layout from "@theme/Layout";
import CodeBlock from '../components/code_block.js'; import CodeBlock from "../components/code_block.js";
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import useBaseUrl from '@docusaurus/useBaseUrl'; import useBaseUrl from "@docusaurus/useBaseUrl";
import styles from './styles.module.scss'; import styles from "./styles.module.scss";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { import {
faShieldAlt, faShieldAlt,
faBatteryFull, faBatteryFull,
faPuzzlePiece, faPuzzlePiece,
faTachometerAlt, faTachometerAlt,
} from '@fortawesome/free-solid-svg-icons'; } from "@fortawesome/free-solid-svg-icons";
const Home = () => { const Home = () => {
const context = useDocusaurusContext(); const context = useDocusaurusContext();
@ -32,7 +32,7 @@ const Home = () => {
const highlights = [ const highlights = [
{ {
icon: faShieldAlt, icon: faShieldAlt,
title: 'Type Safe', title: "Type Safe",
description: ( description: (
<> <>
Forget about stringly typed objects, from request to response, Forget about stringly typed objects, from request to response,
@ -42,24 +42,31 @@ const highlights = [
}, },
{ {
icon: faBatteryFull, icon: faBatteryFull,
title: 'Feature Rich', title: "Feature Rich",
description: ( description: (
<>Actix provides a lot of features out of box. HTTP/2, logging, etc.</> <>Actix provides a lot of features out of box. HTTP/2, logging, etc.</>
), ),
}, },
{ {
icon: faPuzzlePiece, icon: faPuzzlePiece,
title: 'Extensible', title: "Extensible",
description: ( description: (
<>Easily create your own libraries that any Actix application can use.</> <>Easily create your own libraries that any Actix application can use.</>
), ),
}, },
{ {
icon: faTachometerAlt, icon: faTachometerAlt,
title: 'Blazingly Fast', title: "Blazingly Fast",
description: ( description: (
<> <>
Actix is blazingly fast. Don't take our word for it -- <a href='https://www.techempower.com/benchmarks/#section=data-r21&hw=ph&test=fortune' target='_blank' rel='noopener noreferrer'>see for yourself!</a> Actix is blazingly fast. Don't take our word for it --{" "}
<a
href="https://www.techempower.com/benchmarks/#section=data-r21&hw=ph&test=fortune"
target="_blank"
rel="noopener noreferrer"
>
see for yourself!
</a>
</> </>
), ),
}, },
@ -70,7 +77,7 @@ const Hero = () => {
const { siteConfig } = context; const { siteConfig } = context;
return ( return (
<header id="hero" className={clsx('hero', styles.banner)}> <header id="hero" className={clsx("hero", styles.banner)}>
<div className="container"> <div className="container">
<img <img
src={useBaseUrl(`img/logo.png`)} src={useBaseUrl(`img/logo.png`)}
@ -79,14 +86,14 @@ const Hero = () => {
/> />
<h1 className="hero__title">{siteConfig.title}</h1> <h1 className="hero__title">{siteConfig.title}</h1>
<p className={clsx('hero__subtitle', styles.subtitle)}> <p className={clsx("hero__subtitle", styles.subtitle)}>
{siteConfig.tagline} {siteConfig.tagline}
</p> </p>
<div className={styles.buttons}> <div className={styles.buttons}>
<Link <Link
className="button button--primary button--lg" className="button button--primary button--lg"
to={useBaseUrl('docs/')} to={useBaseUrl("docs/")}
> >
Get Started Get Started
</Link> </Link>
@ -106,7 +113,7 @@ const Highlights = () => {
<div className="row"> <div className="row">
{highlights.map((highlight, idx) => ( {highlights.map((highlight, idx) => (
<div <div
className={clsx('col col--6', styles.highlight)} className={clsx("col col--6", styles.highlight)}
key={idx} key={idx}
> >
<div className="item"> <div className="item">
@ -137,8 +144,9 @@ const Examples = () => {
<div className={styles.featureText}> <div className={styles.featureText}>
<h3 className={styles.featureTitle}>Hello World!</h3> <h3 className={styles.featureTitle}>Hello World!</h3>
<p> <p>
Getting started with Actix is easy. An Actix app comes with a URL routing system that lets you match on Getting started with Actix is easy. An Actix app comes with a URL
URLs and invoke individual handlers. routing system that lets you match on URLs and invoke individual
handlers.
</p> </p>
</div> </div>
<div className={styles.example__code}> <div className={styles.example__code}>
@ -169,11 +177,11 @@ const Examples = () => {
<div className={styles.featureText}> <div className={styles.featureText}>
<h3 className={styles.featureTitle}>Powerful Extractors</h3> <h3 className={styles.featureTitle}>Powerful Extractors</h3>
<p> <p>
Actix comes with a powerful extractor system that extracts data from Actix comes with a powerful extractor system that extracts data
the incoming HTTP request and passes it to your view functions. Not from the incoming HTTP request and passes it to your view
only does this make for a convenient API but it also means that your functions. Not only does this make for a convenient API but it
view functions can be synchronous code and still benefit from also means that your view functions can be synchronous code and
asynchronous IO handling. still benefit from asynchronous IO handling.
</p> </p>
</div> </div>
<div className={styles.example__code}> <div className={styles.example__code}>

View File

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

View File

@ -1,5 +1,5 @@
module.exports = { module.exports = {
rustVersion: '1.59', rustVersion: "1.59",
actixWebMajorVersion: '4', actixWebMajorVersion: "4",
tokioMajorVersion: '1', tokioMajorVersion: "1",
}; };