Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/docs/creating-slugs-for-pages.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
title: Creating Slugs for Pages
title: ページのスラッグを作成する
---

The logic for creating slugs from file names can get tricky, the `gatsby-source-filesystem` plugin ships with a function for creating them.
ファイル名からスラッグを作成するロジックは時おり複雑になり得ます。`gatsby-source-filesystem` プラグインは、そのための関数を用意しています。

## Install
## インストール

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

## Create slugs in gatsby-node.js
## gatsby-node.js を使ったスラッグの作成

Add your new slugs directly onto the `MarkdownRemark` nodes. Any data you add to nodes is available to query later with GraphQL.
`MarkdownRemark` ノードに新しいスラッグを直接作成しましょう。このノードに追加されたデータは GraphQL によってクエリ可能となります。

To do so, you'll use a function passed to our API implementation called [`createNodeField`](/docs/actions/#createNodeField). This function allows you to create additional fields on nodes created by other plugins.
作成するには、[`createNodeField`](/docs/actions/#createNodeField) という API を使用します。この関数は他のプラグインによって作成されたノードに新しくフィールドを追加できます。

```javascript:title=gatsby-node.js
const { createFilePath } = require(`gatsby-source-filesystem`)
Expand All @@ -34,9 +34,9 @@ exports.onCreateNode = ({ node, getNode, actions }) => {
}
```

## Query created slugs
## 作成されたスラッグの確認

Open refresh GraphiQL, then run this GraphQL query to see all your slugs:
GraphiQL を開き、以下の GraphQL クエリを実行することで、全てのスラッグが確認できます。

```graphql
{
Expand Down