Skip to content

Commit

Permalink
Docs for v2.0 (#325)
Browse files Browse the repository at this point in the history
* Empty commit for v2 branch

* docs: optimisticData can accept a function in v2 (#333)

* docs: add mutate filter functions documentation in v2 (#340)

* Empty commit for v2 branch

* docs: add mutate filter functions documentation in v2

* remove the usage of cache.clear() and use mutate instead

* docs: add preload API documentation in v2 (#336)

* Empty commit for v2 branch

* docs: add preload API documentation in v2

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Update pages/docs/prefetching.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: add DevTools page in v2 (#337)

* Empty commit for v2 branch

* docs: add DevTools documentation in v2

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: SWRConfig value as a function (#335)

* Empty commit for v2 branch

* docs: Nesting configurations with SWRConfig

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Update pages/docs/global-configuration.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Fetcher no longer accepts multiple arguments in v2 (#326)

* Fetcher no longer accepts multiple arguments in v2

* Empty commit for v2 branch

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Update pages/docs/arguments.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: add an example for preload in effect (#345)

* docs: add an example for preload in effects

* Update pages/docs/prefetching.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* merge examples for inside React

* Update pages/docs/prefetching.en-US.md

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply a suggestion

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: add isLoading and keepPreviousData pages in v2 (#343)

* docs: add the Return Values page

* docs: add isLoading and keepPreviousData option

* docs: fix header levels

* docs: add a video for keepPreviousData

* docs: move arguments page to next to return values page

* docs: update diagrams for returning values

* docs: update the performance document to add isLoading

* docs: keep the list of return values in the options document

* use isLoading instead of !data

* translate options.md into Japanese

* docs: add a detail link for keepPreviousData

* tweak the description of isLoading

* revert to move the arguments page

* move the return values page into the advanced section

* rename the Options page to API Options

* fix links to the return values

* fix a typo

* add an excalidraw file for the state machine diagrams

* rename the page from Return Values to Understanding SWR

* rename the Options page to API

* translate Understanding SWR into Japanese

* tweak

* change /docs/options links to /docs/api

* Update pages/docs/advanced/meta.en-US.json

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* change the link of Understanding SWR

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* add documentations for useSWRMutation (#348)

* reorganize the mutation page for useSWRMutation

* write paramters and return values sections for mutation

* docs: add examples of useSWRMutation

* add an exmple to use useSWRMutation for loading data

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* docs: add notes for Suspense on SSR and React v18 in SWR v2 (#334)

* Empty commit for v2 branch

* docs: add notes for Suspense on SSR and React v18

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply suggestions to other languages

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* update other language

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* sync and refine mutate page (#350)

* sync the mutation page of other languages

* move the return values section of mutate into the API section

* Note for the shape of keys in mutate filter functions (#353)

add a note for the shape of keys in mutate filter functions

* make explicit the location of mutate (#354)

* explicit the location of mutate

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* apply feedback to other languages

* add more descriptiong to mutation

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* v2 blog post (#351)

* add the v2 blog page

* update the description

* add the migration guide section

* write more section for what's new

* write changes of highlights

* add demo videos in the v2 blog and links to the CodeSandbox

* tweak

* add braking changes for mutate multiple items

* update description

* add isMutating into the example for useSWRMutation

* Apply suggestions from code review

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* Update pages/blog/swr-v2.en-US.mdx

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* move the details of isLoading and isValidating to the Userstanding SWR page

* tweak wording

* add authors

* add og image

Co-authored-by: Jiachi Liu <inbox@huozhi.im>

* use link for codesandbox example (#355)

* sync translations (#356)

* sync the translation docs

* fix Author's link

* remove copy from a file name

* fix: typos in v2 docs (#357)

* fix: the hook name of useSWRMutation example

* fix: optimisticData examples

* Add onDiscarded option (#371)

add onDiscarded option

* V2 docs improvements (#361)

* blog improvements

* update

* update blog post

* update mutation

* update

* docs: change the build target in the v2 blogdocs:  (#381)

docs: change the build target in the v2 blog

* Add functional rollbackOnError description (#377)

* Add functional rollbackOnError description

* fix typo

* docs: translate v2 blog into Japanese (#383)

* docs: translate v2 updates in Japanese (#384)

* docs: translate v2 updates into Japanese

* tweak

* Fix case for section title (#387)

* Update card and description for the v2 blog post (#388)

update card and description

* Rename laggy ui to preserving previous state (#389)

* Rename laggy ui to preserving previous state

* fix

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Shu Ding <g@shud.in>
  • Loading branch information
3 people committed Dec 9, 2022
1 parent 57991d1 commit efea2b0
Show file tree
Hide file tree
Showing 151 changed files with 15,527 additions and 2,293 deletions.
5,744 changes: 5,744 additions & 0 deletions components/excalidraw/state-machine.excalidraw

Large diffs are not rendered by default.

57 changes: 35 additions & 22 deletions components/video.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,65 @@
import { useRef, useCallback, useEffect } from 'react'
import { useInView } from 'react-intersection-observer'
import 'intersection-observer'
import { useRef, useCallback, useEffect } from "react";
import { useInView } from "react-intersection-observer";
import "intersection-observer";

export default ({ src, caption, ratio }) => {
const [inViewRef, inView] = useInView({
threshold: 1,
})
const videoRef = useRef()
});
const videoRef = useRef();

const setRefs = useCallback(
(node) => {
// Ref's from useRef needs to have the node assigned to `current`
videoRef.current = node
videoRef.current = node;
// Callback refs, like the one from `useInView`, is a function that takes the node as an argument
inViewRef(node)
inViewRef(node);

if (node) {
node.addEventListener('click', function () {
node.addEventListener("click", function () {
if (this.paused) {
this.play()
this.play();
} else {
this.pause()
this.pause();
}
})
});
}
},
[inViewRef]
)
);

useEffect(() => {
if (!videoRef || !videoRef.current) {
return
return;
}

if (inView) {
videoRef.current.play()
videoRef.current.play();
} else {
videoRef.current.pause()
videoRef.current.pause();
}
}, [inView])
}, [inView]);

return (
<div style={{ position: 'relative', margin: '2rem 1rem' }}>
<div style={{ paddingBottom: ratio * 100 + '%' }}/>
<video style={{ position: 'absolute', top: 0, left: 0 }} loop muted autoPlay playsInline ref={setRefs}>
<div style={{ position: "relative", margin: "2rem 1rem" }}>
<div style={{ paddingBottom: ratio * 100 + "%" }} />
<video
style={{ position: "absolute", top: 0, left: 0 }}
loop
muted
autoPlay
playsInline
ref={setRefs}
>
<source src={src} type="video/mp4" />
</video>
{caption && <figcaption style={{ fontSize: '.9rem', textAlign: 'center' }}>{caption}</figcaption>}
{caption && (
<figcaption
style={{ fontSize: ".9rem", textAlign: "center", marginTop: "1em" }}
>
{caption}
</figcaption>
)}
</div>
)
}
);
};
5 changes: 5 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ module.exports = withNextra({
destination: "/docs/advanced/cache",
statusCode: 301,
},
{
source: "/docs/options",
destination: "/docs/api",
statusCode: 301
},
{
source: "/change-log",
destination: "/docs/change-log",
Expand Down
1 change: 1 addition & 0 deletions pages/blog/meta.en-US.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "Announcing SWR 1.0"
}
1 change: 1 addition & 0 deletions pages/blog/meta.es-ES.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "Announcing SWR 1.0"
}
1 change: 1 addition & 0 deletions pages/blog/meta.ja.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "SWR 2.0 の発表",
"swr-v1": "SWR 1.0 の発表"
}
1 change: 1 addition & 0 deletions pages/blog/meta.ko.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "SWR 1.0 알림"
}
7 changes: 4 additions & 3 deletions pages/blog/meta.pt-BR.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v1": "Anunciando SWR 1.0"
}
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "Anunciando SWR 1.0"
}
1 change: 1 addition & 0 deletions pages/blog/meta.ru.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "Представляем SWR 1.0"
}
1 change: 1 addition & 0 deletions pages/blog/meta.zh-CN.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"swr-v2": "Announcing SWR 2.0",
"swr-v1": "SWR 1.0 发布"
}

1 comment on commit efea2b0

@vercel
Copy link

@vercel vercel bot commented on efea2b0 Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

swr-site – ./

swr.vercel.app
swr-site-git-main.vercel.sh
swr-site.vercel.sh

Please sign in to comment.