mati
mati

Reputation: 5348

How to include static assets dynamically with nuxt generate?

I'm working on a static site using Nuxt.js (I target to publish just the result of nuxt generate).

The content is generated based on asyncData by calling a json API.

I want to grab some files and include them as if they were in the /static directory, depending on the API response. How could that be achieved?

To better illustrate the problem: Let's say there is a list of invoices coming from the API, so in the resulting page I show the invoice info, but I also want to include a download link to it's corresponding file (which I can resolve after knowing the API response).

Maybe this task should be done outside of nuxt.js, after the site generation?

Upvotes: 10

Views: 2549

Answers (1)

Derian André
Derian André

Reputation: 240

static folder is not intended to be like that and it's not intended that the files will change. It's just a way to inject those files into the root directory dist. So if it's dynamic either you don't use static or you first copy all your files in static using a command before nuxt generate.

https://nuxtjs.org/docs/directory-structure/static/

Upvotes: 1

Related Questions