├── .yarnrc ├── now.json ├── .eslintignore ├── lib ├── env.js ├── is-ie-11.js ├── with-api.js ├── scroll-into-view-if-needed.js ├── pure-component.js ├── immutable-component.js ├── bind-listeners.js ├── redirect-to.js ├── router-events.js ├── polyfill.js ├── redirect.js ├── logout.js ├── authenticate.js ├── data │ ├── team.js │ ├── last-edited.json │ └── docs.js ├── api-endpoints.js └── fetch-api.js ├── static ├── docs │ ├── logs │ │ ├── help.png │ │ ├── now-dashboard-logs.png │ │ └── last-10-get-requests.png │ ├── graphql │ │ ├── api.png │ │ └── client.png │ ├── next │ │ ├── output.png │ │ └── running.png │ ├── json-api │ │ ├── date.png │ │ └── members.png │ ├── static │ │ └── browser.png │ ├── aliases │ │ ├── cname-add.png │ │ ├── txt-add.png │ │ ├── alias-dest.png │ │ ├── alias-source.png │ │ └── nameservers-edit.png │ ├── now-secrets │ │ └── help.png │ ├── scaling │ │ ├── now-alias.png │ │ ├── auto-scaling.png │ │ └── fixed-scaling.png │ ├── private-npm │ │ └── example.gif │ ├── realtime-chat │ │ ├── form.png │ │ ├── result.gif │ │ ├── server.png │ │ ├── connected.png │ │ ├── disconnected.png │ │ └── hello-world.png │ ├── installation │ │ ├── now-cli.png │ │ └── now-desktop.png │ ├── installing-now │ │ ├── menubar.png │ │ ├── tutorial-1.png │ │ ├── tutorial-2.png │ │ ├── tutorial-3.png │ │ └── guide-drag-drop-now.gif │ ├── git-repositories │ │ └── slackin.png │ ├── path-aliases │ │ └── deployment.png │ ├── slack-slash │ │ ├── auto-complete.png │ │ └── add-configuration.png │ ├── deployment │ │ └── static-dir-listing.png │ ├── assign-a-domain-name │ │ ├── alias-error.png │ │ ├── buy-domain.png │ │ └── custom-domain.png │ ├── five-minute-guide-to-now │ │ ├── deploy.png │ │ └── domain-setup.png │ ├── your-first-deployments │ │ ├── localhost.png │ │ ├── my-first-site.png │ │ └── my-first-site-folder.png │ └── how-to-use-cloudflare │ │ ├── cloudflare-now-txt.png │ │ ├── cloudflare-dns-records.png │ │ ├── cloudflare-dns-proxy-mode.png │ │ ├── cloudflare-full-strict-ssl.png │ │ ├── cloudflare-page-rule-ssl-off.png │ │ └── cloudflare-page-rules-ssl-off-on-top.png ├── api │ └── deployment-state.png └── blog │ ├── domain-verification │ ├── ssl.png │ ├── rules.png │ └── cloudflare.png │ └── improved-cli-updates │ └── update-option.png ├── circle.yml ├── pages ├── docs │ ├── guides │ │ ├── index.js │ │ ├── updating-now-cli.js │ │ ├── redirect.js │ │ └── app-lifecycle-and-scalability.js │ ├── other │ │ ├── index.js │ │ ├── support-channels.js │ │ └── billing.js │ ├── examples │ │ ├── index.js │ │ ├── redirect.js │ │ ├── travis.js │ │ ├── static.js │ │ └── create-react-app.js │ ├── features │ │ ├── index.js │ │ ├── zero-downtime-migration.js │ │ ├── private-npm.js │ │ ├── dns.js │ │ └── certs.js │ ├── deployment-types │ │ ├── index.js │ │ ├── lifecycle.js │ │ ├── static.js │ │ └── docker.js │ ├── getting-started │ │ ├── index.js │ │ ├── whats-next.js │ │ ├── environment-variables.js │ │ ├── logs.js │ │ ├── secrets.js │ │ ├── deployment.js │ │ └── scaling.js │ └── index.js └── _document.js ├── components ├── api │ ├── sections │ │ ├── getting-started │ │ │ └── index.js │ │ ├── changelog │ │ │ ├── index.js │ │ │ ├── version2.js │ │ │ └── version3.js │ │ ├── index.js │ │ ├── errors │ │ │ ├── index.js │ │ │ ├── oauth2.js │ │ │ ├── dns.js │ │ │ └── generic.js │ │ ├── api-basics │ │ │ ├── index.js │ │ │ ├── content-type.js │ │ │ ├── versioning.js │ │ │ ├── errors.js │ │ │ ├── authentication.js │ │ │ ├── rate-limits.js │ │ │ └── types.js │ │ └── endpoints │ │ │ ├── index.js │ │ │ ├── authentication.js │ │ │ └── oauth2.js │ ├── endpoint.js │ ├── deprecated.js │ ├── request.js │ └── file-icon.js ├── text │ ├── hr.js │ ├── caption.js │ ├── list.js │ ├── paragraph.js │ ├── heading.js │ ├── code.js │ ├── link.js │ └── terminal.js ├── now │ └── now.js ├── css-config.js ├── icons │ ├── plus.js │ ├── github.js │ └── logo.js ├── arrow.js ├── badge.js ├── table.js ├── freeze-page-scroll.js ├── click-outside.js ├── avatar.js ├── permalink-icon.js ├── portal.js ├── docs │ └── navbar │ │ ├── mobile.js │ │ └── toggle.js ├── page.js ├── image.js ├── heading.js ├── popover-link.js └── avatar-popover-link.js ├── deploy-server ├── now.json ├── package.json ├── server.js └── deploy.js ├── .gitignore ├── env-config.js ├── next.config.js ├── license.md ├── scripts ├── last-edited.js └── deploy.js ├── server.js ├── readme.md └── package.json /.yarnrc: -------------------------------------------------------------------------------- 1 | save-prefix "" 2 | -------------------------------------------------------------------------------- /now.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "docs.zeit.sh" 3 | } 4 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | deploy-server/node_modules 3 | -------------------------------------------------------------------------------- /lib/env.js: -------------------------------------------------------------------------------- 1 | export default ('undefined' !== typeof window ? window.__ENV__ : process.env) 2 | -------------------------------------------------------------------------------- /lib/is-ie-11.js: -------------------------------------------------------------------------------- 1 | module.exports = ua => ~ua.indexOf('Trident/7') && ~ua.indexOf('rv:11') 2 | -------------------------------------------------------------------------------- /static/docs/logs/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/logs/help.png -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | node: 3 | version: 8 4 | 5 | test: 6 | post: 7 | - npm run deploy 8 | -------------------------------------------------------------------------------- /static/docs/graphql/api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/graphql/api.png -------------------------------------------------------------------------------- /static/docs/next/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/next/output.png -------------------------------------------------------------------------------- /static/docs/next/running.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/next/running.png -------------------------------------------------------------------------------- /static/docs/graphql/client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/graphql/client.png -------------------------------------------------------------------------------- /static/docs/json-api/date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/json-api/date.png -------------------------------------------------------------------------------- /static/docs/static/browser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/static/browser.png -------------------------------------------------------------------------------- /static/api/deployment-state.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/api/deployment-state.png -------------------------------------------------------------------------------- /static/docs/aliases/cname-add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/aliases/cname-add.png -------------------------------------------------------------------------------- /static/docs/aliases/txt-add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/aliases/txt-add.png -------------------------------------------------------------------------------- /static/docs/json-api/members.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/json-api/members.png -------------------------------------------------------------------------------- /static/docs/now-secrets/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/now-secrets/help.png -------------------------------------------------------------------------------- /static/docs/scaling/now-alias.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/scaling/now-alias.png -------------------------------------------------------------------------------- /static/docs/aliases/alias-dest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/aliases/alias-dest.png -------------------------------------------------------------------------------- /static/docs/private-npm/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/private-npm/example.gif -------------------------------------------------------------------------------- /static/docs/realtime-chat/form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/realtime-chat/form.png -------------------------------------------------------------------------------- /static/docs/aliases/alias-source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/aliases/alias-source.png -------------------------------------------------------------------------------- /static/docs/installation/now-cli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/installation/now-cli.png -------------------------------------------------------------------------------- /static/docs/installing-now/menubar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/installing-now/menubar.png -------------------------------------------------------------------------------- /static/docs/realtime-chat/result.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/realtime-chat/result.gif -------------------------------------------------------------------------------- /static/docs/realtime-chat/server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/realtime-chat/server.png -------------------------------------------------------------------------------- /static/docs/scaling/auto-scaling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/scaling/auto-scaling.png -------------------------------------------------------------------------------- /static/docs/scaling/fixed-scaling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/scaling/fixed-scaling.png -------------------------------------------------------------------------------- /pages/docs/guides/index.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs') 5 | -------------------------------------------------------------------------------- /pages/docs/other/index.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs') 5 | -------------------------------------------------------------------------------- /static/blog/domain-verification/ssl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/blog/domain-verification/ssl.png -------------------------------------------------------------------------------- /static/docs/aliases/nameservers-edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/aliases/nameservers-edit.png -------------------------------------------------------------------------------- /static/docs/git-repositories/slackin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/git-repositories/slackin.png -------------------------------------------------------------------------------- /static/docs/installation/now-desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/installation/now-desktop.png -------------------------------------------------------------------------------- /static/docs/logs/now-dashboard-logs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/logs/now-dashboard-logs.png -------------------------------------------------------------------------------- /static/docs/path-aliases/deployment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/path-aliases/deployment.png -------------------------------------------------------------------------------- /static/docs/realtime-chat/connected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/realtime-chat/connected.png -------------------------------------------------------------------------------- /components/api/sections/getting-started/index.js: -------------------------------------------------------------------------------- 1 | import introduction from './introduction' 2 | 3 | export default { introduction } 4 | -------------------------------------------------------------------------------- /pages/docs/examples/index.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs') 5 | -------------------------------------------------------------------------------- /pages/docs/features/index.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs') 5 | -------------------------------------------------------------------------------- /static/blog/domain-verification/rules.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/blog/domain-verification/rules.png -------------------------------------------------------------------------------- /static/docs/installing-now/tutorial-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/installing-now/tutorial-1.png -------------------------------------------------------------------------------- /static/docs/installing-now/tutorial-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/installing-now/tutorial-2.png -------------------------------------------------------------------------------- /static/docs/installing-now/tutorial-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/installing-now/tutorial-3.png -------------------------------------------------------------------------------- /static/docs/logs/last-10-get-requests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/logs/last-10-get-requests.png -------------------------------------------------------------------------------- /static/docs/realtime-chat/disconnected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/realtime-chat/disconnected.png -------------------------------------------------------------------------------- /static/docs/realtime-chat/hello-world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/realtime-chat/hello-world.png -------------------------------------------------------------------------------- /static/docs/slack-slash/auto-complete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/slack-slash/auto-complete.png -------------------------------------------------------------------------------- /pages/docs/deployment-types/index.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs') 5 | -------------------------------------------------------------------------------- /pages/docs/getting-started/index.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs') 5 | -------------------------------------------------------------------------------- /pages/docs/index.js: -------------------------------------------------------------------------------- 1 | import IntroductionToNow from './getting-started/five-minute-guide-to-now' 2 | 3 | export default IntroductionToNow 4 | -------------------------------------------------------------------------------- /static/docs/deployment/static-dir-listing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/deployment/static-dir-listing.png -------------------------------------------------------------------------------- /static/docs/slack-slash/add-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/slack-slash/add-configuration.png -------------------------------------------------------------------------------- /static/blog/domain-verification/cloudflare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/blog/domain-verification/cloudflare.png -------------------------------------------------------------------------------- /static/docs/assign-a-domain-name/alias-error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/assign-a-domain-name/alias-error.png -------------------------------------------------------------------------------- /static/docs/assign-a-domain-name/buy-domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/assign-a-domain-name/buy-domain.png -------------------------------------------------------------------------------- /static/docs/five-minute-guide-to-now/deploy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/five-minute-guide-to-now/deploy.png -------------------------------------------------------------------------------- /static/docs/your-first-deployments/localhost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/your-first-deployments/localhost.png -------------------------------------------------------------------------------- /pages/docs/examples/redirect.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs/guides/redirect') 5 | -------------------------------------------------------------------------------- /static/blog/improved-cli-updates/update-option.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/blog/improved-cli-updates/update-option.png -------------------------------------------------------------------------------- /static/docs/assign-a-domain-name/custom-domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/assign-a-domain-name/custom-domain.png -------------------------------------------------------------------------------- /static/docs/installing-now/guide-drag-drop-now.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/installing-now/guide-drag-drop-now.gif -------------------------------------------------------------------------------- /static/docs/five-minute-guide-to-now/domain-setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/five-minute-guide-to-now/domain-setup.png -------------------------------------------------------------------------------- /static/docs/your-first-deployments/my-first-site.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/your-first-deployments/my-first-site.png -------------------------------------------------------------------------------- /static/docs/how-to-use-cloudflare/cloudflare-now-txt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/how-to-use-cloudflare/cloudflare-now-txt.png -------------------------------------------------------------------------------- /static/docs/how-to-use-cloudflare/cloudflare-dns-records.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/how-to-use-cloudflare/cloudflare-dns-records.png -------------------------------------------------------------------------------- /static/docs/your-first-deployments/my-first-site-folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/your-first-deployments/my-first-site-folder.png -------------------------------------------------------------------------------- /lib/with-api.js: -------------------------------------------------------------------------------- 1 | export default function withAPI(Component) { 2 | // just pass through here. 3 | // more logics will be added on production. 4 | return Component 5 | } 6 | -------------------------------------------------------------------------------- /pages/docs/features/zero-downtime-migration.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs/guides/migrate-your-app') 5 | -------------------------------------------------------------------------------- /static/docs/how-to-use-cloudflare/cloudflare-dns-proxy-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/how-to-use-cloudflare/cloudflare-dns-proxy-mode.png -------------------------------------------------------------------------------- /components/api/sections/changelog/index.js: -------------------------------------------------------------------------------- 1 | import version2 from './version2' 2 | import version3 from './version3' 3 | 4 | export default { 5 | version2, 6 | version3 7 | } 8 | -------------------------------------------------------------------------------- /deploy-server/now.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "docs-deploy-server.zeit.sh", 3 | "env": { 4 | "ZEIT_TOKEN": "@zeit-docs-zeit-token", 5 | "GH_KEY": "@geist-gh-key" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /pages/docs/deployment-types/lifecycle.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import redirect from '../../../lib/redirect' 3 | 4 | export default redirect('/docs/guides/app-lifecycle-and-scalability') 5 | -------------------------------------------------------------------------------- /static/docs/how-to-use-cloudflare/cloudflare-full-strict-ssl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/how-to-use-cloudflare/cloudflare-full-strict-ssl.png -------------------------------------------------------------------------------- /static/docs/how-to-use-cloudflare/cloudflare-page-rule-ssl-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/how-to-use-cloudflare/cloudflare-page-rule-ssl-off.png -------------------------------------------------------------------------------- /static/docs/how-to-use-cloudflare/cloudflare-page-rules-ssl-off-on-top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasonlong/docs/master/static/docs/how-to-use-cloudflare/cloudflare-page-rules-ssl-off-on-top.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build output 2 | .next 3 | out 4 | 5 | # dependencies 6 | node_modules 7 | deploy-server/node_modules 8 | package-lock.json 9 | 10 | # logs 11 | npm-debug.log 12 | 13 | # other 14 | .DS_Store 15 | -------------------------------------------------------------------------------- /components/text/hr.js: -------------------------------------------------------------------------------- 1 | const HR = () => ( 2 |
9 | ) 10 | 11 | export default HR 12 | -------------------------------------------------------------------------------- /lib/scroll-into-view-if-needed.js: -------------------------------------------------------------------------------- 1 | import scrollIntoViewIfNeeded_ from 'scroll-into-view-if-needed' 2 | 3 | export default function scrollIntoViewIfNeeded(el) { 4 | return scrollIntoViewIfNeeded_(el, true, { 5 | duration: 300 6 | }) 7 | } 8 | -------------------------------------------------------------------------------- /lib/pure-component.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const pureComponent = c => 4 | class PureComponetn extends React.PureComponent { 5 | render() { 6 | return c(this.props) 7 | } 8 | } 9 | 10 | export default pureComponent 11 | -------------------------------------------------------------------------------- /lib/immutable-component.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const immutableComponent = c => 4 | class ImmutableComponent extends React.Component { 5 | shouldComponentUpdate() { 6 | return false 7 | } 8 | 9 | render() { 10 | return c(this.props) 11 | } 12 | } 13 | 14 | export default immutableComponent 15 | -------------------------------------------------------------------------------- /env-config.js: -------------------------------------------------------------------------------- 1 | // this file exports a bunch of replacements 2 | // that are made across the source-code 3 | 4 | const { NODE_ENV } = process.env 5 | 6 | module.exports = { 7 | VERSION: require('./package').version, 8 | 'process.env.NODE_ENV': NODE_ENV, 9 | IMAGE_ASSETS_URL: '', 10 | VIDEO_ASSETS_URL: '', 11 | RAW_ASSETS_URL: '' 12 | } 13 | -------------------------------------------------------------------------------- /components/api/sections/index.js: -------------------------------------------------------------------------------- 1 | import gettingStarted from './getting-started' 2 | import apiBasics from './api-basics' 3 | import endpoints from './endpoints' 4 | import errors from './errors' 5 | import changelog from './changelog' 6 | 7 | export default { 8 | gettingStarted, 9 | apiBasics, 10 | endpoints, 11 | errors, 12 | changelog 13 | } 14 | -------------------------------------------------------------------------------- /lib/bind-listeners.js: -------------------------------------------------------------------------------- 1 | export default function bindListeners(instance) { 2 | for (const k of Object.getOwnPropertyNames(Object.getPrototypeOf(instance))) { 3 | if (!/^on[A-Z]/.test(k)) continue 4 | 5 | const listener = instance[k] 6 | if ('function' === typeof listener) { 7 | instance[k] = listener.bind(instance) 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /components/api/sections/errors/index.js: -------------------------------------------------------------------------------- 1 | import generic from './generic' 2 | import deploymentErrors from './deployments' 3 | import domainErrors from './domains' 4 | import dnsErrors from './dns' 5 | import oauth2Errors from './oauth2' 6 | 7 | export default { 8 | generic, 9 | deploymentErrors, 10 | domainErrors, 11 | dnsErrors, 12 | oauth2Errors 13 | } 14 | -------------------------------------------------------------------------------- /components/now/now.js: -------------------------------------------------------------------------------- 1 | export default function Now(props) { 2 | const color = props.color || '#fff' 3 | 4 | return ( 5 | 6 | Now 7 | 14 | 15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /components/api/endpoint.js: -------------------------------------------------------------------------------- 1 | import { Code } from '../text/code' 2 | 3 | function Endpoint({ method, url, children }) { 4 | return [ 5 | Endpoint, 6 | children ? ( 7 | {children} 8 | ) : ( 9 | 10 | {method} {url} 11 | 12 | ) 13 | ] 14 | } 15 | 16 | export default Endpoint 17 | -------------------------------------------------------------------------------- /components/api/sections/api-basics/index.js: -------------------------------------------------------------------------------- 1 | import contentType from './content-type' 2 | import authentication from './authentication' 3 | import errors from './errors' 4 | import rateLimits from './rate-limits' 5 | import versioning from './versioning' 6 | import types from './types' 7 | 8 | export default { 9 | contentType, 10 | authentication, 11 | errors, 12 | rateLimits, 13 | versioning, 14 | types 15 | } 16 | -------------------------------------------------------------------------------- /lib/redirect-to.js: -------------------------------------------------------------------------------- 1 | import Router from 'next/router' 2 | 3 | export default function redirectTo(destination, { res, status } = {}) { 4 | if (res) { 5 | res.writeHead(status || 302, { Location: destination }) 6 | res.end() 7 | } else { 8 | if (destination[0] === '/' && destination[1] !== '/') { 9 | Router.push(destination) 10 | } else { 11 | window.location = destination 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /components/css-config.js: -------------------------------------------------------------------------------- 1 | export const FONT_FAMILY_SANS = 2 | '-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif' 3 | 4 | export const FONT_FAMILY_MONO = 5 | 'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif' 6 | 7 | export const COLOR_ERROR = '#FF001F' 8 | export const COLOR_SUCCESS = '#067DF7' 9 | -------------------------------------------------------------------------------- /components/icons/plus.js: -------------------------------------------------------------------------------- 1 | const Plus = ({ size = 14 }) => ( 2 | 8 | 15 | 16 | 17 | 18 | ) 19 | 20 | export default Plus 21 | -------------------------------------------------------------------------------- /deploy-server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zeit-docs-deploy-server", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "start": "node server.js" 6 | }, 7 | "license": "MIT", 8 | "dependencies": { 9 | "express": "^4.15.4", 10 | "express-fileupload": "^0.1.4", 11 | "jsonwebtoken": "^7.4.3", 12 | "mz": "^2.6.0", 13 | "uuid": "^3.1.0" 14 | }, 15 | "devDependencies": { 16 | "github": "^9.2.0", 17 | "now": "^8.1.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/router-events.js: -------------------------------------------------------------------------------- 1 | import mitt from 'mitt' 2 | import Router from 'next/router' 3 | 4 | const emitter = mitt() 5 | export default emitter 6 | 7 | Router.onRouteChangeStart = (...args) => { 8 | emitter.emit('routeChangeStart', ...args) 9 | } 10 | 11 | Router.onRouteChangeComplete = (...args) => { 12 | emitter.emit('routeChangeComplete', ...args) 13 | } 14 | 15 | Router.onRouteChangeError = (...args) => { 16 | emitter.emit('routeChangeError', ...args) 17 | } 18 | -------------------------------------------------------------------------------- /components/arrow.js: -------------------------------------------------------------------------------- 1 | const Arrow = () => ( 2 | 9 | 10 | 15 | 16 | 17 | ) 18 | 19 | export default Arrow 20 | -------------------------------------------------------------------------------- /components/api/sections/endpoints/index.js: -------------------------------------------------------------------------------- 1 | import deployments from './deployments' 2 | import domains from './domains' 3 | import dns from './dns' 4 | import certificates from './certificates' 5 | import aliases from './aliases' 6 | import secrets from './secrets' 7 | import oauth2 from './oauth2' 8 | import teams from './teams' 9 | import authentication from './authentication' 10 | import logs from './logs' 11 | 12 | export default { 13 | deployments, 14 | logs, 15 | domains, 16 | dns, 17 | certificates, 18 | aliases, 19 | secrets, 20 | teams, 21 | authentication, 22 | oauth2 23 | } 24 | -------------------------------------------------------------------------------- /components/badge.js: -------------------------------------------------------------------------------- 1 | const Badge = ({ number = 0, backgroundColor }) => ( 2 | 3 | {number} 4 | 21 | 22 | ) 23 | 24 | export default Badge 25 | -------------------------------------------------------------------------------- /lib/polyfill.js: -------------------------------------------------------------------------------- 1 | if (!Array.prototype.find) { 2 | // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find 3 | Array.prototype.find = function ArrayFindPolyfill(predicate) { 4 | if (null == this) { 5 | throw new TypeError('Array.prototype.find called on null or undefined') 6 | } 7 | if ('function' !== typeof predicate) { 8 | throw new TypeError('predicate must be a function') 9 | } 10 | 11 | const list = Object(this) 12 | const length = list.length >>> 0 13 | const thisArg = arguments[1] 14 | 15 | for (let i = 0; i < length; i++) { 16 | const value = list[i] 17 | if (predicate.call(thisArg, value, i, list)) { 18 | return value 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/redirect.js: -------------------------------------------------------------------------------- 1 | // Packages 2 | import React from 'react' 3 | import Head from 'next/head' 4 | import redirectTo from './redirect-to' 5 | 6 | const redirect = destination => 7 | class RedirectRoute extends React.Component { 8 | static getInitialProps({ res }) { 9 | if (typeof window === 'undefined' && !res.writeHead) { 10 | // This is the SSR mode 11 | return { metaRedirect: true } 12 | } 13 | 14 | redirectTo(destination, { res, status: 301 }) 15 | return {} 16 | } 17 | 18 | render() { 19 | if (this.props.metaRedirect) { 20 | return ( 21 | 22 | 23 | 24 | ) 25 | } 26 | 27 | return null 28 | } 29 | } 30 | 31 | export default redirect 32 | -------------------------------------------------------------------------------- /components/text/caption.js: -------------------------------------------------------------------------------- 1 | import { FONT_FAMILY_MONO } from '../css-config' 2 | 3 | const Caption = ({ children }) => ( 4 |

5 | {children} 6 | 16 |

17 | ) 18 | 19 | const Code = ({ children }) => ( 20 | 21 | {children} 22 | 38 | 39 | ) 40 | 41 | Caption.Code = Code 42 | 43 | export default Caption 44 | -------------------------------------------------------------------------------- /components/api/sections/api-basics/content-type.js: -------------------------------------------------------------------------------- 1 | import markdown from 'markdown-in-js' 2 | import Section, { components } from '../../section' 3 | import immutable from '../../../../lib/immutable-component' 4 | 5 | function ContentType() { 6 | return ( 7 |
26 | ) 27 | } 28 | 29 | export default immutable(ContentType) 30 | -------------------------------------------------------------------------------- /pages/docs/getting-started/whats-next.js: -------------------------------------------------------------------------------- 1 | import markdown from 'markdown-in-js' 2 | import withDoc, { components } from '../../../lib/with-doc' 3 | import { arunoda } from '../../../lib/data/team' 4 | import Now from '../../../components/now/now' 5 | 6 | // prettier-ignore 7 | export default withDoc({ 8 | title: 'What\'s Next', 9 | date: '10 August 2017', 10 | authors: [arunoda], 11 | editUrl: 'pages/docs/getting-started/whats-next.js', 12 | })(markdown(components)` 13 | 14 | As you've gone through the getting started guide, you are ready to do production deployments with ${}. 15 | 16 | For additional information, follow these links: 17 | 18 | * [Discover more with guides](/docs/deployment-types/lifecycle) 19 | * [Try example apps](/docs/examples/json-api) 20 | * [Connect with our support channels](/docs/other/support-channels) 21 | * [Check the frequently asked questions (FAQ)](/docs/other/faq) 22 | `) 23 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | const glob = require('glob-promise') 2 | 3 | module.exports = { 4 | exportPathMap: async function() { 5 | const paths = await glob('pages/**') 6 | const pages = paths 7 | .map(path => { 8 | path = path.replace(/^pages/, '') 9 | path = path.replace('index.js', '') 10 | path = path.replace('.js', '') 11 | 12 | if (path === '/_document') return 13 | if (path === '/') return path 14 | 15 | path = path.replace(/\/$/, '') 16 | return path 17 | }) 18 | .filter(Boolean) 19 | 20 | const pageMap = pages.reduce((map, page) => { 21 | map[page] = { page } 22 | return map 23 | }, {}) 24 | 25 | return pageMap 26 | }, 27 | 28 | // By default we don't have any assetPrefix. 29 | // This is because we need to support PR based static deployments 30 | // But for multi-zones suppport we are running a custom proxy which adds 31 | // multi-zones support. 32 | assetPrefix: '' 33 | } 34 | -------------------------------------------------------------------------------- /components/api/sections/api-basics/versioning.js: -------------------------------------------------------------------------------- 1 | import markdown from 'markdown-in-js' 2 | import Section, { components } from '../../section' 3 | import immutable from '../../../../lib/immutable-component' 4 | 5 | function Versioning() { 6 | return ( 7 |
23 | ) 24 | } 25 | 26 | export default immutable(Versioning) 27 | -------------------------------------------------------------------------------- /components/text/list.js: -------------------------------------------------------------------------------- 1 | export const UL = ({ children }) => ( 2 |
    3 | {children} 4 | 20 |
21 | ) 22 | 23 | export const OL = ({ children }) => ( 24 |
    25 | {children} 26 | 34 |
35 | ) 36 | 37 | export const LI = ({ children }) => ( 38 |
  • 39 | {children} 40 | 49 |
  • 50 | ) 51 | -------------------------------------------------------------------------------- /components/api/sections/errors/oauth2.js: -------------------------------------------------------------------------------- 1 | import markdown from 'markdown-in-js' 2 | import Section, { components } from '../../section' 3 | import { Code } from '../../../text/code' 4 | import { InternalLink } from '../../../text/link' 5 | import immutable from '../../../../lib/immutable-component' 6 | 7 | function OAuth2() { 8 | return ( 9 |
    OAuth2 related endpoint}. 15 | ` 16 | ], 17 | [ 18 | markdown(components)` 19 | ### Client Not Found 20 | ` 21 | ], 22 | [ 23 | markdown(components)` 24 | The OAuth2 client ID could not be found or doesn't exists. 25 | `, 26 | markdown(components)` 27 | ${{`{ 28 | "error": { 29 | "code": "not_found", 30 | "message": "OAuth client doesn't not found: CLIENT_ID" 31 | } 32 | }`}} 33 | ` 34 | ] 35 | ]} 36 | /> 37 | ) 38 | } 39 | 40 | export default immutable(OAuth2) 41 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Zeit Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /components/api/deprecated.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class Deprecated extends React.PureComponent { 4 | render() { 5 | const { hash, children } = this.props 6 | const link = `/api${hash}` 7 | 8 | return ( 9 |
    10 | {children} 11 |
    DEPRECATED
    12 | 13 | 40 |
    41 | ) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /scripts/last-edited.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require('path') 2 | const fs = require('fs') 3 | const glob = require('glob') 4 | const { promisify } = require('util') 5 | const logger = console 6 | 7 | const getStats = promisify(fs.stat) 8 | const writeFile = promisify(fs.writeFile) 9 | const globPromise = promisify(glob) 10 | 11 | async function getFileStats() { 12 | const files = await globPromise(resolve('./pages/docs/**/*.js')) 13 | const stats = await Promise.all( 14 | files 15 | .map(file => file.split('/pages/')) 16 | .map(file => file[1]) 17 | .map(file => `pages/${file}`) 18 | .map(file => Promise.all([getStats(file), Promise.resolve(file)])) 19 | ) 20 | 21 | return stats 22 | .map(([stat, filePath]) => [stat.mtime, filePath]) 23 | .reduce( 24 | (results, [stat, filePath]) => ({ ...results, [filePath]: stat }), 25 | {} 26 | ) 27 | } 28 | 29 | async function main(fileStats) { 30 | const filePath = resolve('./lib/data/last-edited.json') 31 | await writeFile(filePath, JSON.stringify(fileStats, null, 2), 'utf8') 32 | logger.log('Last edited file updated') 33 | } 34 | 35 | getFileStats() 36 | .then(main) 37 | .catch(error => logger.error(error)) 38 | -------------------------------------------------------------------------------- /components/icons/github.js: -------------------------------------------------------------------------------- 1 | const GitHub = ({ light = false, height, width }) => ( 2 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | ) 19 | 20 | export default GitHub 21 | -------------------------------------------------------------------------------- /deploy-server/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const fileUpload = require('express-fileupload') 3 | const UUID = require('uuid') 4 | const deploy = require('./deploy') 5 | 6 | const logger = console 7 | const port = process.env.PORT || 8070 8 | const app = express() 9 | app.use(fileUpload()) 10 | 11 | app.post('/deploy/:pullRequestId', (req, res) => { 12 | if (!req.files || !req.files.app) { 13 | return res.status(400).send('Upload a file with the name "app"') 14 | } 15 | 16 | const { pullRequestId } = req.params 17 | 18 | // Use the mv() method to place the file somewhere on your server 19 | const tarballName = UUID.v4() 20 | logger.log(`Deploying pull request: ${pullRequestId}`) 21 | 22 | req.files.app.mv(`/tmp/${tarballName}.tar.gz`, err => { 23 | if (err) { 24 | return res.status(500).send(err) 25 | } 26 | 27 | deploy(pullRequestId, tarballName) 28 | .then(() => { 29 | res.send('SUCCESS') 30 | }) 31 | .catch(error => { 32 | logger.error(error.stack) 33 | return res.status(500).send(error) 34 | }) 35 | }) 36 | }) 37 | 38 | app.listen(port, () => { 39 | logger.log(`Deploy server started in port: ${port}\n`) 40 | }) 41 | -------------------------------------------------------------------------------- /lib/logout.js: -------------------------------------------------------------------------------- 1 | // Packages 2 | import NProgress from 'nprogress' 3 | import Cookies from 'js-cookie' 4 | 5 | // Helpers 6 | import { getToken } from './authenticate' 7 | import fetchAPI from './fetch-api' 8 | import { API_USER_TOKENS } from './api-endpoints' 9 | 10 | export default async () => { 11 | const token = getToken() 12 | NProgress.start() 13 | try { 14 | const { tokens } = await fetchAPI(API_USER_TOKENS, token, { 15 | throwOnHTTPError: true 16 | }) 17 | const tokenObj = tokens.find(t => token === t.token) 18 | await fetchAPI( 19 | `${API_USER_TOKENS}/${encodeURIComponent(tokenObj.id)}`, 20 | token, 21 | { 22 | method: 'DELETE', 23 | throwOnHTTPError: true 24 | } 25 | ) 26 | Cookies.remove('token') 27 | } catch (err) { 28 | // eslint-disable-next-line no-console 29 | console.error(err.stack) 30 | if (err.status === 403) { 31 | // we consider it already logged out 32 | // if the user doesn't have access to 33 | // own tokens 34 | Cookies.remove('token') 35 | return 36 | } 37 | if (err.code == null) { 38 | err.code = 'UNKNOWN' 39 | } 40 | throw err 41 | } finally { 42 | NProgress.done() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /components/api/sections/api-basics/errors.js: -------------------------------------------------------------------------------- 1 | import markdown from 'markdown-in-js' 2 | import React from 'react' 3 | import Section, { components } from '../../section' 4 | import { Code } from '../../../text/code' 5 | import { InternalLink } from '../../../text/link' 6 | import immutable from '../../../../lib/immutable-component' 7 | 8 | function Errors() { 9 | return ( 10 |
    Errors} section. 17 | 18 | Since the \`message\` is bound to change over time, we recommend you do not pass it along directly to end-users of your application. 19 | 20 | ${/*Finally, we provide a help link that will give you information about the specific error you just received to make debugging easier! This link is generic and not exclusive to your application or data.*/''} 21 | `, 22 | markdown(components)` 23 | All errors have the following format: 24 | 25 | ${{`{ 26 | "error": { 27 | "code": "error_code", 28 | "message": "An english description of the error that just occurred" 29 | } 30 | }`}} 31 | `, 32 | ] 33 | ] 34 | } 35 | /> 36 | ) 37 | } 38 | 39 | export default immutable(Errors) 40 | -------------------------------------------------------------------------------- /scripts/deploy.js: -------------------------------------------------------------------------------- 1 | /* 2 | Deploy to now and get the URL 3 | Deploy to now via the token 4 | Add a comment to the PR 5 | */ 6 | 7 | const shell = require('shelljs') 8 | const logger = console 9 | 10 | const { CI_PULL_REQUEST } = process.env 11 | 12 | async function run() { 13 | if (!CI_PULL_REQUEST || CI_PULL_REQUEST === '') return 14 | 15 | const [, PULL_REQUEST_ID] = CI_PULL_REQUEST.match(/\/([0-9]*)$/) 16 | 17 | // Build the app 18 | const build = shell.exec(`npm run build`) 19 | if (build.code !== 0) { 20 | throw new Error(build.stderr) 21 | } 22 | 23 | // Export the app 24 | const exportApp = shell.exec(`npm run export`) 25 | if (exportApp.code !== 0) { 26 | throw new Error(exportApp.stderr) 27 | } 28 | 29 | // Create a tarball version of the app 30 | const tarball = shell.exec(`tar czf app.tar.gz out`) 31 | if (tarball.code !== 0) { 32 | throw new Error(tarball.stderr) 33 | } 34 | 35 | // Upload the app to the deploy server 36 | const url = `https://docs-deploy-server.zeit.sh/deploy/${PULL_REQUEST_ID}` 37 | const upload = shell.exec(`curl -F "app=@app.tar.gz" ${url}`) 38 | if (upload.code !== 0) { 39 | throw new Error(upload.stderr) 40 | } 41 | 42 | if (upload.stdout !== 'SUCCESS') { 43 | throw new Error(`${upload.stdout}\n${upload.stdout}`) 44 | } 45 | } 46 | 47 | run().catch(error => { 48 | logger.error(error.stack) 49 | process.exit(1) 50 | }) 51 | -------------------------------------------------------------------------------- /components/table.js: -------------------------------------------------------------------------------- 1 | import PropTypes from 'prop-types' 2 | // Packages 3 | import React from 'react' 4 | 5 | const Table = ({ children }) => ( 6 | 7 | 8 | {children} 9 | 10 | 19 | 20 |
    21 | ) 22 | 23 | class Row extends React.Component { 24 | getChildContext() { 25 | return { 26 | header: this.props.header || false 27 | } 28 | } 29 | 30 | render() { 31 | return ( 32 | 33 | {this.props.children} 34 | 35 | 45 | 46 | ) 47 | } 48 | } 49 | 50 | Row.childContextTypes = { 51 | header: PropTypes.bool 52 | } 53 | 54 | const Column = ({ children }, context) => 55 | React.createElement( 56 | context.header ? 'th' : 'td', 57 | { 58 | style: { 59 | verticalAlign: 'top' 60 | } 61 | }, 62 | children 63 | ) 64 | 65 | Column.contextTypes = { 66 | header: PropTypes.bool 67 | } 68 | 69 | export { Table, Row, Column } 70 | -------------------------------------------------------------------------------- /components/freeze-page-scroll.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default class FreezePageScroll extends React.Component { 4 | // Make sure to unfreeze when unmounting the component 5 | componentWillUnmount() { 6 | this.freezeScrolling(false) 7 | } 8 | 9 | // Make sure to freeze if unmounted and re-mounted again while mouse is 10 | // still over the component 11 | register(ref) { 12 | if (!ref) return 13 | 14 | const onMove = () => { 15 | this.freezeScrolling(true) 16 | ref.removeEventListener('mousemove', onMove) 17 | } 18 | 19 | ref.addEventListener('mousemove', onMove) 20 | } 21 | 22 | freezeScrolling(enable) { 23 | const { body } = document 24 | if (enable) { 25 | // If already freezed we don't need to do anything 26 | if (/body-freeze-scroll/.test(body.className)) return 27 | body.className = `body-freeze-scroll ${body.className}` 28 | } else { 29 | body.className = body.className.replace('body-freeze-scroll', '').trim() 30 | } 31 | } 32 | 33 | render() { 34 | return ( 35 |
    this.register(r)} 37 | onMouseEnter={() => this.freezeScrolling(true)} 38 | onMouseLeave={() => this.freezeScrolling(false)} 39 | > 40 | {this.props.children} 41 | 46 |
    47 | ) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/authenticate.js: -------------------------------------------------------------------------------- 1 | // Helpers 2 | import fetchAPI from './fetch-api' 3 | import { API_USER } from './api-endpoints' 4 | 5 | const isServer = typeof window === 'undefined' 6 | 7 | export default (async function authenticate({ req }) { 8 | const token = getToken({ req }) 9 | if (!token) return {} 10 | 11 | if (!isServer) { 12 | // Sometimes, user in the client side global cache can be undefined. 13 | // So, we need to get the user again and assign the user to the global cache. 14 | if (!window.__user) { 15 | const { user } = await getUser(token) 16 | window.__user = user 17 | } 18 | 19 | return { user: window.__user, token } 20 | } 21 | 22 | const user = await getUser(token) 23 | return { ...user, token } 24 | }) 25 | 26 | export function getToken({ req } = {}) { 27 | if (req) { 28 | const parseCookie = require('cookie').parse 29 | const { cookie } = req.headers 30 | if (!cookie) return 31 | 32 | const { token } = parseCookie(cookie) 33 | return token 34 | } else { 35 | const Cookies = require('js-cookie') 36 | const { token } = Cookies.get() 37 | return token 38 | } 39 | } 40 | 41 | export async function getUser(token) { 42 | let res 43 | 44 | try { 45 | res = await fetchAPI(API_USER, token, { 46 | throwOnHTTPError: true 47 | }) 48 | } catch (err) { 49 | if (err.status && 403 === err.status) { 50 | return {} 51 | } 52 | throw err 53 | } 54 | 55 | return res 56 | } 57 | -------------------------------------------------------------------------------- /components/click-outside.js: -------------------------------------------------------------------------------- 1 | // Packages 2 | import { Component } from 'react' 3 | import PropTypes from 'prop-types' 4 | 5 | export default class ClickOutside extends Component { 6 | static propTypes = { 7 | active: PropTypes.bool, 8 | onClick: PropTypes.func, 9 | render: PropTypes.func 10 | } 11 | 12 | static defaultProps = { 13 | active: true 14 | } 15 | 16 | constructor(props) { 17 | super(props) 18 | this.handleRef = this.handleRef.bind(this) 19 | this.handleClick = this.handleClick.bind(this) 20 | } 21 | 22 | componentDidMount() { 23 | if (this.props.active) { 24 | document.addEventListener('click', this.handleClick) 25 | } 26 | } 27 | 28 | componentWillReceiveProps(nextProps) { 29 | if (!this.props.active && nextProps.active) { 30 | document.addEventListener('click', this.handleClick) 31 | } 32 | 33 | if (this.props.active && !nextProps.active) { 34 | document.removeEventListener('click', this.handleClick) 35 | } 36 | } 37 | 38 | componentWillUnmount() { 39 | if (this.props.active) { 40 | document.removeEventListener('click', this.handleClick) 41 | } 42 | } 43 | 44 | handleRef(element) { 45 | this.element = element 46 | } 47 | 48 | handleClick(event) { 49 | if (!this.element.contains(event.target)) { 50 | this.props.onClick(event) 51 | } 52 | } 53 | 54 | render() { 55 | return this.props.render({ 56 | innerRef: this.handleRef 57 | }) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /components/api/sections/api-basics/authentication.js: -------------------------------------------------------------------------------- 1 | import markdown from 'markdown-in-js' 2 | import Section, { components } from '../../section' 3 | import { Code } from '../../../text/code' 4 | import { ExternalLink } from '../../../text/link' 5 | import pure from '../../../../lib/pure-component' 6 | 7 | function Authentication(props) { 8 | const TOKEN = props.testingToken ? props.testingToken.token : '$TOKEN' 9 | 10 | return ( 11 |
    Authorization: Bearer {TOKEN}} 25 | 26 | ${https://api.zeit.co/example?teamId=team_123} 27 | 28 | > **NOTE:** ${props.user ? 'Since you\'re logged in, ' : ['When ', logged in, ',']} the examples in the API will contain your secret token. Don't share them! For example, to get a [list of deployments](/api/endpoints/get-endpoint) try the following: 29 | 30 | ${curl -H "Authorization: Bearer {TOKEN}" https://api.zeit.co/v2/now/deployments} 31 | ` 32 | ] 33 | ] 34 | } 35 | /> 36 | ) 37 | } 38 | 39 | export default pure(Authentication) 40 | -------------------------------------------------------------------------------- /components/api/request.js: -------------------------------------------------------------------------------- 1 | import { parse as parseURL } from 'url' 2 | 3 | import { Code } from '../text/code' 4 | 5 | function formatCurl({ url, method = 'GET', headers, body }) { 6 | let request = `curl ${method !== 'GET' ? `-X ${method} ` : ''}"${url}"` 7 | 8 | if (headers && Object.keys(headers).length > 0) { 9 | request = Object.entries(headers).reduce((req, [key, value]) => { 10 | return req + ` \\\n -H "${key}: ${value}"` 11 | }, request) 12 | } 13 | 14 | if (body) { 15 | if (typeof body !== 'string') { 16 | request = `${request} \\\n -d '${JSON.stringify(body, null, 2)}'` 17 | } else { 18 | request = `${request} \\\n -d '${body}'` 19 | } 20 | } 21 | 22 | return request 23 | } 24 | 25 | function formatJS({ url, ...opts }) { 26 | return `await fetch("${url}", ${JSON.stringify(opts, null, 2)})` 27 | } 28 | 29 | function formatHTTP({ url, method = 'GET', headers, body }) { 30 | const { path, host } = parseURL(url) 31 | 32 | return [ 33 | `${method} ${path} HTTP/1.1`, 34 | `Host: ${host}`, 35 | ...Object.entries(headers).map(([key, value]) => `${key}: ${value}`), 36 | JSON.stringify(body, null, 2) 37 | ].join('\n') 38 | } 39 | 40 | export default function Request({ type = 'curl', ...request }) { 41 | if (type === 'fetch' || type === 'js' || type === 'javascript') { 42 | return {formatJS(request)} 43 | } 44 | if (type === 'http') { 45 | return {formatHTTP(request)} 46 | } 47 | return {formatCurl(request)} 48 | } 49 | -------------------------------------------------------------------------------- /lib/data/team.js: -------------------------------------------------------------------------------- 1 | /* 2 | This isn't a JSON file or a single object because 3 | these solutions wouldn't enable code-splitting 4 | */ 5 | 6 | export const leo = { 7 | real: 'Leo Lamprecht', 8 | twitter: 'notquiteleo', 9 | zeit: 'leo' 10 | } 11 | 12 | export const rauchg = { 13 | real: 'Guillermo Rauch', 14 | twitter: 'rauchg', 15 | zeit: 'rauchg' 16 | } 17 | 18 | export const rase = { 19 | real: 'Tony Kovanen', 20 | twitter: 'tonykovanen', 21 | zeit: 'rase-' 22 | } 23 | 24 | export const nkzawa = { 25 | real: 'Naoyuki Kanezawa', 26 | twitter: 'nkzawa', 27 | zeit: 'nkzawa' 28 | } 29 | 30 | export const hbp = { 31 | real: 'Olli Vanhoja', 32 | twitter: 'OVanhoja', 33 | zeit: 'hbp_' 34 | } 35 | 36 | export const tootallnate = { 37 | real: 'Nathan Rajlich', 38 | twitter: 'tootallnate', 39 | zeit: 'tootallnate' 40 | } 41 | 42 | export const jamo = { 43 | real: 'Jarmo Isotalo', 44 | twitter: 'JarmoIsotalo', 45 | zeit: 'jamo' 46 | } 47 | 48 | export const arunoda = { 49 | real: 'Arunoda Susiripala', 50 | twitter: 'arunoda', 51 | zeit: 'arunoda' 52 | } 53 | 54 | export const tim = { 55 | real: 'Tim Neutkens', 56 | twitter: 'timneutkens', 57 | zeit: 'timneutkens' 58 | } 59 | 60 | export const matheus = { 61 | real: 'Matheus Fernandes', 62 | twitter: 'matheusfrndes', 63 | zeit: 'matheus' 64 | } 65 | 66 | export const sergio = { 67 | real: 'Sergio Xalambrí', 68 | twitter: 'sergiodxa', 69 | zeit: 'sergiodxa' 70 | } 71 | export const devisscher = { 72 | real: 'Thomas Devisscher', 73 | twitter: 'devisscher', 74 | zeit: 'devisscher' 75 | } 76 | -------------------------------------------------------------------------------- /pages/_document.js: -------------------------------------------------------------------------------- 1 | import Document_, { Head, Main, NextScript } from 'next/document' 2 | import isIE11_ from '../lib/is-ie-11' 3 | import htmlescape from 'htmlescape' 4 | 5 | const { API_URL, NOW_API_URL } = process.env 6 | const env = { API_URL, NOW_API_URL } 7 | 8 | export default class Document extends Document_ { 9 | static async getInitialProps(ctx) { 10 | const props = await Document_.getInitialProps(ctx) 11 | const ua = String(ctx.req.headers && ctx.req.headers['user-agent']) 12 | return { 13 | ...props, 14 | isIE11: isIE11_(ua) 15 | } 16 | } 17 | 18 | render() { 19 | return ( 20 | 21 | 22 | 23 |
    24 |