Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netlify CMSで記事にカテゴリを設定できるようにしました #4

Merged
merged 6 commits into from May 24, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -0,0 +1,4 @@
---
title: カテゴリA
---
カテゴリAです
@@ -1,14 +1,14 @@
---
title: Default Starterからブログを作成する
category: Tech
tags:
- Gridsome
- Netlify
slug: first-post
date: 2019-05-20
description: GridsomeのDefault Starterからブログを作成しています。
category: カテゴリA
---

外部リンクはtransformerにより、別タブで開きます。

外部リンクテスト: [ぺんすけブログ](https://pensuke.work)
外部リンクテスト: [ぺんすけブログ](https://pensuke.work)
@@ -18,6 +18,11 @@ module.exports = {
typeName: 'Tag',
route: '/tag/:id',
create: true
},
category: {
typeName: 'Category',
route: '/category/:id',
create: true
}
}
}
@@ -7,12 +7,27 @@ public_folder: "/uploads"

collections:
- name: "posts"
label: "Posts"
label: "投稿"
folder: "content/posts"
create: true
slug: "{{slug}}"
fields:
- {label: "タイトル", name: "title", widget: "string"}
- {label: "概要", name: "description", widget: "string"}
- label: "カテゴリ"
name: "category"
widget: "relation"
collection: "categories"
searchFields: ["title", "body"]
valueField: "title"
displayFields: ["title"]
- {label: "公開日", name: "date", widget: "date"}
- {label: "内容", name: "body", widget: "markdown"}

- name: "categories"
label: "カテゴリ"
folder: "content/categories"
create: true
fields:
- { label: "カテゴリ名", name: "title", widget: "string" }
- { label: "説明文", name: "body", widget: "text" }
@@ -13,6 +13,7 @@
<ul v-if="post.node.tags">
<li v-for="tag in post.node.tags" :key="tag.id">{{ tag.title }}</li>
</ul>
<p>カテゴリ: <span v-if="post.node.category">{{ post.node.category.title }}</span><span v-else>未設定</span></p>
</div>
</Layout>
</template>
@@ -29,6 +30,10 @@
title
path
}
category {
id
title
}
description
content
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.