Giter Site home page Giter Site logo

Comments (6)

claytonchew avatar claytonchew commented on July 24, 2024 2

Same issue here, but our case is quite different. We have a middleware that redirects path / to /home for example, adding page/index.vue works on route correction, but for some reason, nuxt could not initialized properly, such as runtime public configs went missing + client-side plugins were not registered.

from nuxt.js.

BananaAcid avatar BananaAcid commented on July 24, 2024

The project is going to be placed on a php hoster (that is the reason for generate), where the index.php is already occupied by the main website (that is the reason, why the change is hurtful).

from nuxt.js.

BananaAcid avatar BananaAcid commented on July 24, 2024

A crude FIX:

  1. add an empty pages/index.vue,
  2. generate, and
  3. remove the index.html before generating the next project/deployment.

or: downgrade nuxt

from nuxt.js.

danielroe avatar danielroe commented on July 24, 2024

Apologies for this. We will be able to revert this when we upgrade nitro to the next version.

In the mean time you should be able to use the nitro prerender:routes hook to remove the index route.

from nuxt.js.

BananaAcid avatar BananaAcid commented on July 24, 2024

@danielroe there seems to be an additional problem. Using:

{
    nitro: {
        prerender: {
            crawlLinks: false,
            // ignore: ['/'], -- how to address index? using this, no route will be generated anymore
            routes: ['/about'],
        },
    }
}

it will always generate a html file: 200.html

Unfortunately, crawlLiks:false will not "validate" any links anymore, but ignore:['/'] will just block any route defined in routes:[].

... can this 200.html be blocked? Or the index be targeted better?

Trying to filter a '/' or alike from the hooks's ctx.routes does not work for me. Any advice on how to use it in my case? (I can't seem to find out what could work)

trying

{nitro:
        prerender: {
            crawlLinks: true,
            routes: ['/about'],
        },
         hooks: {
            "prerender:generate"(route) {
                if (route.route === '/' || route.route === '/200.html') {
                    route.skip = true;
                }
            },
        },
}

I get (without index.vue):

  ├─ / (507ms)                                                                                                                                                                                           
  └── Error: [404] Page not found: / (skipped)

is this supposed to trigger an abort error, even thought I filtered it to skip ?

Using reference: https://nuxt.com/docs/getting-started/prerendering

from nuxt.js.

danielroe avatar danielroe commented on July 24, 2024

Here's a workaround for now:

import { useNitro } from '@nuxt/kit'

export default defineNuxtConfig({
  devtools: { enabled: true },
  hooks: {
    'build:done'() {
      useNitro().hooks.hook('prerender:routes', (routes) => {
        routes.delete('/')
      })
    }
  },
})

from nuxt.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.