DreaMinder / nuxt-payload-extractor

Nuxt.js module that makes `nuxt generate` command to store html and payload separately.
MIT License
145 stars 18 forks source link

Feature/subfolders #20

Closed jani-kasa closed 4 years ago

jani-kasa commented 4 years ago

Hello! Thanks you for this package, very useful. I wanted to use it with subFolders set to false, so updated the code for that.

It works the same as before if subFolders is not set to false. If the subFolders options is set to false the generated files will be the same as the page's name. So for example for /example route the generated html will be example.html the JS file will be example.js and the extracted data will be example.json. (for the index route, / it will use the index.js and index.json files).

DreaMinder commented 4 years ago

@jani-kasa Woah, that's a lot of work, thank you!

and the extracted data will be example.json

But with a timestamp, if it's enabled, right?

@jani-kasa The PR marked as WIP, are you planning to add something? I'll merge after some testing, alright?

Do you know about native payload-extractor implementation in beta version of Nuxt though? My component will be deprecated eventually, in favor of the native feature which supports subFolders=false: https://github.com/nuxt/nuxt.js/pull/6159/files#diff-4ddfa243e02d885643040d0baeea50a3R211

jani-kasa commented 4 years ago

and the extracted data will be example.json

But with a timestamp, if it's enabled, right?

Yeah, if timestamp is enabled it will be appended to it.

Do you know about native payload-extractor implementation in beta version of Nuxt though? My component will be deprecated eventually, in favor of the native feature which supports subFolders=false: https://github.com/nuxt/nuxt.js/pull/6159/files#diff-4ddfa243e02d885643040d0baeea50a3R211

Yes, I've heard of it, but I don't want to use the beta version, and needed this to work before that...

Thanks for testing, and let me know if anything needs to be fixed!

DreaMinder commented 4 years ago

@jani-kasa Hey, I can't get it working (at least with local-module approach) - it crashes with ./helpers module not found. Can you clarify your testing method, maybe I'm doing something wrong?

jani-kasa commented 4 years ago

@jani-kasa Hey, I can't get it working (at least with local-module approach) - it crashes with ./helpers module not found. Can you clarify your testing method, maybe I'm doing something wrong?

So sorry, I forgot to push up my fixes after introducing the extracted helpers from the plugins🤦‍♂️ I added them now, it should be good now!

I started the Nuxt server in one terminal with npm run dev and then generated the static files using npm run generate, and worked fine for me

DreaMinder commented 4 years ago

@jani-kasa Hey. It didn't work until I added a fix: route: route.path. Because $payloadURL(route) route argument should be an object with path inside, not the path itself... I know it was a weird decision but we have to keep it this way for backward compatibility.

Can you test it again on your side? It seems to be working for me now.