0

I have a monorep based set-up where all shared static assets live in <repo>/public/img. I’d like every Nuxt app under <repo>/apps/… to reference those images directly. I’d like all of my Nuxt apps under /apps/* to be able to reference images in the root public/img directory:

  • "nuxt": "^3.17.5",
  • "@nuxt/content": "^3.6.3",
  • "better-sqlite3": "^12.2.0",
<!-- in a Vue component -->
<img
  src="/img/supply-chain.svg"
  alt="Supply chain illustration"
  class="object-cover w-full h-full"
/>

I’ve configured Nitro in nuxt.config.ts to serve those files:

import { defineNuxtConfig } from 'nuxt/config'
import { resolve }           from 'node:path'

export default defineNuxtConfig({
  nitro: {
    publicAssets: [
      {
        dir:     resolve(__dirname, '../public/img'),
        baseURL: '/img',
        maxAge:  60 * 60 * 24 * 30
      },
      /* …other roots… */
    ]
  }
})
  • ✅ Vue components load /img/supply-chain.svg correctly (even without a full page reload).

  • ❌ Markdown in /content/*.md (rendered via ) does not show /img/supply-chain.svg unless I manually copy it into apps/web/public/img.

However, when I reference images from Nuxt content v3 markdown files, it's not working and the image is not showing in the markdown with Nuxt content <ContentRenderer>:

![World map | Figure 1: World map.](/img/supply-chain.svg)

But for the same markdown, if I place the image in respective project/public/img folder, then it shows up in the ContentRenderer page. How to use the images from root folder public/img within my markdown file rather than using them from the `project/public/imgà folder?

What I’ve Tried

  • Configuring nitro.publicAssets (works for Vue tags, not for Markdown).
  • Moving the image into apps/web/public/img (works, but duplicates assets).

Question How can I configure Nuxt 3 + Content so that Markdown images (/img/…) resolve from my mono-repo’s root public/img, instead of each app’s public/img?

Any guidance on Vite/Nuxt/Nitro settings (or recommended folder-structure patterns) would be hugely appreciated!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.