Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
NuxtJS Components/Content module
Search
Kaneko Takeshi
May 29, 2020
Technology
22
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
NuxtJS Components/Content module
Pizza_jp#29
Kaneko Takeshi
May 29, 2020
More Decks by Kaneko Takeshi
See All by Kaneko Takeshi
オープンソースライセンスについて勉強する定期
tkckaneko
0
44
Eye Tracking on the Browser
tkckaneko
0
99
IEEE754を完全に理解した
tkckaneko
1
85
CSSのトレンドをみんなで見よう -2021年-
tkckaneko
0
100
多分これが一番早いと思います
tkckaneko
0
31
暗黒面の話
tkckaneko
0
31
CSR / SSR / SSG / JAMstack
tkckaneko
0
79
BOLT
tkckaneko
0
40
CSS Logical Properties and Values
tkckaneko
0
55
Other Decks in Technology
See All in Technology
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.1k
【CEDEC2026】『GRANBLUE FANTASY: Relink - Endless Ragnarok』のバトル制作事例 ~最高のキャラゲーを目指して~
cygames
PRO
0
190
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.9k
つくって納得、つかって実感! 大規模言語モデルことはじめ ver2.0
recruitengineers
PRO
2
770
初めてのGitHub Actions / GitHub Actions at First
tooppoo
0
140
【CEDEC2026】専門性の高いデフォルメチームが挑んだ人材育成戦略 〜Cygames Academiaの企画から実施まで〜
cygames
PRO
0
390
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
19k
Goでデータパイプラインを作ろう
sansantech
PRO
0
250
第3回しろおびセキュリティスポンサーセッション
log0417
0
140
認知負荷をGemini で溶かす — GKE 基盤「Orbit」における AI エージェントの実践
sansantech
PRO
1
250
【CEDEC2026】コードレビュー支援ツール開発から学ぶ:LLMを用いた業務システムの実践的な運用設計と誤出力対策
cygames
PRO
0
560
ボトムアップ文化が強い組織で セキュリティをどう根付かせていくかの現在進行形の話 / Making Security Stick in a Bottom-Up Organization
yamaguchitk333
0
130
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.6k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
530
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
480
Code Review Best Practice
trishagee
74
20k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Everyday Curiosity
cassininazir
0
270
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Google's AI Overviews - The New Search
badams
0
1.1k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
890
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
200
Transcript
NuxtJS Components/Content module
Components module 自動でコンポーネントを探してきてインポートしてくれるモジュール import文とcomponentsフィールドを書かなくてよくなる 便利すぎるので試してみた話です
Components module $ yarn create nuxt-app playground-202005 $ yarn add
--dev @nuxt/components で、簡単に入れられます。
Components module 現在(2020/05/29)の最新版バージョン2.12.2の場合 nuxt.config.jsを書き換える ※ 2.13.xからは不要になる buildModules: [ '@nuxt/components', ],
Components module <script lang="ts"> import Vue from 'vue' import Logo
from '~/components/Logo.vue' export default Vue.extend({ components: { Logo } }) </script> これが
Components module <script lang="ts"> import Vue from 'vue' </script> こうなる
Components module $ yarn dev 実行!
べんり!
Content module MarkdownとかJSONなんかからNuxtJSへ渡してくれるモジュール なんかいろいろできる - 全文検索とかできる - Markdownの構文もVueのコンポーネントで書き出せる - 目次もつくれる
スゴそうなので試してみた話です
Content module $ yarn add @nuxt/content ※ さっきのに追加 nuxt.config.jsを書き換える modules:
[ '@nuxt/content', ],
Content module 下準備は簡単 contentディレクトリをつくってmdファイルを入れるだけ ├─- content │ └── articles │
├── article-1.md │ └── article-2.md
Content module 一覧を取得する - $contentでディレクトリのパスをセット - チェーンシーケンスが返ってくる - sortByとかsearchとか繋げられる async
asyncData ({ $content, params }) { const query = await $content('articles').limit(15) const articles = await query.fetch() return { articles } }
Content module コンテンツを取得する - $contentでファイルのパスをセット - <nuxt-content>テンプレートでページの本文を表示 async asyncData ({
$content, params }) { const articles = await $content('articles', params.slug).fetch() return { articles } }
おしまい