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

Commit bda7c62

Browse files
authored
Merge pull request #221 from gentksb/docs/adding-markdown-pages
Translate Docs/adding markdown pages
2 parents fe0b193 + 5b17f15 commit bda7c62

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

docs/docs/adding-markdown-pages.md

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
---
2-
title: Adding Markdown Pages
2+
title: Markdown のページを追加する
33
---
44

5-
Gatsby can use Markdown files to create pages in your site.
6-
You add plugins to read and understand folders with Markdown files and from them create pages automatically.
5+
Gatsby ではあなたのウェブサイトにページを追加するために Markdown ファイルを利用できます。
6+
プラグインを追加し、Markdown ファイルのあるフォルダーを読み込むよう設定するだけで、自動的に Markdown ファイルからページを生成します。
77

8-
Here are the steps Gatsby follows for making this happen.
8+
以下が、Gatsby における上記の処理です。
99

10-
1. Read files into Gatsby from the filesystem
11-
2. Transform Markdown to HTML and [frontmatter](#frontmatter-for-metadata-in-markdown-files) to data
12-
3. Add a Markdown file
13-
4. Create a page component for the Markdown files
14-
5. Create static pages using Gatsby's Node.js `createPage` API
10+
1. ファイルシステムから Gatsby にファイルを読み込む
11+
2. `gatsby-transformer-remark` を使って Markdown [frontmatter](#Frontmatter - Markdown ファイルのメタデータ)を変換してデータとして利用する
12+
3. Markdown ファイルを追加する
13+
4. Markdown ファイルのためのページテンプレートを作成する
14+
5. Gatsby `createPage` Node.js API を使って静的なページを生成する
1515

16-
## Read files into Gatsby from the filesystem
16+
## ファイルシステムから Gatsby にファイルを読み込む
1717

18-
Use the plugin [`gatsby-source-filesystem`](/packages/gatsby-source-filesystem/#gatsby-source-filesystem) to read files.
18+
[`gatsby-source-filesystem`](/packages/gatsby-source-filesystem/#gatsby-source-filesystem) をファイル読み込みのために利用します。
1919

20-
### Install
20+
### インストール
2121

2222
`npm install --save gatsby-source-filesystem`
2323

24-
### Add plugin
24+
### プラグインの追加
2525

26-
**NOTE:** There are two ways to add a plugin in `gatsby-config.js`. Either you can pass a string with the plugin name or in case you want to include options, pass an object.
26+
**ヒント:** `gatsby-config.js` にプラグインを追加する方法は 2 通りあります。プラグイン名の文字列を記述する方法と、オプションを含んだ内容を記述する方法です。後者の場合はオブジェクトとして記述します。
2727

28-
Open `gatsby-config.js` to add the `gatsby-source-filesystem` plugin. Now pass the object from the next block to the `plugins` array. By passing an object that includes the key `path`, you set the file system path.
28+
`gatsby-config.js` を開き `gatsby-source-filesystem` プラグインを追加しましょう。この時、`plugins` 配列の最後の位置にオブジェクトを追加します。`path` キーに、Gatsby が読み込むファイルシステムのパスを指定してください。
2929

3030
```javascript:title=gatsby-config.js
3131
plugins: [
@@ -39,19 +39,19 @@ plugins: [
3939
]
4040
```
4141

42-
Completing the above step means that you've "sourced" the Markdown files from the filesystem. You can now "transform" the Markdown to HTML and the YAML frontmatter to JSON.
42+
この手順を完了することで、Markdown ファイルをファイルシステムからデータソースとして利用できます。Markdown 本文は HTML に変換され、frontmatter の YAML JSON ファイルとしてデータ化されます。
4343

44-
## Transform Markdown to HTML and frontmatter to data using `gatsby-transformer-remark`
44+
## `gatsby-transformer-remark` を使って Markdown と Frontmatter を変換してデータとして利用する
4545

46-
You'll use the plugin [`gatsby-transformer-remark`](/packages/gatsby-transformer-remark/) to recognize files which are Markdown and read their content. The plugin will convert the frontmatter metadata part of your Markdown files as `frontmatter` and the content part as HTML.
46+
[`gatsby-transformer-remark`](/packages/gatsby-transformer-remark/) プラグインを使うことで、Markdown ファイルのコンテンツを認識し、読み込むことができます。このプラグインは Frontmatter のメタデータを `frontmatter` に変換して、コンテンツ部分を HTML に変換します。
4747

48-
### Install transformer plugin
48+
### `gatsby-transformer-remark` プラグインのインストール
4949

5050
`npm install --save gatsby-transformer-remark`
5151

5252
### Configure plugin
5353

54-
Add this to `gatsby-config.js` after the previously added `gatsby-source-filesystem`.
54+
`gatsby-config.js` に下記の記述を追加します。`gatsby-source-filesystem` より後ろである必要があります。
5555

5656
```javascript:title=gatsby-config.js
5757
plugins: [
@@ -66,14 +66,14 @@ plugins: [
6666
]
6767
```
6868

69-
## Add a Markdown file
69+
## Markdown ファイルを追加する
7070

71-
Create a folder in the `/src` directory of your Gatsby application called `markdown-pages`.
72-
Now create a Markdown file inside it with the name `post-1.md`.
71+
`/src` ディレクトリー内に、`markdown-pages` ディレクトリーを新しく作成しましょう。
72+
そしてその中に `post-1.md` ファイルを作成します。
7373

74-
### Frontmatter for metadata in Markdown files
74+
### Frontmatter - Markdown ファイルのメタデータ
7575

76-
When you create a Markdown file, you can include a set of key value pairs that can be used to provide additional data relevant to specific pages in the GraphQL data layer. This data is called frontmatter and is denoted by the triple dashes at the start and end of the block. This block will be parsed by `gatsby-transformer-remark` as `frontmatter`. The GraphQL API will provide the key value pairs as data in your React components.
76+
Markdown ファイルを作成すると、コンテンツ以外のデータとしてキー・バリュー値のセットを含めることができます。これはコンテンツ以外のデータとして GraphQL のデータレイヤーに追加されます。このデータは frontmatter と呼ばれ、ハイフン 3 つで区切られたブロックで記述されます。このブロック内に書かれたキーバリュー値は `gatsby-transformer-remark` によって `frontmatter` データに変換されます。GraphQL によってこのキーバリュー値のペアが React コンポーネント内で利用できるようになります。
7777

7878
```markdown:title=src/markdown-pages/post-1.md
7979
---
@@ -83,21 +83,21 @@ title: "My first blog post"
8383
---
8484
```
8585

86-
What is important in this step is the key pair `path`. The value that is assigned to the key `path` is used in order to navigate to your post.
86+
ここで重要なのは `path` のキーペアです。 `path` の値は、この記事をウェブサイト上で利用されるパスとして機能します。
8787

88-
## Create a page template for the Markdown files
88+
## Markdown ファイルのためのページテンプレートを作成する
8989

90-
Create a folder in the `/src` directory of your Gatsby application called `templates`.
91-
Now create a `blogTemplate.js` inside it with the following content:
90+
`/src` ディレクトリー内に、`templates` ディレクトリーを新しく作成しましょう。
91+
`blogTemplate.js` ファイルをこのディレクトリー内に下記の内容で作成します。
9292

9393
```jsx:title=src/templates/blogTemplate.js
9494
import React from "react"
9595
import { graphql } from "gatsby"
9696

9797
export default function Template({
98-
data, // this prop will be injected by the GraphQL query below.
98+
data, // この prop はGraphQLのクエリ結果が注入されます
9999
}) {
100-
const { markdownRemark } = data // data.markdownRemark holds your post data
100+
const { markdownRemark } = data // data.markdownRemark が記事データ
101101
const { frontmatter, html } = markdownRemark
102102
return (
103103
<div className="blog-post-container">
@@ -127,21 +127,21 @@ export const pageQuery = graphql`
127127
`
128128
```
129129

130-
Two things are important in the file above:
130+
ファイルに置いては 2 つの重要なポイントがあります:
131131

132-
1. A GraphQL query is made in the second half of the file to get the Markdown data. Gatsby has automagically given you all the Markdown metadata and HTML in this query's result.
132+
1. GraphQL クエリーは Markdown データのファイル取得後半で生成されます。Gatsby は自動的にクエリ結果に含まれるすべての Markdown メタデータと HTML をあなたに渡します。
133133

134-
**Note: To learn more about GraphQL, consider this [excellent resource](https://www.howtographql.com/)**
134+
**ヒント: GraphQL についてさらに知りたい場合は、こちらをお読みください [How to GraphQL](https://www.howtographql.com/)**
135135

136-
2. The result of the query is injected by Gatsby into the `Template` component as `data`. `markdownRemark` is the property that you'll find has all the details of the Markdown file. You can use that to construct a template for your blog post view. Since it's a React component, you could style it with any of the [recommended styling systems](/docs/styling/) in Gatsby.
136+
2. クエリ結果は、Gatsby `Template` `data` として渡されます。`markdownRemark` はクエリした Markdown ファイルに関するすべてのプロパティが含まれます。このデータを使っってテンプレートを構築し、ブログ記事のスタイリングを変更できます。テンプレートは React コンポーネントなので、スタイリングに関しては Gatsby における[推奨されるスタイリング手段](/docs/styling/)を利用できます。
137137

138-
### Create static pages using Gatsby’s Node.js `createPage` API
138+
### Gatsby `createPage` Node.js API を使って静的なページを生成する
139139

140-
Gatsby exposes a powerful Node.js API, which allows for functionality such as creating dynamic pages. This API is available in the `gatsby-node.js` file in the root directory of your project, at the same level as `gatsby-config.js`. Each export found in this file will be run by Gatsby, as detailed in its [Node API specification](/docs/node-apis/). However, you should only care about one particular API in this instance, `createPages`.
140+
Gatsby は強力な Node.js API を用意しており、これによって動的ページの作成などの機能が可能になります。 この API `gatsby-node.js` 内で利用可能です。ルートディレクトリー、つまり `gatsby-config.js` と同じ階層に配置します。このファイルに書かれたそれぞれのエクスポート設定が Gatsby によって実行されます。詳細は [Node API の詳細](/docs/node-apis/)で確認できます。このセクションでは、`createPages` のみを利用します。
141141

142-
Use the `graphql` to query Markdown file data as below. Next, use the `createPage` action creator to create a page for each of the Markdown files using the `blogTemplate.js` you created in the previous step.
142+
`graphql` を利用して Markdown ファイルのデータを下記サンプルのように取得します。 次に、`createPage` を利用して前のステップで作成した `blogTemplate.js` にデータを渡すことでファイルごとに静的なページを生成します。
143143

144-
**NOTE:** Gatsby calls the `createPages` API (if present) at build time with injected parameters, `actions` and `graphql`.
144+
**ヒント:** Gatsby `createPages` API をビルド時に呼びだす際、`actions` `graphql` パラメーターを付与しています。
145145

146146
```javascript:title=gatsby-node.js
147147
const path = require(`path`)
@@ -178,20 +178,20 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
178178
createPage({
179179
path: node.frontmatter.path,
180180
component: blogPostTemplate,
181-
context: {}, // additional data can be passed via context
181+
context: {}, // コンテキストとして任意のデータを付与できます
182182
})
183183
})
184184
}
185185
```
186186

187-
This should get you started on some basic Markdown functionality in your Gatsby site. You can further customize the frontmatter and the template file to get desired effects!
187+
以上が、あなたの Gatsby ウェブサイトにおける基本的な Markdown ファイル機能です。frotmatter とテンプレートファイルをカスタマイズすることで、思い通りの効果を得ることができます!
188188

189-
For more information, have a look in the working example `using-markdown-pages`. You can find it in the [Gatsby examples section](https://github.com/gatsbyjs/gatsby/tree/master/examples).
189+
実際に動作するコードを Github のサンプルで確認することもできます。公式リポジトリーの [Gatsby examples section](https://github.com/gatsbyjs/gatsby/tree/master/examples) から `using-markdown-pages` ディレクトリーを探してください。
190190

191-
## Other tutorials
191+
## 他のチュートリアル
192192

193-
Check out tutorials listed on the [Awesome Gatsby](/docs/awesome-gatsby-resources/#gatsby-tutorials) page for more information on building Gatsby sites with Markdown.
193+
Markdown ファイルを利用したウェブサイト作成に関して、追加のチュートリアルが [Awesome Gatsby](/docs/awesome-gatsby-resources/#gatsby-tutorials) で紹介されています。
194194

195-
## Gatsby Markdown starters
195+
## Gatsby Markdown スターター
196196

197-
There are also a number of [Gatsby starters](/starters?c=Markdown) that come pre-configured to work with Markdown.
197+
Markdown ファイルを利用するための設定がすでに済んだスターターキットを [Gatsby starters](/starters?c=Markdown) から探して利用できます。

0 commit comments

Comments
 (0)