Skip to content

Commit fbeab0d

Browse files
mueschaLekoArts
andauthored
chore(docs): routing - brand name, code language, code block (#28929)
Co-authored-by: Lennart <[email protected]>
1 parent e8e2410 commit fbeab0d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/docs/reference/routing/file-system-route-api.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To use the File System Route API, use curly braces (`{ }`) in your filenames to
2323
- `src/pages/products/{Product.fields__sku}.js` will generate a route like `/products/001923`
2424
- `src/pages/blog/{MarkdownRemark.parent__(File)__name}.js` will generate a route like `/blog/learning-gatsby`
2525

26-
At build time, Gatsby uses the content within the curly braces to generate GraphQL queries to retrieve the nodes that should be built for a given collection (collection here refers to all nodes of a given type, e.g. all markdown files for `MarkdownRemark`). Gatsby then runs those queries to grab all the nodes and create a page for each of them. Gatsby also adds an `id` field to every query automatically, to simplify integration with page queries.
26+
At build time, Gatsby uses the content within the curly braces to generate GraphQL queries to retrieve the nodes that should be built for a given collection (collection here refers to all nodes of a given type, e.g. all Markdown files for `MarkdownRemark`). Gatsby then runs those queries to grab all the nodes and create a page for each of them. Gatsby also adds an `id` field to every query automatically, to simplify integration with page queries.
2727

2828
### Syntax (collection routes)
2929

@@ -112,7 +112,7 @@ Naming your file with the File System Route API will generate routes for each no
112112

113113
For example, in the component itself (e.g. `src/pages/products/{Product.name}.js`) you're able to access the `name` via `props.params` and as a variable in the GraphQL query (as `$name`). However, we recommend filtering by `id` as this is the fastest way to filter.
114114

115-
```jsx:title=src/pages/products/{Product.name}.js
115+
```js:title=src/pages/products/{Product.name}.js
116116
import React from "react"
117117
import { graphql } from "gatsby"
118118

@@ -135,11 +135,11 @@ export const query = graphql`
135135
`
136136
```
137137

138-
If you need to customize the query used for collecting the nodes (e.g. filtering out any product of type "Food"), you should use the [`createPages`](/docs/reference/config-files/gatsby-node#createPages) API instead as File System Route API doesn't support this at the moment.
138+
If you need to customize the query used for collecting the nodes (e.g. filtering out any product of type `"Food"`), you should use the [`createPages`](/docs/reference/config-files/gatsby-node#createPages) API instead as File System Route API doesn't support this at the moment.
139139

140140
### Routing and linking
141141

142-
Gatsby "slugifies" every route that gets created from collection pages (by using [sindresorhus/slugify](https://github.com/sindresorhus/slugify)). Or in other words: If you have a route called `src/pages/wholesome/{Animal.slogan}.js` where `slogan` is `I ♥ Dogs` the final URL will be `/wholesome/i-love-dogs`. Gatsby will convert the field into a human-readable URL format while stripping it of invalid characters.
142+
Gatsby "slugifies" every route that gets created from collection pages (by using [`sindresorhus/slugify`](https://github.com/sindresorhus/slugify)). Or in other words: If you have a route called `src/pages/wholesome/{Animal.slogan}.js` where `slogan` is `I ♥ Dogs` the final URL will be `/wholesome/i-love-dogs`. Gatsby will convert the field into a human-readable URL format while stripping it of invalid characters.
143143

144144
When you want to link to one of those pages, it may not always be clear how to construct the URL from scratch.
145145

@@ -161,7 +161,7 @@ Assume that a `Product` type is used in two pages:
161161

162162
If you wanted to link to the `products/{Product.name}` and `discounts/{Product.name}` routes from your home page, you would have a component like this:
163163

164-
```jsx:title=src/pages/index.js
164+
```js:title=src/pages/index.js
165165
import React from "react"
166166
import { Link, graphql } from "gatsby"
167167

0 commit comments

Comments
 (0)