BridgeCraft logobridgecraft
週報顧問服務作品集關於聯絡登入
聯絡

bridgecraft

從資料視覺化到 AI Agent,一直在找下一個 meta

文章主題指南週報顧問服務Labs作品集系統架構關於聯絡RSS

© 2026 BridgeCraft — Waiting7777. All rights reserved.

← 所有文章

Nuxt Content 初探心得

2020年5月15日 · Waiting7777 · 2 分鐘閱讀

介紹

在你的 NuxtJs 專案底下安裝 @nuxtjs/content 套件,並且將你的內容放在 content/ 資料夾底下,那麼套件將會自動將資料夾底下的 Markdown,JSON,YAML,CSV 檔案轉成 MongoDB 形式的 API,這樣你的專案將會如同擁有一個內容的資料庫。

特色

  • 開發時快速 hot reload
  • 可以在 markdown 裡面用 vue compoents
  • 全文搜索
  • 支援靜態網站生成 nuxt generate
  • 強大的 QueryBuilder API (MongoDB like)
  • code block 內建用 PrismJS 的語法高亮

安裝

將 @nuxt/conent 裝入你的專案

yarn add @nuxt/content

然後設定 nuxt.config.js 的 modules

{
  modules: [
    '@nuxt/content'
  ],
  content: {
    // options
  }
}

內容

在專案底下,創個 content 資料夾,結構如下:

content/
  articles/
    article-1.md
    article-2.md
  home.md

會自動將裡面的 .md,.yaml,.csv,.json,檔案轉換並生成以下額外的屬性:

  • dir
  • path
  • slug
  • extension
  • createdAt
  • updatedAt
[
  {
    "toc": [
      {
        "id": "這是測試副標",
        "depth": 2,
        "text": "這是測試副標"
      }
    ],
    "body": {
      "type": "root",
      "children": [
        {
          "type": "element",
          "tag": "h1",
          "props": {
            "id": "這是測試標題"
          },
          "children": [
            {
              "type": "element",
              "tag": "a",
              "props": {
                "ariaHidden": "true",
                "href": "#%E9%80%99%E6%98%AF%E6%B8%AC%E8%A9%A6%E6%A8%99%E9%A1%8C",
                "tabIndex": -1
              },
              "children": [
                {
                  "type": "element",
                  "tag": "span",
                  "props": {
                    "className": [
                      "icon",
                      "icon-link"
                    ]
                  },
                  "children": []
                }
              ]
            },
            {
              "type": "text",
              "value": "這是測試標題"
            }
          ]
        },
        {
          "type": "element",
          "tag": "h2",
          "props": {
            "id": "這是測試副標"
          },
          "children": [
            {
              "type": "element",
              "tag": "a",
              "props": {
                "ariaHidden": "true",
                "href": "#%E9%80%99%E6%98%AF%E6%B8%AC%E8%A9%A6%E5%89%AF%E6%A8%99",
                "tabIndex": -1
              },
              "children": [
                {
                  "type": "element",
                  "tag": "span",
                  "props": {
                    "className": [
                      "icon",
                      "icon-link"
                    ]
                  },
                  "children": []
                }
              ]
            },
            {
              "type": "text",
              "value": "這是測試副標"
            }
          ]
        },
        {
          "type": "element",
          "tag": "p",
          "props": {},
          "children": [
            {
              "type": "text",
              "value": "這是測試內文"
            }
          ]
        }
      ]
    },
    "dir": "/",
    "path": "/test",
    "extension": ".md",
    "slug": "test",
    "createdAt": "2020-06-01T06:26:44.150Z",
    "updatedAt": "2020-06-01T06:55:23.703Z"
  }
]

Fetching & Displaying Content

有了內容以後,再來要將它讀出來並放到頁面上, @nuxtjs/content 會在你的 vue 上面掛載 $content 接口,接著用各種 mongoDB 的方式來 query 內容,再用它的呈現專用 component 來呈現內容。

<template>
  <article>
    <h1>{{ page.title }}</h1>
    <nuxt-content :document="page" />
  </article>
</template>

<script>
export default {
  async asyncData ({ $content }) {
    const page = await this.$content('articles').sortBy('desc').limit(5).fetch()

    return {
      page
    }
  }
}
</script>

結論

因為現在 JAMSTACK 越來越盛行了,以前端製作一個外皮然後搭上內容就是一個網站,而@nuxtjs/content 這個 module 提供了一個幫你把 markdown file 轉換成 API 的接口,讓前端靜態網站blog 系統的製作越來越省心,另外這個 github repo 才剛創一個月,目前只能說是一個概念的展示,或是說 mvp 吧,很多應該要可以 custom 的地方,都不見得有提供 config 給你修改,所以就目前來說想用到完全客製化的話,可能還需要再等等。

每週一篇 — 技術趨勢背後的商業邏輯

分享:

Waiting7777

WoW Arena 冠軍轉前端,用電競 meta 思維拆解技術趨勢。

關於作者

相關文章

YC 裡越來越多二次創業者 — AI 時代為什麼老手反而更吃香創業創投+4

YC 裡越來越多二次創業者 — AI 時代為什麼老手反而更吃香

為什麼 AI 時代反而讓「老手」更吃香?從 YC 的數據看 repeat founder 的優勢在哪,以及這對第一次創業的人有什麼啟示。

2026年8月12日 · Waiting7777 · 7 分鐘閱讀

繼續閱讀 →
OpenChamber:專為 AI Agent 設計的開發環境,跟 IDE 的差別在哪?AI Agents開發工具+5

OpenChamber:專為 AI Agent 設計的開發環境,跟 IDE 的差別在哪?

拆解 OpenChamber 的設計邏輯:為什麼 agent 需要專屬的開發環境、跟直接在 terminal 跑 Claude Code 有什麼本質差異,以及這個方向的商業潛力在哪。

2026年8月11日 · Waiting7777 · 8 分鐘閱讀

繼續閱讀 →
AI coding 工具燒錢有多快?Databricks 告訴你怎麼控成本AI開發工具+4

AI coding 工具燒錢有多快?Databricks 告訴你怎麼控成本

從「Databricks 燒完錢才搞出控制工具」這個角度切入,拆解 AI coding 工具的真實成本結構,以及企業在 scale up 後才發現的坑。對比 Rippling 同樣在燒錢後才蓋 ROI 工具,這是一個系統性問題。

2026年8月8日 · Waiting7777 · 7 分鐘閱讀

繼續閱讀 →

這篇文章對你有幫助嗎?

每週一篇 — 技術趨勢背後的商業邏輯

AI 產業在變什麼、工程師該注意什麼——拆清楚寄到你的信箱。