├── .nvmrc
├── .yarnrc
├── base-commit.json
├── components
├── intersection-observer
│ ├── index.js
│ ├── utils.js
│ ├── manager.js
│ └── intersection-observer.js
├── hoc
│ └── pure.js
├── icons
│ ├── arrow-right.js
│ └── github.js
├── docs
│ ├── text
│ │ ├── quotes.js
│ │ ├── headings.js
│ │ ├── code.js
│ │ └── link.js
│ ├── head.js
│ ├── documentation.js
│ ├── heading.js
│ ├── sidebar.js
│ └── docs.mdx
├── contributions
│ ├── contributor.js
│ └── contributions.mdx
├── media-query.js
├── logo.js
├── container.js
├── header.js
├── navbar.js
└── page.js
├── .gitignore
├── public
└── static
│ └── favicon
│ ├── favicon.ico
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── mstile-150x150.png
│ ├── apple-touch-icon.png
│ ├── android-chrome-192x192.png
│ ├── android-chrome-512x512.png
│ ├── browserconfig.xml
│ ├── site.webmanifest
│ └── safari-pinned-tab.svg
├── scripts
├── copy-latest-target.sh
└── show-lastest-commit.sh
├── .editorconfig
├── lib
├── polyfill.js
└── rehype-readme.js
├── .eslintrc.json
├── pages
├── index.js
├── contribution
│ └── index.js
├── _document.js
└── docs
│ └── index.js
├── README.md
├── next.config.js
└── package.json
/.nvmrc:
--------------------------------------------------------------------------------
1 | lts/erbium
2 |
--------------------------------------------------------------------------------
/.yarnrc:
--------------------------------------------------------------------------------
1 | save-prefix ""
2 |
--------------------------------------------------------------------------------
/base-commit.json:
--------------------------------------------------------------------------------
1 | {
2 | "ref": "d16f39a20bbdcaf821480817bc283ab2ead3aa64"
3 | }
4 |
--------------------------------------------------------------------------------
/components/intersection-observer/index.js:
--------------------------------------------------------------------------------
1 | export { default } from './intersection-observer';
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .next
2 | .idea
3 | node_modules
4 | .DS_Store
5 | .vscode
6 | out
7 | yarn-error.log
8 | bundles
9 |
--------------------------------------------------------------------------------
/public/static/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nextjs-ja-translation/nextjs-docs-ja/HEAD/public/static/favicon/favicon.ico
--------------------------------------------------------------------------------
/public/static/favicon/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nextjs-ja-translation/nextjs-docs-ja/HEAD/public/static/favicon/favicon-16x16.png
--------------------------------------------------------------------------------
/public/static/favicon/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nextjs-ja-translation/nextjs-docs-ja/HEAD/public/static/favicon/favicon-32x32.png
--------------------------------------------------------------------------------
/public/static/favicon/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nextjs-ja-translation/nextjs-docs-ja/HEAD/public/static/favicon/mstile-150x150.png
--------------------------------------------------------------------------------
/public/static/favicon/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nextjs-ja-translation/nextjs-docs-ja/HEAD/public/static/favicon/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/static/favicon/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nextjs-ja-translation/nextjs-docs-ja/HEAD/public/static/favicon/android-chrome-192x192.png
--------------------------------------------------------------------------------
/public/static/favicon/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nextjs-ja-translation/nextjs-docs-ja/HEAD/public/static/favicon/android-chrome-512x512.png
--------------------------------------------------------------------------------
/scripts/copy-latest-target.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | dst_path="./components/docs/docs.mdx"
4 |
5 | curl -o "${dst_path}" https://raw.githubusercontent.com/5t111111/nextjs-docs-ja-omegat/master/target/docs.mdx
6 |
--------------------------------------------------------------------------------
/scripts/show-lastest-commit.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | pushd $NEXT_SITE_REPOSITORY_PATH > /dev/null
4 | latest_commit=$(git log --pretty=format:'%h' -n 1 -- components/docs/docs.mdx)
5 | echo $latest_commit
6 | popd > /dev/null
7 |
8 |
--------------------------------------------------------------------------------
/components/hoc/pure.js:
--------------------------------------------------------------------------------
1 | import { PureComponent } from 'react'
2 |
3 | export default function (Comp) {
4 | return class extends PureComponent {
5 | render () {
6 | return
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [{package.json,*.yml}]
12 | indent_style = space
13 | indent_size = 2
--------------------------------------------------------------------------------
/components/icons/arrow-right.js:
--------------------------------------------------------------------------------
1 | export default () =>
2 |
11 |
--------------------------------------------------------------------------------
/lib/polyfill.js:
--------------------------------------------------------------------------------
1 | import "core-js/fn/array/find";
2 | import "core-js/fn/array/find-index";
3 | import "core-js/fn/array/from";
4 | import "core-js/fn/object/entries";
5 | import "core-js/fn/object/values";
6 | import "core-js/fn/symbol/iterator";
7 | import "core-js/fn/string/starts-with";
8 |
--------------------------------------------------------------------------------
/public/static/favicon/browserconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | #000000
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/components/docs/text/quotes.js:
--------------------------------------------------------------------------------
1 | export const Blockquote = ({ children, ...props }) => (
2 |
3 | {children}
4 |
5 |
20 |
21 | );
22 |
--------------------------------------------------------------------------------
/public/static/favicon/site.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Next.js",
3 | "short_name": "Next.js",
4 | "icons": [
5 | {
6 | "src": "/static/favicons/android-chrome-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png"
9 | },
10 | {
11 | "src": "/static/favicons/android-chrome-512x512.png",
12 | "sizes": "512x512",
13 | "type": "image/png"
14 | }
15 | ],
16 | "theme_color": "#000000",
17 | "background_color": "#000000",
18 | "display": "standalone"
19 | }
20 |
--------------------------------------------------------------------------------
/components/contributions/contributor.js:
--------------------------------------------------------------------------------
1 | export default props => {
2 | return (
3 |
4 |
5 |

10 |
11 |
16 |
17 | );
18 | };
19 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": ["airbnb", "prettier", "prettier/react"],
4 | "env": {
5 | "browser": true
6 | },
7 | "rules": {
8 | "react/react-in-jsx-scope": 0,
9 | "react/prop-types": 0,
10 | "react/jsx-filename-extension": 0,
11 | "react/destructuring-assignment": 0,
12 | "jsx-a11y/anchor-is-valid": 0,
13 | "no-nested-ternary": 0,
14 | "array-callback-return": 0,
15 | "consistent-return": 0,
16 | "no-param-reassign": 0,
17 | "lines-between-class-members": 0,
18 | "global-require": 0,
19 | "import/prefer-default-export": 0,
20 | "import/no-extraneous-dependencies": 0
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/components/icons/github.js:
--------------------------------------------------------------------------------
1 | export default () =>
2 |
6 |
--------------------------------------------------------------------------------
/pages/index.js:
--------------------------------------------------------------------------------
1 | import withPure from '../components/hoc/pure';
2 |
3 | const Content = withPure(() => (
4 |
35 | ));
36 |
37 | export default () => ;
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # nextjs-docs-ja
2 |
3 | [Next.js の公式ドキュメント](https://nextjs.org/docs/)を日本語に翻訳し公開するためのプロジェクトです。
4 |
5 | ## 翻訳対象
6 |
7 | 翻訳対象の元ファイルはこちらです。
8 |
9 | https://github.com/zeit/next-site/blob/master/components/docs/docs.mdx
10 |
11 | [components/docs/docs.mdx](https://github.com/5t111111/nextjs-docs-ja/blob/master/components/docs/docs.mdx) が日本語訳されたファイルになります。
12 |
13 | ## 翻訳プロジェクトを手伝ってくれる方へ
14 |
15 | 翻訳を手伝っていただける方を募集しています。
16 |
17 | - 翻訳を追加や修正
18 | - サイトの改善
19 |
20 | などをやっていただける場合、一般的な GitHub リポジトリ同様に pull-request を出していただければ取り込みます。
21 |
22 | 翻訳自体の作業は、翻訳メモリを利用するために以下のプロジェクトで OmegaT という翻訳ツールを利用していますが、メンテナが翻訳メモリへの反映を行いますので、翻訳に貢献いただける方は気にする必要はありません。
23 | https://github.com/5t111111/nextjs-docs-omegat
24 |
25 | ## 翻訳のベースコミット
26 |
27 | 翻訳元に更新があったことを検知するため、翻訳元となるファイルのコミットへの参照を記録したファイルを用意しています。
28 |
29 | - [base-commit.json](https://github.com/5t111111/nextjs-docs-ja/blob/master/base-commit.json)
30 |
31 | 翻訳に貢献いただく際は、基本的に上記コミットをベースとしてくださいますようお願いします。
32 |
--------------------------------------------------------------------------------
/pages/contribution/index.js:
--------------------------------------------------------------------------------
1 | import Page from '../../components/page';
2 | import Header from '../../components/header';
3 | import Navbar from '../../components/navbar';
4 | import Container from '../../components/container';
5 | import { MediaQueryConsumer } from '../../components/media-query';
6 | import withPure from '../../components/hoc/pure';
7 |
8 | import Markdown from '../../components/contributions/contributions.mdx';
9 | import { components } from '../../components/docs/documentation';
10 |
11 | const Content = withPure(() => );
12 |
13 | export default () => (
14 |
15 |
16 | {({ isMobile }) => (
17 |
24 | )}
25 |
26 |
27 |
28 |
29 |
30 | );
31 |
--------------------------------------------------------------------------------
/components/contributions/contributions.mdx:
--------------------------------------------------------------------------------
1 | import Contributor from "./contributor.js";
2 |
3 | ## 貢献
4 |
5 | ### Next.js 公式ドキュメント翻訳プロジェクトメンテナ一覧
6 |
7 |
12 |
13 | ### Next.js 公式ドキュメント翻訳プロジェクト貢献者一覧
14 |
15 |
20 |
25 |
30 |
35 |
--------------------------------------------------------------------------------
/components/docs/head.js:
--------------------------------------------------------------------------------
1 | import Head from "next/head";
2 |
3 | export default ({ children, ...props }) => (
4 |
5 | {`Documentation - ${props.title} | Next.js`}
6 |
10 |
11 |
12 | {props.description ? (
13 |
14 | ) : null}
15 | {props.ogDescription ? (
16 |
17 | ) : (
18 |
19 | )}
20 | {props.video
21 | ? [
22 | ,
23 | ,
24 |
25 | ]
26 | : null}
27 |
28 | {children}
29 |
30 | );
31 |
--------------------------------------------------------------------------------
/components/docs/text/headings.js:
--------------------------------------------------------------------------------
1 | const H1 = ({ children, ...props }) => (
2 |
3 | {children}
4 |
5 |
10 |
11 | );
12 |
13 | const H2 = ({ children, ...props }) => (
14 |
15 | {children}
16 |
17 |
21 |
22 | );
23 |
24 | const H3 = ({ children, ...props }) => (
25 |
26 | {children}
27 |
28 |
32 |
33 | );
34 |
35 | const H4 = ({ children, ...props }) => (
36 |
37 | {children}
38 |
39 |
43 |
44 | );
45 |
46 | const H5 = ({ children, ...props }) => (
47 |
48 | {children}
49 |
50 |
55 |
56 | );
57 |
58 | export { H1, H2, H3, H4, H5 };
59 |
--------------------------------------------------------------------------------
/components/media-query.js:
--------------------------------------------------------------------------------
1 | import React, { PureComponent } from "react";
2 |
3 | const {
4 | Provider: MediaQueryProvider,
5 | Consumer: MediaQueryConsumer
6 | } = React.createContext({
7 | isMobile: false,
8 | isTablet: false
9 | });
10 |
11 | const withMediaQuery = Comp =>
12 | class extends PureComponent {
13 | state = {
14 | isMobile: false,
15 | isTablet: false
16 | };
17 | componentDidMount() {
18 | window.addEventListener("resize", this.onResize);
19 | this.onResize();
20 | }
21 | componentWillUnmount() {
22 | window.removeEventListener("resize", this.onResize);
23 | }
24 | onResize = () => {
25 | const isMobile = window.innerWidth < 640;
26 | const isTablet = window.innerWidth < 960;
27 |
28 | if (isMobile !== this.state.isMobile) {
29 | this.setState({ isMobile });
30 | }
31 | if (isTablet !== this.state.isTablet) {
32 | this.setState({ isTablet });
33 | }
34 | };
35 | render() {
36 | const { isMobile, isTablet } = this.state;
37 |
38 | return (
39 |
40 |
41 |
42 | );
43 | }
44 | };
45 |
46 | export { MediaQueryProvider, MediaQueryConsumer, withMediaQuery };
47 |
--------------------------------------------------------------------------------
/components/docs/text/code.js:
--------------------------------------------------------------------------------
1 | export const Code = ({ children, syntax }) => (
2 |
3 | {children}
4 |
21 |
22 | );
23 |
24 | export const InlineCode = ({ children, wrap = false }) => (
25 |
26 | {children}
27 |
57 |
58 | );
59 |
--------------------------------------------------------------------------------
/components/logo.js:
--------------------------------------------------------------------------------
1 | import withPure from "./hoc/pure";
2 |
3 | export default withPure(({ size }) => (
4 |
22 | ));
23 |
--------------------------------------------------------------------------------
/next.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const webpack = require("webpack");
3 | const rehypePrism = require("@mapbox/rehype-prism");
4 | const nextMDX = require("@next/mdx");
5 | const rehypeReadme = require("./lib/rehype-readme");
6 |
7 | // only enable rehypeReadme for this file
8 | // because the github relative path replacement
9 | // might break things in other markdowns
10 | const withGitHubMDX = nextMDX({
11 | extension: path.join(__dirname, "components", "docs", "docs.mdx"),
12 | options: {
13 | hastPlugins: [
14 | rehypePrism,
15 | [
16 | rehypeReadme,
17 | {
18 | repo: "zeit/next.js",
19 | branch: "master",
20 | level: 4
21 | }
22 | ]
23 | ]
24 | }
25 | });
26 |
27 | const withContributionMDX = nextMDX({
28 | extension: path.join(
29 | __dirname,
30 | "components",
31 | "contributions",
32 | "contributions.mdx"
33 | )
34 | });
35 |
36 | const withMDX = nextMDX({
37 | extension: /\/(pages)\/(.+)\.mdx?$/,
38 | options: {
39 | hastPlugins: [rehypePrism]
40 | }
41 | });
42 |
43 | const config = {
44 | pageExtensions: ["jsx", "js", "mdx"],
45 | webpack: (config, { dev, isServer }) => {
46 | config.plugins = config.plugins || [];
47 | config.plugins.push(
48 | new webpack.ContextReplacementPlugin(
49 | /highlight\.js[\/\\]lib[\/\\]languages$/,
50 | new RegExp(`^./(${["javascript", "json", "xml"].join("|")})$`)
51 | )
52 | );
53 |
54 | return config;
55 | }
56 | };
57 |
58 | module.exports = withContributionMDX(withGitHubMDX(withMDX(config)));
59 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nextjs-docs-ja",
3 | "description": "Japanese Translation of Next.js Official documents",
4 | "version": "1.0.0",
5 | "repository": "5t111111/nextjs-docs-ja",
6 | "license": "MIT",
7 | "engines": {
8 | "node": ">=10.x"
9 | },
10 | "scripts": {
11 | "dev": "next",
12 | "build": "next build",
13 | "export": "next export",
14 | "start": "next start",
15 | "lint": "eslint"
16 | },
17 | "dependencies": {
18 | "@mapbox/rehype-prism": "^0.3.1",
19 | "@mdx-js/loader": "0.20.3",
20 | "@mdx-js/mdx": "0.20.3",
21 | "@mdx-js/tag": "0.20.3",
22 | "@next/mdx": "9.1.4",
23 | "babel-plugin-module-resolver": "^3.2.0",
24 | "classnames": "^2.2.6",
25 | "date-fns": "^2.8.1",
26 | "github-slugger": "1.2.1",
27 | "highlight.js": "^9.16.2",
28 | "intersection-observer": "^0.7.0",
29 | "mitt": "^1.2.0",
30 | "next": "9.1.4",
31 | "polished": "^3.4.2",
32 | "prop-types": "^15.7.2",
33 | "react": "^16.12.0",
34 | "react-dom": "^16.12.0",
35 | "react-frame-component": "^4.1.1",
36 | "react-highlight": "^0.12.0",
37 | "react-spring": "^8.0.27",
38 | "react-virtualized": "^9.21.2",
39 | "scroll-into-view-if-needed": "^2.2.20",
40 | "unist-util-visit": "2.0.1"
41 | },
42 | "devDependencies": {
43 | "babel-eslint": "^10.0.3",
44 | "eslint": "^6.7.2",
45 | "eslint-config-airbnb": "^18.0.1",
46 | "eslint-config-prettier": "6.7.0",
47 | "eslint-plugin-import": "^2.18.2",
48 | "eslint-plugin-jsx-a11y": "^6.2.3",
49 | "eslint-plugin-react": "^7.17.0",
50 | "prettier": "^1.19.1"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/components/docs/text/link.js:
--------------------------------------------------------------------------------
1 | import NativeLink from "next/link";
2 |
3 | export const GenericLink = props => {
4 | if (props.href.startsWith("/") && !props.href.startsWith("/docs")) {
5 | return ;
6 | }
7 |
8 | if (props.href.includes("@") || props.href.startsWith("#")) {
9 | return ;
10 | }
11 |
12 | return ;
13 | };
14 |
15 | export const InternalLink = ({ href, as, children, error = false }) => (
16 |
17 |
18 | {children}
19 |
20 |
30 |
31 |
32 | );
33 |
34 | export const AnchorLink = ({ href, onClick, children }) => (
35 |
36 | {children}
37 |
38 |
52 |
53 | );
54 |
55 | export const ExternalLink = ({ href, children }) => (
56 |
57 | {children}
58 |
59 |
67 |
68 | );
69 |
--------------------------------------------------------------------------------
/components/intersection-observer/utils.js:
--------------------------------------------------------------------------------
1 | export function isDOMNode(node) {
2 | return (
3 | node && Object.prototype.hasOwnProperty.call(node, 'getBoundingClientRect')
4 | );
5 | }
6 |
7 | export function parseOptions(options = {}) {
8 | return {
9 | root: options.root || null,
10 | rootMargin: parseRootMargin(options.rootMargin),
11 | threshold: parseThreshold(options.threshold)
12 | };
13 | }
14 |
15 | export function hasEqualOptions(observer, options) {
16 | return (
17 | equalPair(options.root, observer.root) &&
18 | equalPair(options.rootMargin, observer.rootMargin) &&
19 | equalPair(options.threshold, observer.thresholds)
20 | );
21 | }
22 |
23 | function parseRootMargin(rootMargin) {
24 | const margins = (rootMargin || '0px').trim().split(/\s+/);
25 | margins.forEach(validateRootMargin);
26 | margins[1] = margins[1] || margins[0];
27 | margins[2] = margins[2] || margins[0];
28 | margins[3] = margins[3] || margins[1];
29 | return margins.join(' ');
30 | }
31 |
32 | function validateRootMargin(margin) {
33 | if (!/^-?\d*\.?\d+(px|%)$/.test(margin)) {
34 | throw new Error('rootMargin must be specified as a CSS margin property');
35 | }
36 | }
37 |
38 | function parseThreshold(threshold) {
39 | return !Array.isArray(threshold)
40 | ? [typeof threshold !== 'undefined' ? threshold : 0]
41 | : threshold;
42 | }
43 |
44 | function equalPair(optionA, optionB) {
45 | if (Array.isArray(optionA) && Array.isArray(optionB)) {
46 | if (optionA.length === optionB.length) {
47 | return optionA.every((element, idx) =>
48 | equalPair(optionA[idx], optionB[idx])
49 | );
50 | }
51 | }
52 | return optionA === optionB;
53 | }
54 |
--------------------------------------------------------------------------------
/pages/_document.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable react/no-danger */
2 | import Document, { Head, Main, NextScript } from "next/document";
3 |
4 | export default class NextSite extends Document {
5 | render() {
6 | return (
7 |
8 |
9 |
13 | Next.js
14 |
15 |
20 |
26 |
32 |
33 |
38 |
39 |
40 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | );
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/components/intersection-observer/manager.js:
--------------------------------------------------------------------------------
1 | import { hasEqualOptions, parseOptions } from './utils';
2 |
3 | if (typeof window !== 'undefined') {
4 | require('intersection-observer');
5 | }
6 |
7 | const manager = (function makeManager() {
8 | const observers = new Map();
9 |
10 | function getObserver(options) {
11 | return (
12 | findObserver(options) ||
13 | new IntersectionObserver(intersectionCallback, options)
14 | );
15 | }
16 |
17 | function findObserver(options = {}) {
18 | const parsedOptions = parseOptions(options);
19 | for (const observer of observers.keys()) {
20 | if (hasEqualOptions(observer, parsedOptions)) {
21 | return observer;
22 | }
23 | }
24 | return null;
25 | }
26 |
27 | function getObserverTargets(observer) {
28 | return !observers.has(observer)
29 | ? observers.set(observer, new Map()).get(observer)
30 | : observers.get(observer);
31 | }
32 |
33 | function observeTarget(observer, target, handler) {
34 | const targets = getObserverTargets(observer);
35 | targets.set(target, handler);
36 | observer.observe(target);
37 | }
38 |
39 | function unobserveTarget(observer, target) {
40 | const handlers = getObserverTargets(observer);
41 | handlers.delete(target);
42 | observer.unobserve(target);
43 | }
44 |
45 | function intersectionCallback(entries, observer) {
46 | for (let entry of entries) {
47 | const handlers = getObserverTargets(observer);
48 | const handler = handlers.get(entry.target);
49 | if (handler) {
50 | handler(entry);
51 | }
52 | }
53 | }
54 |
55 | return {
56 | getObserver,
57 | observeTarget,
58 | unobserveTarget
59 | };
60 | })();
61 |
62 | export default manager;
63 | export const { getObserver } = manager;
64 | export const { observeTarget } = manager;
65 | export const { unobserveTarget } = manager;
66 |
--------------------------------------------------------------------------------
/public/static/favicon/safari-pinned-tab.svg:
--------------------------------------------------------------------------------
1 |
2 |
4 |
34 |
--------------------------------------------------------------------------------
/pages/docs/index.js:
--------------------------------------------------------------------------------
1 | import Page from "../../components/page";
2 | import Header from "../../components/header";
3 | import Navbar from "../../components/navbar";
4 | import Container from "../../components/container";
5 | import { MediaQueryConsumer } from "../../components/media-query";
6 | import withPure from "../../components/hoc/pure";
7 |
8 | import Markdown, { headings } from "../../components/docs/docs.mdx";
9 | import Documentation, { components } from "../../components/docs/documentation";
10 | import baseCommit from "../../base-commit.json";
11 |
12 | const Content = withPure(() => );
13 |
14 | const TranslationInformation = () => {
15 | const baseCommitUrl = `https://github.com/zeit/next-site/tree/${baseCommit.ref}`;
16 |
17 | return (
18 |
48 | );
49 | };
50 |
51 | export default () => (
52 |
53 |
54 | {({ isMobile }) => (
55 |
62 | )}
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | );
72 |
--------------------------------------------------------------------------------
/components/container.js:
--------------------------------------------------------------------------------
1 | export default function Container({
2 | center,
3 | vCenter,
4 | dark,
5 | gray,
6 | wide,
7 | small,
8 | padding,
9 | overflow,
10 | minHeight,
11 | dotBackground,
12 | children,
13 | mobileStyle,
14 | divider,
15 | ...props
16 | }) {
17 | return (
18 |
19 |
71 | {children}
72 |
73 | );
74 | }
75 |
--------------------------------------------------------------------------------
/components/intersection-observer/intersection-observer.js:
--------------------------------------------------------------------------------
1 | // Packages
2 | import { Component, cloneElement, Children } from 'react';
3 | import { findDOMNode } from 'react-dom';
4 | import PropTypes from 'prop-types';
5 |
6 | // Private Observer Manager functions and manager
7 | import { getObserver, observeTarget, unobserveTarget } from './manager';
8 | import { hasEqualOptions, isDOMNode } from './utils';
9 |
10 | export default class Observer extends Component {
11 | static propTypes = {
12 | disabled: PropTypes.bool,
13 | once: PropTypes.bool,
14 | onIntersect: PropTypes.func.isRequired,
15 | render: PropTypes.func,
16 | root: PropTypes.element,
17 | rootMargin: PropTypes.string,
18 | threshold: PropTypes.oneOfType([
19 | PropTypes.arrayOf(PropTypes.number),
20 | PropTypes.number
21 | ]),
22 | value: PropTypes.string
23 | };
24 |
25 | static defaultProps = {
26 | disabled: false,
27 | once: false
28 | };
29 |
30 | shouldReobserve = false;
31 |
32 | componentDidMount() {
33 | this.observer = getObserver(getOptions(this.props));
34 | this.observe();
35 | }
36 |
37 | UNSAFE_componentWillReceiveProps(nextProps) {
38 | const nextOptions = getOptions(nextProps);
39 | if (!hasEqualOptions(this.observer, nextOptions)) {
40 | this.unobserve();
41 | this.observer = getObserver(nextOptions);
42 | this.shouldReobserve = true;
43 | }
44 |
45 | if (this.props.disabled && !nextProps.disabled) {
46 | this.shouldReobserve = true;
47 | }
48 |
49 | if (!this.props.disabled && nextProps.disabled) {
50 | this.unobserve();
51 | }
52 | }
53 |
54 | componentDidUpdate() {
55 | if (this.shouldReobserve) {
56 | this.observe();
57 | this.shouldReobserve = false;
58 | }
59 | }
60 |
61 | componentWillUnmount() {
62 | this.unobserve();
63 | }
64 |
65 | handleTarget = node => {
66 | // eslint-disable-next-line
67 | const element = isDOMNode(node) ? node : findDOMNode(node);
68 | if (this.target && this.target !== element) {
69 | this.unobserve();
70 | this.shouldReobserve = true;
71 | }
72 | this.target = element;
73 | };
74 |
75 | observe() {
76 | if (!this.props.disabled) {
77 | observeTarget(this.observer, this.target, this.handleIntersect);
78 | }
79 | }
80 |
81 | unobserve() {
82 | unobserveTarget(this.observer, this.target);
83 | }
84 |
85 | handleIntersect = entry => {
86 | this.props.onIntersect(entry, this.props.value);
87 | if (this.props.once && entry.isIntersecting) {
88 | this.unobserve();
89 | }
90 | };
91 |
92 | render() {
93 | return this.props.render
94 | ? this.props.render({ innerRef: this.handleTarget })
95 | : cloneElement(Children.only(this.props.children), {
96 | ref: this.handleTarget
97 | });
98 | }
99 | }
100 |
101 | const getOptions = props => ({
102 | root: props.root,
103 | rootMargin: props.rootMargin,
104 | threshold: props.threshold
105 | });
106 |
--------------------------------------------------------------------------------
/components/header.js:
--------------------------------------------------------------------------------
1 | import React, { PureComponent } from "react";
2 | import classNames from "classnames";
3 | import { useAmp } from "next/amp";
4 |
5 | export default function Header(props) {
6 | const {
7 | height,
8 | shadow,
9 | zIndex,
10 | background,
11 | defaultActive,
12 | dotBackground,
13 | children
14 | } = props;
15 | const isAmp = useAmp();
16 |
17 | const desktopHeight = height.desktop || Number(height) || 0;
18 | const mobileHeight = height.mobile || desktopHeight;
19 | const tabletHeight = height.tablet || desktopHeight;
20 |
21 | const desktopShadow =
22 | shadow.desktop || (typeof shadow === "boolean" ? shadow : false);
23 | const tabletShadow =
24 | shadow.tablet || (typeof shadow === "boolean" ? shadow : false);
25 | const mobileShadow =
26 | shadow.mobile || (typeof shadow === "boolean" ? shadow : false);
27 |
28 | return (
29 |
30 |
35 | {children}
36 |
37 |
100 |
101 | );
102 | }
103 |
--------------------------------------------------------------------------------
/components/docs/documentation.js:
--------------------------------------------------------------------------------
1 | import Head from "./head";
2 | import { H1, H2, H3, H4, H5 } from "./text/headings";
3 | import { Blockquote } from "./text/quotes";
4 | import { InlineCode, Code } from "./text/code";
5 | import { GenericLink } from "./text/link";
6 | import Heading from "./heading";
7 | import Sidebar from "./sidebar";
8 |
9 | export default function Documentation({ children, headings }) {
10 | return (
11 | <>
12 |