Skip to content

Commit d96e972

Browse files
ElianCodesdelucis
andauthored
Upgrade docs site to Astro v3 (withastro#4461)
Co-authored-by: Chris Swithinbank <[email protected]>
1 parent 71eea69 commit d96e972

39 files changed

+1441
-793
lines changed

.github/workflows/ci.yml

-12
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ jobs:
3030

3131
- name: Run Check
3232
run: pnpm run check
33-
tsc:
34-
name: Check for type issues with tsc
35-
runs-on: ubuntu-latest
36-
steps:
37-
- name: Checkout
38-
uses: actions/checkout@v3
39-
40-
- name: Install Tools & Dependencies
41-
uses: ./.github/actions/install
42-
43-
- name: Run Check
44-
run: pnpm run tsc
4533
eslint:
4634
name: Check for code issues with ESLint
4735
runs-on: ubuntu-latest

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ tasks:
22
- init: pnpm install
33
command: pnpm run dev
44
ports:
5-
- port: 3000
5+
- port: 4321
66
onOpen: open-browser

astro.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export default defineConfig({
2929
astroDocsExpressiveCode(),
3030
mdx(),
3131
],
32+
scopedStyleStrategy: 'where',
33+
compressHTML: false,
3234
markdown: {
3335
// Override with our own config
3436
smartypants: false,

contributor-guides/writing-and-style-guide.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ All readers can benefit from clear, straightforward writing, but this can be par
1414
- have cognitive, learning or attention difficulties.
1515
- come from a non-traditional development background.
1616

17-
We aim for **clear** and **helpful** documentation that serves the reader above all else!
17+
We aim for **clear** and **helpful** documentation that serves the reader above all else!
1818

1919
Usually this means choosing:
2020

@@ -59,7 +59,7 @@ Whenever possible, give the reader a direct instruction:
5959

6060
e.g. Type the command...
6161

62-
Do not use _"Let's..."_ or _"Next, we will..."_. You are not sitting there with your reader! (This also means you will never need the words _we_, _us_, and _our_. If you see them, rephrase!)
62+
Do not use *"Let's..."* or *"Next, we will..."*. You are not sitting there with your reader! (This also means you will never need the words *we*, *us*, and *our*. If you see them, rephrase!)
6363

6464
If you must address the reader, it is OK to use "you" and "your". Especially for emphasis in very important steps where something could go wrong:
6565

@@ -85,12 +85,11 @@ Here is an example edit we made to one of our own recipes to illustrate the diff
8585
> 1.
8686
> 2. ...
8787
88-
8988
### Opinionated Instructions
9089

91-
Sometimes you will need to give an instruction where the reader has options. You want to illustrate the example with the specific choice you made, but you also want to make it clear that other decisions are acceptable.
90+
Sometimes you will need to give an instruction where the reader has options. You want to illustrate the example with the specific choice you made, but you also want to make it clear that other decisions are acceptable.
9291

93-
In this case, try to separate the instruction from the opinion. First, give the action to take with a more general description. Then state the opinionated choice that your example uses. Your reader will be able to first process what you are doing and then will see the choice you have made. They can still follow your instruction, making a choice that works for their own project.
92+
In this case, try to separate the instruction from the opinion. First, give the action to take with a more general description. Then state the opinionated choice that your example uses. Your reader will be able to first process what you are doing and then will see the choice you have made. They can still follow your instruction, making a choice that works for their own project.
9493

9594
This can be easier to follow (and perhaps more reassuring!) than a statement that gives multiple options. This is also usually easier to write since you do not have to remind the reader that this file is from *your* example, and may not appear in their project.
9695

@@ -105,7 +104,6 @@ This can be easier to follow (and perhaps more reassuring!) than a statement tha
105104
106105
<!--
107106
108-
109107
-->
110108

111109
## Custom Components
@@ -161,7 +159,7 @@ By default, the badge uses a muted colour scheme to blend in. It also has an acc
161159

162160
### Since Component
163161

164-
As features are added to Astro, it can be helpful to document _when_ they were added. This allows users to easily see if the version of Astro (or other packages) they are running supports a specific feature as described in the docs.
162+
As features are added to Astro, it can be helpful to document *when* they were added. This allows users to easily see if the version of Astro (or other packages) they are running supports a specific feature as described in the docs.
165163

166164
You can use the `<Since />` component to display this information in a standardized way.
167165

@@ -277,28 +275,29 @@ Inside `MyCustomTabs.jsx`, import the Tabs component and create one `<Tabs>` com
277275
---
278276
import Tabs from './Tabs';
279277
---
280-
<Tabs client:visible sharedStore="my-shared-store">
278+
<Tabs client:idle sharedStore="my-shared-store">
281279
</Tabs>
282280
```
281+
283282
To create your custom tab component, follow the pattern below using a `<Fragment>` with a named slot for each tab and panel to be created. Note that you must define your tab names here (e.g. Preact, React, Solid, Svelte, Vue), but the content for each panel will be written when your custom component is imported and used in a Markdown page, as in the previous `<PackageManagerTabs>` example.
284283

285284
```jsx
286285
---
287286
import Tabs from './Tabs';
288287
---
289288

290-
<Tabs client:visible sharedStore="ui-frameworks">
291-
<Fragment slot="tab.preact">Preact</Fragment>
292-
<Fragment slot="tab.react">React</Fragment>
293-
<Fragment slot="tab.solid">Solid</Fragment>
294-
<Fragment slot="tab.svelte">Svelte</Fragment>
295-
<Fragment slot="tab.vue">Vue</Fragment>
296-
297-
<Fragment slot="panel.preact"><slot name="preact" /></Fragment>
298-
<Fragment slot="panel.react"><slot name="react" /></Fragment>
299-
<Fragment slot="panel.solid"><slot name="solid" /></Fragment>
300-
<Fragment slot="panel.svelte"><slot name="svelte" /></Fragment>
301-
<Fragment slot="panel.vue"><slot name="vue" /></Fragment>
289+
<Tabs client:idle sharedStore="ui-frameworks">
290+
<Fragment slot="tab.preact">Preact</Fragment>
291+
<Fragment slot="tab.react">React</Fragment>
292+
<Fragment slot="tab.solid">Solid</Fragment>
293+
<Fragment slot="tab.svelte">Svelte</Fragment>
294+
<Fragment slot="tab.vue">Vue</Fragment>
295+
296+
<Fragment slot="panel.preact"><slot name="preact" /></Fragment>
297+
<Fragment slot="panel.react"><slot name="react" /></Fragment>
298+
<Fragment slot="panel.solid"><slot name="solid" /></Fragment>
299+
<Fragment slot="panel.svelte"><slot name="svelte" /></Fragment>
300+
<Fragment slot="panel.vue"><slot name="vue" /></Fragment>
302301
</Tabs>
303302
```
304303

@@ -318,7 +317,7 @@ import RecipeLinks from "~/components/RecipeLinks.astro";
318317

319318
## Lists vs. Headings
320319

321-
Both lists and headings are used in our docs for readability. We will often start by using `<ul>` to list related items.
320+
Both lists and headings are used in our docs for readability. We will often start by using `<ul>` to list related items.
322321

323322
But, when individual line items become large, span multiple paragraphs, or contain too many `<code>` terms affecting readability, then we will change to section headings.
324323

@@ -339,33 +338,36 @@ Do use headings to break up text into organized sections! Many readers prefer to
339338
## Examples (e.g. examples)
340339

341340
Current practice is to use the words "for example" in full within the text of a sentence, but (e.g. Netlify, Vercel) inside a parenthetical so as to not take the reader out of the flow the sentence.
342-
343-
> For example, when passing props . . .
344341

345-
> If you store your Astro project in an online Git provider (e.g. GitHub, GitLab), you can . . .
342+
> For example, when passing props . . .
343+
344+
> If you store your Astro project in an online Git provider (e.g. GitHub, GitLab), you can . . .
346345
347346
## Code Samples
348347

349-
We take great pride in our code samples, but they require a little extra work to write!
348+
We take great pride in our code samples, but they require a little extra work to write!
350349

351350
Don't worry! We'll help you out in a PR if your code authoring needs some adjustment before merging. But, you can make use of all our features below and preview them locally to make sure your code looks the way you want.
352351

353352
If you are **editing existing code samples**, then please make sure to preview your updated code sample! Update any necessary syntax such as line highlighting or title (file name).
354353

355-
If you are **adding new code samples**, you have the option of adding a file name (usually recommended!) to be displayed as a title. You can also highlight individual words, phrases, or entire lines in regular or "diff" (red/green) style.
354+
If you are **adding new code samples**, you have the option of adding a file name (usually recommended!) to be displayed as a title. You can also highlight individual words, phrases, or entire lines in regular or "diff" (red/green) style.
356355

357356
**All extra code styling is written on the opening line of the code block, immediately after the language.**
358357

359358
Here are two examples of what our code snippets look like written in Markdown, just so you can see what it looks like in action. Syntax explanations follow.
360359

361-
#### Example 1
360+
#### Example 1
361+
362362
- Use the file name as a title
363363
- highlight rows 9 and 10
364+
364365
``````markdown
365366
```astro title="src/pages/nested-components.astro" {9-10}
366367
``````
367368

368-
#### Example 2
369+
#### Example 2
370+
369371
- use the file name as a title (alt method)
370372
- apply "+ diff" styling (green backround) to any occurrence of `<Button />`
371373
- highlight any occurrence of `{props.title}` and `{props.social}`
@@ -379,9 +381,10 @@ Here are two examples of what our code snippets look like written in Markdown, j
379381

380382
Most code should include a sample file name so that we give the reader not only copy-pastable code, but also provide the file into which that code should be pasted.
381383

382-
`title="src/pages/index.astro"`
384+
`title="src/pages/index.astro"`
383385

384386
Alternatively, write the file name as a code comment in a separate line. Write the file name of `.astro` files immediately after the opening `---`
387+
385388
``````markdown
386389
```astro
387390
---
@@ -403,7 +406,6 @@ Use Curly braces to highlight (default), or show "diff" style (+/-) "inserted" o
403406
- del={2} - Shows "diff" style (-) at line 2
404407
- ins={7-9} - Shows "diff" style (+) lines 7-9
405408

406-
407409
### Text Highlighting
408410

409411
Use quotation marks to highlight (default), or assign red/green "diff" style background colors for individual words and phrases.
@@ -419,14 +421,12 @@ Regular expressions are supported within slashes `/ /`. See a handy [tool for co
419421
- /{frontmatter.(title|description)}/ - Highlight all instances of `{frontmatter.title}` and `{frontmatter.description}`
420422

421423
> ***Note***
424+
>
422425
> - del="<p class=\"hi\">" - Use `\` to escape quotation marks and other special characters in the search string
423426
>
424427
>- del='\<p class="hi">' - Use single quotes to make it easier to match double quotes
425428
426-
427-
428-
429-
### Don't destructure props
429+
### Don't destructure props
430430

431431
The following prop syntax is relevant to all component frameworks we support:
432432

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"test": "vitest",
1010
"preview": "astro preview",
1111
"check": "astro check",
12-
"tsc": "astro sync && tsc",
1312
"format": "pnpm run format:code",
1413
"format:ci": "pnpm run format:imports && pnpm run format:code",
1514
"format:code": "prettier -w . --cache --plugin-search-dir=.",
@@ -31,9 +30,9 @@
3130
"devDependencies": {
3231
"@11ty/eleventy-fetch": "^3.0.0",
3332
"@actions/core": "^1.9.0",
34-
"@astrojs/mdx": "^0.19.7",
35-
"@astrojs/preact": "^2.2.1",
36-
"@astrojs/sitemap": "1.0.1",
33+
"@astrojs/mdx": "^1.0.0",
34+
"@astrojs/preact": "^3.0.0",
35+
"@astrojs/sitemap": "3.0.0",
3736
"@babel/core": "^7.18.10",
3837
"@docsearch/css": "^3.5.1",
3938
"@docsearch/react": "^3.5.1",
@@ -44,11 +43,11 @@
4443
"@types/node": "^18.6.4",
4544
"@typescript-eslint/eslint-plugin": "^5.46.1",
4645
"@typescript-eslint/parser": "^5.46.1",
47-
"astro": "^2.8.0",
48-
"astro-auto-import": "^0.2.1",
46+
"astro": "^3.0.8",
47+
"astro-auto-import": "^0.3.1",
4948
"astro-eslint-parser": "^0.9.2",
5049
"astro-expressive-code": "^0.20.0",
51-
"astro-og-canvas": "^0.1.7",
50+
"astro-og-canvas": "^0.2.1",
5251
"bcp-47-normalize": "^2.1.0",
5352
"canvaskit-wasm": "^0.37.0",
5453
"dedent-js": "^1.0.1",
@@ -92,6 +91,7 @@
9291
"vitest": "^0.28.5"
9392
},
9493
"dependencies": {
94+
"@astrojs/check": "^0.2.0",
9595
"@fontsource/ibm-plex-mono": "^4.5.10",
9696
"@nanostores/preact": "^0.1.3",
9797
"canvas-confetti": "^1.6.0",

0 commit comments

Comments
 (0)