Skip to content

Commit 48671ac

Browse files
authored
fix(docs): #3827 link ref to other doc pages is incorrect (#3830)
1 parent bc104f7 commit 48671ac

File tree

8 files changed

+33
-25
lines changed

8 files changed

+33
-25
lines changed

.github/workflows/benchmark.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ on:
55
push:
66
branches: [main]
77

8-
permissions:
9-
# deployments permission to deploy GitHub pages website
10-
deployments: write
11-
# contents permission to update benchmark contents in gh-pages branch
12-
contents: write
13-
148
jobs:
159
benchmark:
1610
runs-on: ubuntu-latest
@@ -37,7 +31,13 @@ jobs:
3731
npm --version
3832
yarn --version
3933
yarn install --frozen-lockfile
40-
yarn build
34+
yarn build:benchmark
35+
36+
- name: Download previous benchmark data
37+
uses: actions/cache@v3
38+
with:
39+
path: ./benchmark-cache
40+
key: ${{ runner.os }}-benchmark
4141

4242
- name: Run benchmark
4343
run: yarn benchmark
@@ -46,6 +46,7 @@ jobs:
4646
uses: benchmark-action/github-action-benchmark@v1
4747
with:
4848
tool: benchmarkjs
49+
external-data-json-path: ./benchmark-cache/benchmark-data.json
4950
output-file-path: output.txt
5051
# comment for PRs that's updated with current perf relative to baseline (main)
5152
summary-always: true
@@ -55,7 +56,5 @@ jobs:
5556
fail-on-alert: true
5657
# if things get considerably slower, deny the PR
5758
fail-threshold: 120%
58-
# needed for pushing historical results to gh-pages & commenting on PRs
59+
# needed for commenting on PRs
5960
github-token: ${{ secrets.GITHUB_TOKEN }}
60-
# creates a gh-pages deployment with historical benchmarking data
61-
auto-push: true

docs/api/field.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ There are a few different ways to render things with `<Field>`.
2020

2121
`children` can either be an array of elements (e.g. `<option>` in the case of `<Field as="select">`) or a callback function (a.k.a render prop). The render props are an object containing:
2222

23-
- `field`: An object containing `onChange`, `onBlur`, `name`, and `value` of the field (see [`FieldInputProps`](./useField#fieldinputprops))
23+
- `field`: An object containing `onChange`, `onBlur`, `name`, and `value` of the field (see [`FieldInputProps`](./useField#fieldinputpropsvalue))
2424
- `form`: The Formik bag
25-
- `meta`: An object containing metadata (i.e. `value`, `touched`, `error`, and `initialValue`) about the field (see [`FieldMetaProps`](./useField#fieldmetaprops))
25+
- `meta`: An object containing metadata (i.e. `value`, `touched`, `error`, and `initialValue`) about the field (see [`FieldMetaProps`](./useField#fieldmetapropsvalue))
2626

2727
`component` can either be a React component or the name of an HTML element to render. All additional props will be passed through.
2828

docs/api/fieldarray.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const FriendList = () => (
6767

6868
### `name: string`
6969

70-
The name or path to the relevant key in [`values`](./formik.md#values-field-string-any).
70+
The name or path to the relevant key in [`values`](./formik#values--field-string-any-).
7171

7272
### `validateOnChange?: boolean`
7373

docs/api/formik.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ to `<button onClick={handleReset}>...</button>`
9393

9494
#### `handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void`
9595

96-
Submit handler. This should be passed to `<form onSubmit={props.handleSubmit}>...</form>`. To learn more about the submission process, see [Form Submission](../docs/guides/form-submission.md).
96+
Submit handler. This should be passed to `<form onSubmit={props.handleSubmit}>...</form>`. To learn more about the submission process, see [Form Submission](../guides/form-submission.md).
9797

9898
#### `isSubmitting: boolean`
9999

100-
Submitting state of the form. Returns `true` if submission is in progress and `false` otherwise. IMPORTANT: Formik will set this to `true` as soon as submission is _attempted_. To learn more about the submission process, see [Form Submission](../docs/guides/form-submission.md).
100+
Submitting state of the form. Returns `true` if submission is in progress and `false` otherwise. IMPORTANT: Formik will set this to `true` as soon as submission is _attempted_. To learn more about the submission process, see [Form Submission](../guides/form-submission.md).
101101

102102
#### `isValid: boolean`
103103

@@ -107,7 +107,7 @@ Returns `true` if there are no `errors` (i.e. the `errors` object is empty) and
107107
108108
#### `isValidating: boolean`
109109

110-
Returns `true` if Formik is running validation during submission, or by calling [`validateForm`] directly `false` otherwise. To learn more about what happens with `isValidating` during the submission process, see [Form Submission](../docs/guides/form-submission.md).
110+
Returns `true` if Formik is running validation during submission, or by calling [`validateForm`] directly `false` otherwise. To learn more about what happens with `isValidating` during the submission process, see [Form Submission](../guides/form-submission.md).
111111

112112
#### `resetForm: (nextState?: Partial<FormikState<Values>>) => void`
113113

@@ -188,8 +188,8 @@ Trigger a form submission. The promise will be rejected if form is invalid.
188188

189189
#### `submitCount: number`
190190

191-
Number of times user tried to submit the form. Increases when [`handleSubmit`](#handlesubmit-e-reactformevent-htmlformelement-void) is called, resets after calling
192-
[`handleReset`](#handlereset-void). `submitCount` is readonly computed property and should not be mutated directly.
191+
Number of times user tried to submit the form. Increases when [`handleSubmit`](#handlesubmit-e-reactformeventhtmlformelement--void) is called, resets after calling
192+
[`handleReset`](#handlereset---void). `submitCount` is readonly computed property and should not be mutated directly.
193193

194194
#### `setFieldValue: (field: string, value: any, shouldValidate?: boolean) => Promise<void | FormikErrors>`
195195

@@ -206,7 +206,7 @@ use it to pass API responses back into your component in `handleSubmit`.
206206

207207
#### `setSubmitting: (isSubmitting: boolean) => void`
208208

209-
Set `isSubmitting` imperatively. You would call it with `setSubmitting(false)` in your `onSubmit` handler to finish the cycle. To learn more about the submission process, see [Form Submission](../docs/guides/form-submission.md).
209+
Set `isSubmitting` imperatively. You would call it with `setSubmitting(false)` in your `onSubmit` handler to finish the cycle. To learn more about the submission process, see [Form Submission](../guides/form-submission.md).
210210

211211
#### `setTouched: (fields: { [field: string]: boolean }, shouldValidate?: boolean) => void`
212212

@@ -223,7 +223,7 @@ otherwise be expressed/stored with other methods. This is useful for capturing
223223
and passing through API responses to your inner component.
224224

225225
`status` should only be modified by calling
226-
[`setStatus`](#setstatus-status-any-void).
226+
[`setStatus`](#setstatus-status-any--void).
227227

228228
#### `touched: { [field: string]: boolean }`
229229

docs/api/useField.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function MyOtherComponent(props) {
128128
This object is a subset of the props that you would pass to `<Field>`. It contains:
129129

130130
- `name: string` - The name of the field
131-
- `validate?: (value: any) => undefined | string | Promise<any>` - See [the documentation for `<Field>`](../field#validate)
131+
- `validate?: (value: any) => undefined | string | Promise<any>` - See [the documentation for `<Field>`](./field#validate)
132132
- `type?: string` - The type of the HTML input (`text`, `number` and etc.)
133133
- `multiple?: boolean` - Whether or not the multiple values can be selected.
134134
- `value?: string`- Works only for inputs of type `checkbox` and `radio`. When a form is submitted, checkboxes and radios are submitted with the provided `value`. Read more about it on [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Value).

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"dev": "turbo run start",
3232
"test": "turbo run test --filter='./packages/*' --",
3333
"build": "turbo run build",
34+
"build:benchmark": "yarn build --filter=formik",
3435
"build:codesandbox": "yarn build --filter='./packages/*'",
3536
"prepublish": "turbo run build --filter='./packages/*'",
3637
"format": "prettier --write 'examples/**/*' 'packages/*/src/**/*' 'website/src/**/*.{ts,tsx,js,jsx,md,mdx}' 'app/pages/**/*' 'packages/*/test/**/*' 'README.md'",

website/src/lib/docs/rehype-docs.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function removeExt(path) {
1313
const basePath = path.split(/#|\?/)[0];
1414
const i = basePath.lastIndexOf('.');
1515

16-
if (i === -1) return path;
16+
if (i === -1 || i === 0) return path;
1717
return basePath.substring(0, i) + path.substring(basePath.length);
1818
}
1919

@@ -50,7 +50,7 @@ export default function rehypeDocs({ filePath, tag }) {
5050
const slugger = new GithubSlugger();
5151
const anchorSlugger = new GithubSlugger();
5252
// Don't use the custom tag here, relative URLs to repo files should always go to canary
53-
const blobUrl = `${GITHUB_URL}/${REPO_NAME}/blob/master`;
53+
const blobUrl = `${GITHUB_URL}/${REPO_NAME}/blob/main`;
5454

5555
function visitAnchor(node) {
5656
const props = node.properties;
@@ -96,8 +96,16 @@ export default function rehypeDocs({ filePath, tag }) {
9696
props.href = hash
9797
? `${relativePath}#${anchorSlugger.slug(hash)}`
9898
: relativePath;
99-
// Relative URL for another documentation route
99+
100+
//turn URL to absolute path for correct doc route
100101
if (isDocs) {
102+
let absolutePath = resolve(filePath, relativePath);
103+
// Reset the slugger because single pages can have multiple urls to the same hash
104+
anchorSlugger.reset();
105+
props.href = hash
106+
? `${absolutePath}#${anchorSlugger.slug(hash)}`
107+
: absolutePath;
108+
props.className = 'absolute-link';
101109
props.href = removeExt(
102110
tag ? props.href.replace('/docs', `/docs/tag/${tag}`) : props.href
103111
);

website/src/siteConfig.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// List of projects/orgs using your project for the users page.
22

33
export const siteConfig = {
4-
editUrl: 'https://github.com/formik/formik/edit/master',
4+
editUrl: 'https://github.com/formik/formik/edit/main',
55
copyright: `Copyright © ${new Date().getFullYear()} Jared Palmer. All Rights Reserved.`,
66
repoUrl: 'https://github.com/formik/formik',
77
discordUrl: 'https://discord.com/invite/pJSg287',

0 commit comments

Comments
 (0)