Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include static assets dynamically with nuxt generate?

Tags:

vuejs2

nuxt.js

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?

like image 838
mati Avatar asked Jul 07 '17 16:07

mati


1 Answers

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/

like image 173
Derian André Avatar answered Nov 16 '22 18:11

Derian André