You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
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` が利用できます。
19
16
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 メソッドを利用してください。
22
19
23
-
## Required props
20
+
## 必須なプロパティ
24
21
25
-
Note: the various props that are rendered into pages _are_ required e.g.
26
-
`headComponents`, `preBodyComponents`, `body`, and `postBodyComponents`.
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` プロップの利用を検討してください。
38
31
39
-
## Target container
32
+
## ターゲットコンテナ
40
33
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 を必要とします。
44
35
45
36
```jsx:title=src/html.js
46
37
<div
@@ -50,9 +41,9 @@ If you see this error: `Uncaught Error: _registerComponent(...): Target containe
50
41
/>
51
42
```
52
43
53
-
## Adding custom JavaScript
44
+
## カスタム JavaScript の追加
54
45
55
-
You can add custom JavaScript to your HTML document by using React's [dangerouslySetInnerHTML](https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml)attribute.
0 commit comments