diff --git a/src/components/QuickStart/index.jsx b/src/components/QuickStart/index.jsx index 670fc710..489be011 100644 --- a/src/components/QuickStart/index.jsx +++ b/src/components/QuickStart/index.jsx @@ -1,9 +1,10 @@ import React from 'react' import Tabs from '@theme/Tabs' import TabItem from '@theme/TabItem' -import CodeBlock from '@theme/CodeBlock' import Link from '@docusaurus/Link' import Heading from '@theme/Heading' +import CodeBlock from '@theme/CodeBlock' +import styles from './styles.module.css' export default function QuickStart() { const esm = `// Import the framework and instantiate it @@ -169,24 +170,36 @@ start()` Quick start

Get Fastify with NPM:

- npm install fastify +
+ npm install fastify +

Then create server.js and add the following content:

- - - {esm} - - - {cjs} - - +
+ + + + {esm} + + + + + {cjs} + + + +

Finally, launch the server with:

- node server +
+ node server +

and test it with:

- curl http://localhost:3000 +
+ curl http://localhost:3000 +
Using CLI

@@ -197,29 +210,35 @@ start()` to create a new scaffolding project:

- - npm install --global fastify-cli -
- fastify generate myproject -
+
+ {`npm install --global fastify-cli\n\nfastify generate myproject`} +

Or to create a TypeScript project:

- fastify generate myproject --lang=ts +
+ fastify generate myproject --lang=ts +
Request/Response validation and hooks

Fastify can do much more than this. For example, you can easily provide input and output validation using JSON Schema and perform specific operations before the handler is executed:

- - - {exampleRequestResponseEsm} - - - {exampleRequestResponseCjs} - - +
+ + + + {exampleRequestResponseEsm} + + + + + {exampleRequestResponseCjs} + + + +
TypeScript Support

@@ -239,11 +258,15 @@ start()` This ensures within the server handler we also get http.ServerResponse with correct typings on{' '} reply.res.

- - - {typescript} - - +
+ + + + {typescript} + + + +

Visit the Documentation to learn more about all the features that Fastify has to offer. diff --git a/src/components/QuickStart/styles.module.css b/src/components/QuickStart/styles.module.css new file mode 100644 index 00000000..09ca0d64 --- /dev/null +++ b/src/components/QuickStart/styles.module.css @@ -0,0 +1,90 @@ +.qsCodeblock { + border: 0.5px solid #2d3040; + border-radius: 12px; + overflow: hidden; + margin: 8px 0; + background: #16181d; +} + +.qsCodeblock > div, +.qsCodeblock [class*='tabItem'], +.qsCodeblock [role='tabpanel'], +.qsCodeblock [class*='codeBlockContainer'], +.qsCodeblock [class*='codeBlockContent'] pre { + margin: 0; + padding-top: 0; + padding-bottom: 0; +} + +.qsCodeblock [class*='tabList__'] { + background: #1c1f28 !important; + border-bottom: 0.5px solid #2d3040 !important; + border-radius: 0 !important; + margin: 0 !important; + padding: 0 !important; + gap: 0 !important; +} + +.qsCodeblock [class*='tabList__'] [aria-selected='true'] { + font-size: 13px !important; + font-weight: 500 !important; + color: #25c2a0 !important; + background: none !important; + margin: 10px 0 0 !important; + border: none !important; + text-transform: uppercase; +} + +.qsCodeblock [class*='tabList__'] [aria-selected='false'] { + font-size: 13px !important; + font-weight: 500 !important; + border-bottom: 2px solid transparent !important; + color: #6c7086 !important; + background: none !important; + margin: 10px 0 0 !important; + text-transform: uppercase; +} + +.qsCodeblock [role='tabpanel'] { + padding: 0; + margin: 0; +} + +.qsCodeblock [class*='codeBlockContainer'] { + border-radius: 0 !important; + border: none !important; + box-shadow: none !important; + margin: 0; + background: #16181d !important; +} + +.qsCodeblock [class*='codeBlockContent'] { + background: #16181d !important; +} + +.qsCodeblock [class*='codeBlockContent'] pre { + background: #16181d !important; + margin: 0; +} + +.qsCodeblock [class*='codeBlockTitle'] { + background: #1c1f28 !important; + border-bottom: 0.5px solid #2d3040 !important; + border-radius: 0 !important; + color: #25c2a0 !important; + font-size: 11px !important; + font-weight: 500 !important; + letter-spacing: 0.07em !important; + text-transform: uppercase !important; + padding: 8px 16px !important; + margin: 0 !important; +} + +.qsCodeblock [class*='copyButton'] { + color: #25c2a0 !important; +} + +.qsCodeblock [class*='copyButton']:hover { + color: #25c2a0bb !important; + background: transparent !important; +} diff --git a/src/theme/CodeBlock/index.js b/src/theme/CodeBlock/index.js new file mode 100644 index 00000000..7da6d8fe --- /dev/null +++ b/src/theme/CodeBlock/index.js @@ -0,0 +1,8 @@ +import React from 'react' +import OriginalCodeBlock from '@docusaurus/theme-classic/lib/theme/CodeBlock/index.js' + +export default function CodeBlock({ language, title, noTitle, ...props }) { + const resolvedTitle = noTitle ? undefined : (title ?? language) + + return +}