Skip to content

Commit

Permalink
upgrade theme and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Dec 19, 2020
1 parent c555055 commit 91ef7de
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 102 deletions.
6 changes: 3 additions & 3 deletions components/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export default ({ src, caption, ratio }) => {
}, [inView])

return (
<figure>
<div style={{ position: 'relative', margin: '2rem 1rem' }}>
<div style={{ paddingBottom: ratio * 100 + '%' }}/>
<video loop muted autoPlay playsInline ref={setRefs}>
<source src={src} type="video/mp4" />
</video>
{caption && <figcaption>{caption}</figcaption>}
</figure>
{caption && <figcaption style={{ fontSize: '.9rem', textAlign: 'center' }}>{caption}</figcaption>}
</div>
)
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"intersection-observer": "^0.10.0",
"markdown-to-jsx": "^6.11.4",
"next": "^10.0.0",
"nextra": "^0.3.1",
"nextra-theme-docs": "^0.2.6",
"nextra": "^0.3.2",
"nextra-theme-docs": "^1.0.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-intersection-observer": "^8.26.2"
Expand Down
17 changes: 10 additions & 7 deletions pages/change-log.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import { useSSG } from 'nextra/ssg'
export const getStaticProps = ({ params }) => {
return fetch('https://api.github.com/repos/vercel/swr/releases')
.then(res => res.json())
// we keep the most recent 3 releases here
.then(releases => ({ props: { ssg: releases.slice(0, 3) } }))
// we keep the most recent 5 releases here
.then(releases => ({ props: { ssg: releases.slice(0, 5) }, revalidate: 10 }))
}

export const ReleasesRenderer = () => {
const releases = useSSG()
return <Markdown>{releases.map(release => {
return `## <a href="${release.html_url}" target="_blank" rel="noopener">${release.tag_name}</a>\n
Published on ${new Date(release.published_at) .toDateString()}.\n
${release.body}`
}).join('\n\n')}</Markdown>
return <Markdown>{
releases.map(release => {
const body = release.body
.replace(/&#39;/g, "'")
.replace(/@([a-zA-Z0-9_-]+)(?=(,| ))/g, '<a href="https://github.com/$1" target="_blank" rel="noopener">@$1</a>')
return `## <a href="${release.html_url}" target="_blank" rel="noopener">${release.tag_name}</a>
Published on ${new Date(release.published_at) .toDateString()}.\n\n${body}`}).join('\n\n')
}</Markdown>
}

# Change Log
Expand Down
25 changes: 15 additions & 10 deletions pages/docs/revalidation.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Video from 'components/video'
import Callout from 'nextra-theme-docs/callout'
import Bleed from 'nextra-theme-docs/bleed'
import Link from 'next/link'

# Automatic Revalidation
Expand All @@ -14,11 +15,13 @@ When you re-focus a page or switch between tabs, SWR automatically revalidates d

This can be useful to immediately synchronize to the latest state. This is helpful for refreshing data in scenarios like stale mobile tabs, or laptops that **went to sleep**.

<Video
src="https://raw.githubusercontent.com/vercel/swr-site/master/.github/videos/focus-revalidate.mp4"
caption="Video: using focus revalidation to automatically sync login state between pages."
ratio={307/768}
/>
<Bleed>
<Video
src="https://raw.githubusercontent.com/vercel/swr-site/master/.github/videos/focus-revalidate.mp4"
caption="Video: using focus revalidation to automatically sync login state between pages."
ratio={307/768}
/>
</Bleed>

This feature is enabled by default. You can disable it via the [`revalidateOnFocus`](/docs/options) option.

Expand All @@ -28,11 +31,13 @@ In many cases, data changes because of multiple devices, multiple users, multipl

SWR will give you the option to automatically refetch data. It’s **smart** which means refetching will only happen if the component associated with the hook is **on screen**.

<Video
src="https://raw.githubusercontent.com/vercel/swr-site/master/.github/videos/refetch-interval.mp4"
caption="Video: when a user makes a change, both sessions will eventually render the same data."
ratio={307/768}
/>
<Bleed>
<Video
src="https://raw.githubusercontent.com/vercel/swr-site/master/.github/videos/refetch-interval.mp4"
caption="Video: when a user makes a change, both sessions will eventually render the same data."
ratio={307/768}
/>
</Bleed>

You can enable it by setting a [`refreshInterval`](/docs/options) value:

Expand Down
120 changes: 40 additions & 80 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1501,21 +1501,10 @@
tslib "^2.0.0"
warning "^4.0.3"

"@sindresorhus/slugify@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/slugify/-/slugify-1.1.0.tgz#2f195365d9b953384305b62664b44b4036c49430"
integrity sha512-ujZRbmmizX26yS/HnB3P9QNlNa4+UvHh+rIse3RbOXLp8yl6n1TxB4t7NHggtVgS8QmmOtzXo48kCxZGACpkPw==
dependencies:
"@sindresorhus/transliterate" "^0.1.1"
escape-string-regexp "^4.0.0"

"@sindresorhus/transliterate@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@sindresorhus/transliterate/-/transliterate-0.1.1.tgz#779b31244781d3c898f185b61d58c89e7c782674"
integrity sha512-QSdIQ5keUFAZ3KLbfbsntW39ox0Ym8183RqTwBq/ZEFoN3NQAtGV+qWaNdzKpIDHgj9J2CQ2iNDRVU11Zyr7MQ==
dependencies:
escape-string-regexp "^2.0.0"
lodash.deburr "^4.1.0"
"@researchgate/react-intersection-observer@^1.3.5":
version "1.3.5"
resolved "https://registry.yarnpkg.com/@researchgate/react-intersection-observer/-/react-intersection-observer-1.3.5.tgz#0321d2dd609aaacdb9bace8004d99c72824fb142"
integrity sha512-aYlsex5Dd6BAHMJvJrUoFp8gzgMSL27xFvrxkVYW0bV1RMAapVsO+QeYLtTaSF/QCflktODodvv+wJm49oMnnQ==

"@types/color-name@^1.1.1":
version "1.1.1"
Expand Down Expand Up @@ -2434,7 +2423,7 @@ chalk@^2.0.0, chalk@^2.4.1, chalk@^2.4.2:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

"chalk@^3.0.0 || ^4.0.0", chalk@^4.0.0:
chalk@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a"
integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==
Expand Down Expand Up @@ -3295,6 +3284,11 @@ elliptic@^6.0.0, elliptic@^6.5.2:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.0"

"emoji-regex@>=6.0.0 <=6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-6.1.1.tgz#c6cd0ec1b0642e2a3c67a1137efc5e796da4f88e"
integrity sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4=

emojis-list@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389"
Expand Down Expand Up @@ -3420,16 +3414,6 @@ escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=

escape-string-regexp@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344"
integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==

escape-string-regexp@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==

eslint-scope@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
Expand Down Expand Up @@ -3762,6 +3746,13 @@ [email protected]:
resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce"
integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=

github-slugger@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/github-slugger/-/github-slugger-1.3.0.tgz#9bd0a95c5efdfc46005e82a906ef8e2a059124c9"
integrity sha512-gwJScWVNhFYSRDvURk/8yhcFBee6aFjye2a7Lhb2bUyRulpIoek9p0I9Kt7PT67d/nUlZbFu8L9RLiA0woQN8Q==
dependencies:
emoji-regex ">=6.0.0 <=6.1.1"

glob-parent@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae"
Expand Down Expand Up @@ -3995,11 +3986,6 @@ html-comment-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/html-comment-regex/-/html-comment-regex-1.1.2.tgz#97d4688aeb5c81886a364faa0cad1dda14d433a7"
integrity sha512-P+M65QY2JQ5Y0G9KKdlDpo0zK+/OHptU5AaBwUfAIDJZk1MYf32Frm84EcOytfJE0t5JvkAnKlmjsXDnWzCJmQ==

html-tags@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.1.0.tgz#7b5e6f7e665e9fb41f30007ed9e0d41e97fb2140"
integrity sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg==

html-void-elements@^1.0.0:
version "1.0.5"
resolved "https://registry.yarnpkg.com/html-void-elements/-/html-void-elements-1.0.5.tgz#ce9159494e86d95e45795b166c2021c2cfca4483"
Expand Down Expand Up @@ -4116,6 +4102,11 @@ intersection-observer@^0.10.0:
resolved "https://registry.yarnpkg.com/intersection-observer/-/intersection-observer-0.10.0.tgz#4d11d63c1ff67e21e62987be24d55218da1a1a69"
integrity sha512-fn4bQ0Xq8FTej09YC/jqKZwtijpvARlRp6wxL5WTA6yPe2YWSJ5RJh7Nm79rK2qB0wr6iDQzH60XGq5V/7u8YQ==

intersection-observer@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/intersection-observer/-/intersection-observer-0.12.0.tgz#6c84628f67ce8698e5f9ccf857d97718745837aa"
integrity sha512-2Vkz8z46Dv401zTWudDGwO7KiGHNDkMv417T5ItcNYfmvHR/1qCTVBO9vwH8zZmQ0WkA/1ARwpysR9bsnop4NQ==

invariant@^2.2.2:
version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
Expand Down Expand Up @@ -4584,11 +4575,6 @@ lodash._reinterpolate@^3.0.0:
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=

lodash.deburr@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/lodash.deburr/-/lodash.deburr-4.1.0.tgz#ddb1bbb3ef07458c0177ba07de14422cb033ff9b"
integrity sha1-3bG7s+8HRYwBd7oH3hRCLLAz/5s=

lodash.memoize@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
Expand Down Expand Up @@ -4629,7 +4615,7 @@ lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==

lodash@^4.17.19, lodash@^4.17.20:
lodash@^4.17.19:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
Expand Down Expand Up @@ -5103,26 +5089,28 @@ next@^10.0.0:
optionalDependencies:
sharp "0.26.2"

nextra-theme-docs@^0.2.6:
version "0.2.6"
resolved "https://registry.yarnpkg.com/nextra-theme-docs/-/nextra-theme-docs-0.2.6.tgz#c7710fc258dbc0c39ba77b32bb7124972ecae312"
integrity sha512-B5NFRMEIJLeYrVhEugpF4CpXgs6TKnOFYL26COclH2sLD073GSjG2/Qzf98bccftMiwZnvCGSZWi78JOlLaURw==
nextra-theme-docs@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/nextra-theme-docs/-/nextra-theme-docs-1.0.3.tgz#c851c51c26a9139768aef0377a05ae49eca88933"
integrity sha512-VTTJbvJhO3I87dygYi5+q2EEGwuRVxl6mRheJfW/iHkiiTJInSVIHPmAEh9syJhOE62qCTFW6VZKRH/nRZA1Rw==
dependencies:
"@mdx-js/react" "^1.6.16"
"@reach/skip-nav" "^0.11.2"
"@sindresorhus/slugify" "^1.1.0"
"@researchgate/react-intersection-observer" "^1.3.5"
classnames "^2.2.6"
focus-visible "^5.1.0"
github-slugger "^1.3.0"
intersection-observer "^0.12.0"
match-sorter "^4.2.0"
next-themes "^0.0.8"
prism-react-renderer "^1.1.1"
tailwindcss "^1.8.3"
react-innertext "^1.1.5"
title "^3.4.2"

nextra@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/nextra/-/nextra-0.3.1.tgz#61b2d0ac86f5fedb6cf50ad88727cb880e245ebe"
integrity sha512-P/PcHKqz1SrXqWf21TNFUGMJtfM4/yG5CYpV3BW7EJnIihBELd2oKNVm47RsDLNQ0ycpb6iS6vexwWAuymb8Zw==
nextra@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/nextra/-/nextra-0.3.2.tgz#a13098d05be46b14383eac874f08a6062cab825b"
integrity sha512-Mf7s0YTmf/ZZXOL/X1mjs7hY/W05PoeZsxDt/2NNMH+BZsMcy3qjhqdZyNDNFb7VDJrCirPYw67znZS0P+2gHw==
dependencies:
"@mdx-js/loader" "^2.0.0-next.8"
gray-matter "^4.0.2"
Expand Down Expand Up @@ -5294,11 +5282,6 @@ object-copy@^0.1.0:
define-property "^0.2.5"
kind-of "^3.0.3"

object-hash@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-2.0.3.tgz#d12db044e03cd2ca3d77c0570d87225b02e1e6ea"
integrity sha512-JPKn0GMu+Fa3zt3Bmr66JhokJU5BaNBIh4ZeTlaCBzrBsOeXzwcKKAK1tbLiPKgvwmPXsDvvLHoWh5Bm7ofIYg==

object-inspect@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0"
Expand Down Expand Up @@ -6455,6 +6438,11 @@ react-dom@^16.13.1:
prop-types "^15.6.2"
scheduler "^0.19.1"

react-innertext@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/react-innertext/-/react-innertext-1.1.5.tgz#8147ac54db3f7067d95f49e2d2c05a720d27d8d0"
integrity sha512-PWAqdqhxhHIv80dT9znP2KvS+hfkbRovFp4zFYHFFlOoQLRiawIic81gKb3U1wEyJZgMwgs3JoLtwryASRWP3Q==

react-intersection-observer@^8.26.2:
version "8.26.2"
resolved "https://registry.yarnpkg.com/react-intersection-observer/-/react-intersection-observer-8.26.2.tgz#0562ff0c06b2b10e809190c2fa9b6ded656e6e16"
Expand Down Expand Up @@ -7405,34 +7393,6 @@ tailwindcss@^1.4.6:
reduce-css-calc "^2.1.6"
resolve "^1.14.2"

tailwindcss@^1.8.3:
version "1.8.10"
resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-1.8.10.tgz#945ef151c401c04a1c95e6a6bc747387a8d1b9dc"
integrity sha512-7QkERG/cWCzsuMqHMwjOaLMVixOGLNBiXsrkssxlE1aWfkxVbGqiuMokR2162xRyaH2mBIHKxmlf1qb3DvIPqw==
dependencies:
"@fullhuman/postcss-purgecss" "^2.1.2"
autoprefixer "^9.4.5"
browserslist "^4.12.0"
bytes "^3.0.0"
chalk "^3.0.0 || ^4.0.0"
color "^3.1.2"
detective "^5.2.0"
fs-extra "^8.0.0"
html-tags "^3.1.0"
lodash "^4.17.20"
node-emoji "^1.8.1"
normalize.css "^8.0.1"
object-hash "^2.0.3"
postcss "^7.0.11"
postcss-functions "^3.0.0"
postcss-js "^2.0.0"
postcss-nested "^4.1.1"
postcss-selector-parser "^6.0.0"
postcss-value-parser "^4.1.0"
pretty-hrtime "^1.0.3"
reduce-css-calc "^2.1.6"
resolve "^1.14.2"

tapable@^1.0.0, tapable@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2"
Expand Down

0 comments on commit 91ef7de

Please sign in to comment.