Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 6a34b74

Browse files
author
BSKY
authored
Merge pull request #228 from Sliip831143/master
Translate docs/docs/custom-html.md
2 parents 1ecea71 + 2210808 commit 6a34b74

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

docs/docs/custom-html.md

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
11
---
2-
title: Customizing html.js
2+
title: html.js をカスタマイズする
33
---
44

5-
Gatsby uses a React component to server render the `<head>` and other parts of
6-
the HTML outside of the core Gatsby application.
5+
Gatsby は React コンポーネントを利用して、コア Gatsby アプリケーションの外部で HTML の `<head>` およびその他のパーツをサーバーレンダリングします。
76

8-
Most sites should use the default `html.js` shipped with Gatsby. But if you need
9-
to customize your site's html.js, copy the default one into your source
10-
tree by running:
7+
ほとんどのサイトでは Gatsby に同梱されているデフォルトの `html.js` を利用するべきです。しかしサイトの html.js をカスタマイズする必要がある場合には、デフォルトのものをソースツリーにコピーします。
118

129
```shell
1310
cp .cache/default-html.js src/html.js
1411
```
1512

16-
And then make modifications as needed.
13+
そして、必要に応じて変更を加えます。
1714

18-
If you need to insert custom html into the `<head>` or `<footer>` of each page on your site, you can use `html.js`.
15+
もしサイト各ページの `<head>` または `<footer>` にカスタム html を挿入する必要がある場合は、`html.js` が利用できます。
1916

20-
> Customizing `html.js` is a workaround solution for when the use of the appropriate APIs is not available in `gatsby-ssr.js`. Consider using [`onRenderBody`](/docs/ssr-apis/#onRenderBody) or [`onPreRenderHTML`](/docs/ssr-apis/#onPreRenderHTML) instead of the method above.
21-
> As a further consideration, customizing `html.js` is not supported within a Gatsby Theme. Use the API methods mentioned instead.
17+
> `html.js` のカスタマイズは、`gatsby-ssr.js` で適切な API を利用できない場合の回避策です。上記方法の代わりに [`onRenderBody`](/docs/ssr-apis/#onRenderBody) または [`onPreRenderHTML`](/docs/ssr-apis/#onPreRenderHTML) の利用も検討してください。
18+
> さらなる考慮事項として、Gatsby テーマ内での `html.js` のカスタマイズはサポートされていません。先述の API メソッドを利用してください。
2219
23-
## Required props
20+
## 必須なプロパティ
2421

25-
Note: the various props that are rendered into pages _are_ required e.g.
26-
`headComponents`, `preBodyComponents`, `body`, and `postBodyComponents`.
22+
ヒント: 例えば `headComponents``preBodyComponents``body``postBodyComponents` _など_、ページにレンダリングされる様々なプロパティが必要です。
2723

28-
## Inserting html into the `<head>`
24+
## `<head>` に html を挿入する
2925

30-
Anything you render in the `html.js` component will _not_ be made "live" in
31-
the client like other components. If you want to dynamically update your
32-
`<head>` we recommend using
33-
[React Helmet](/packages/gatsby-plugin-react-helmet/)
26+
`html.js` コンポーネントでレンダリングしたものは、他のコンポーネントのようにクライアントで動的に更新されることは*ありません*。もし `<head>` を動的に更新したいときは、[React Helmet](/packages/gatsby-plugin-react-helmet/) の利用を推奨します。
3427

35-
## Inserting html into the `<footer>`
28+
## `<footer>` に html を挿入する
3629

37-
If you want to insert custom html into the footer, html.js is the preferred way of doing this. If you're writing a plugin, consider using the `setPostBodyComponents` prop in the [Gatsby SSR API](/docs/ssr-apis/).
30+
もしカスタム html をフッターに挿入したいときは、html.js の利用を推奨します。独自のプラグインを作成している場合は、[Gatsby SSR API](/docs/ssr-apis/)`setPostBodyComponents` プロップの利用を検討してください。
3831

39-
## Target container
32+
## ターゲットコンテナ
4033

41-
If you see this error: `Uncaught Error: _registerComponent(...): Target container is not a DOM element.` it means your `html.js` is missing the required
42-
"target container". Inside your `<body>` you must have a div with an id of
43-
`___gatsby` like:
34+
エラー: `Uncaught Error: _registerComponent(...): Target container is not a DOM element.` が表示される場合、`html.js` に必要な "ターゲットコンテナ" が存在しないことを意味します。`<body>` 内に以下のような `___gatsby` の id を持つ div を必要とします。
4435

4536
```jsx:title=src/html.js
4637
<div
@@ -50,9 +41,9 @@ If you see this error: `Uncaught Error: _registerComponent(...): Target containe
5041
/>
5142
```
5243

53-
## Adding custom JavaScript
44+
## カスタム JavaScript の追加
5445

55-
You can add custom JavaScript to your HTML document by using React's [dangerouslySetInnerHTML](https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml) attribute.
46+
React[dangerouslySetInnerHTML](https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml) 属性を利用して、HTML ドキュメントにカスタム JavaScript を追加できます。
5647

5748
```jsx:title=src/html.js
5849
<script

0 commit comments

Comments
 (0)