Commit graph

8 commits

Author SHA1 Message Date
Steven
4466ba436b
chore(examples): use default prettier for examples/templates (#60530)
## Description
This PR ensures that the default prettier config is used for examples
and templates.

This config is compatible with `prettier@3` as well (upgrading prettier
is bigger change that can be a future PR).

## Changes
- Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will
be needed upgrading to prettier@3)
- Added `examples/.prettierrc.json` with default config (this will
change every example)
- Added `packages/create-next-app/templates/.prettierrc.json` with
default config (this will change every template)

## Related

- Fixes #54402
- Closes #54409
2024-01-11 16:01:44 -07:00
Henrik Wenz
7f9fe8ca30
chore: Refactor active-class-name example (#40670)
## Changes

- Migrated missing file to typescript

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2022-09-19 11:23:42 -07:00
Max Proske
3a22c4c554
Convert active-class-name example to TypeScript (#37676)
The Contributing guidelines say TypeScript should be leveraged for new examples, so I thought I'd convert this example over. 

I also:
- Upgraded all dependencies
- Replaced the `prop-types` package with TypeScript types

## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-14 08:49:09 +00:00
xhoantran
a38e144099
Update examples/active-class-name (#34205)
## Description

According to `Next.js` useRouter documentation:

- `asPath`: The path (including the query) shown in the browser without the configured basePath or locale.
- `pathname`: Current route. That is the path of the page in /pages, the configured basePath or locale is not included.

`asPath` should not be used as the props of components. There are many cases that `asPath` not working as expected. For example:

- `asPath` is different on server-side and client-side.
- `asPath` can contains `id` and `query`.

## Suggestion

- Warning the use of `asPath` can lead to the conflict of client and server-side.
- Update `useRouter` document.

## Bug

- [x] Related issues linked using `fixes #number`

Fixes: https://github.com/vercel/next.js/issues/34144
Fixes: https://github.com/vercel/next.js/issues/34016
Fixes: https://github.com/vercel/next.js/issues/34197
2022-02-11 00:51:56 +00:00
Aubrey
7d8e0c512f
updated active-class-name example to also demo a [slug] path (#15924)
updated example for [active-class-name](f00ad581a1/examples/active-class-name) to also support a `[slug].js` page that matches on `as` instead of `href` (as `href` would be `/[slug]`)

> This does not demo `[..slug].js` as this requires possible custom code for determining the slug path part for the active classname. i.e. page tree active nodes. A possible other example or another PR on this example.

Has possible information for:
 * https://github.com/vercel/next.js/issues/7410
2020-08-06 01:26:48 +00:00
Henrik Wenz
ce25f747e7 Refactor active-class-name example (#8558)
- use router hook instead of hoc
- simplify ActiveLink component
- add prop-types
- add function names
- use fragments instead of divs
2019-08-29 12:22:42 -04:00
Tim Neutkens
c8059b9f12 Make sure linting passes 2017-10-31 08:58:00 +01:00
Remy Sharp
4c18678d54 Create example of activeClassLink using withRouter (#3188) 2017-10-30 15:24:31 +01:00