Reputation: 455
I have a problem without solution, I finally finish my app but now I can't to generate full static site. In my case, a little "multi arguments" blog, i didn't like how Nuxt generate the route, cause for my navigation system I need this layout:
Nuxt last version, node.js last version
index
blog
|-article one (child of blog)
|-article two (child of blog)
|-other pages (child of blog)
other blog
|-article one (child of other blog)
|-article two (child of other blog)
|-other pages (child of other blog)
The expected resoult should be:
mysite.io/
mysite.io/blog/articles-slug
mysite.io/blog-2/articles-slug
Maybe I'm wrong with the philosophie of nuxt? surelly
For do this I use ['@nuxtjs/router', { parsePages: 'true' }]
My route configuration is this:
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/onstep',
name: 'OnStep',
component: OnstepMain,
children: [
{ path: 'cosa-e-onstep', name: 'Cosa è OnStep', component: CosaOnStep },
{ path: 'configurazioni-possibili-di-onstep', name: 'Configurazioni Possibili', component: ConfOnStep },
{ path: 'moduli-necessari-per-la-scheda', name: 'Moduli Necessari', component: ModuliNecessari },
{ path: 'scelta-del-driver-per-motori-passo-passo', name: 'Scelta Del Driver Per Motori Passo Passo', component: SceltaDriver },
{ path: 'funzionamento-scelta-motori-passo-passo', name: 'Scelta e Funzinamento dei Motori Passo Passo', component: SceltaStepper },
{ path: 'calcolo-step-grado-montatura-eq-o-azm', name: 'Calcolo degli step/grado di una montatura EQ o AZM', component: CalcoloStep },
{ path: 'montare-la-scheda', name: 'Montare la Scheda', component: MontaScheda },
{ path: 'prepariamoci-a-scaricare-il-firmware', name: 'Preprariamo il PC', component: PreparaPC },
{ path: 'download-configurazione-firmware-onstep', name: 'Impostare il firmware di OnStep', component: FwOnstep },
{ path: 'configurazione-firmware-wifi', name: 'Impostare il firmware del WiFi', component: FwWiFi },
{ path: 'download-firmware-onstep', name: 'Download Firmware OnStep', component: DwOnstep },
]
},
]
})
When I do npm run generate --fail-on-error I get a lot of unfinded pages, cause the path where is looking is wrong:
ERROR Error generating route "/onstep/DownOnStep": This page could not be found 19:05:38
real route is /onstep/download-firmware-onstep
Other strange thing is this, I get:
ERROR Error generating route "/onstep/CosaOnStep": This page could not be found
But at least, only for this child route, I get this:
√ Generated route "/onstep/cosa-e-onstep"
And the html page is ok...but he generate two folders:
onstep/cosa-e-onstep and onstep/CosaOnStep
Any suggestion?
If it can help this is my nuxt.config:
const path = require('path')
export default {
// Target: https://go.nuxtjs.dev/config-target
target: 'static',
ssr: 'true',
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'stefanotesla',
htmlAttrs: {
lang: 'it'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'~assets/styles/tailwind.css',
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
// '~router.js'
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
['@nuxtjs/router', { parsePages: 'true' }],
// https://go.nuxtjs.dev/eslint
'@nuxtjs/eslint-module',
// https://go.nuxtjs.dev/stylelint
'@nuxtjs/stylelint-module',
// https://go.nuxtjs.dev/tailwindcss
'@nuxtjs/tailwindcss',
'@nuxtjs/sitemap',
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'nuxt-purgecss',
],
purgeCSS: {
mode: 'postcss',
enabled: (process.env.NODE_ENV === 'production')
},
sitemap: {
hostname: 'https://stefanotesla.it',
gzip: true,
},
// Build Configuration: https://go.nunpm run devxtjs.dev/config-build
build: {
postcss: {
plugins: {
'postcss-import': {},
tailwindcss: path.resolve(__dirname, './tailwind.config.js'),
'postcss-nested': {}
}
},
preset: {
stage: 1 // see https://tailwindcss.com/docs/using-with-preprocessors#future-css-featuress
}
}
}
Upvotes: 1
Views: 1322
Reputation: 455
Issue solved, if I route.js I have olso to declare in the nuxt.config.js the route path to prerender as here:
generate: {
routes: [ '/',
'/blog/',
'/blog/article1',
]
},
Upvotes: 1