Git Product home page Git Product logo

Comments (10)

mrleblanc101 avatar mrleblanc101 commented on May 23, 2024 1

But only is you have keepDefaultRouter enabled which I don't because I use the pages folder for my custom Page that I don't want nuxt to treat as automatic route

from router-module.

ricardogobbosouza avatar ricardogobbosouza commented on May 23, 2024

Hi @mrleblanc101
It is already sent inside routerOptions
See https://github.com/nuxt-community/router-module#accessing-default-router

export function createRouter(ssrContext, createDefaultRouter, routerOptions, config) {
  // https://github.com/nuxt/nuxt.js/blob/dev/packages/vue-app/template/router.js#L90-L95
  // routerOptions.scrollBehavior <-- here
  return new Router(routerOptions ? routerOptions : createDefaultRouter(ssrContext, config).options)
}

from router-module.

ricardogobbosouza avatar ricardogobbosouza commented on May 23, 2024

I will make sure that all options are passed and it is up to the user to decide what to do

from router-module.

ricardogobbosouza avatar ricardogobbosouza commented on May 23, 2024

@mrleblanc101
I added a new option parsePages
Waiting review

from router-module.

mrleblanc101 avatar mrleblanc101 commented on May 23, 2024

So something like ?

{
  keepDefaultRouter: true,
  parsePage: false
}

from router-module.

ricardogobbosouza avatar ricardogobbosouza commented on May 23, 2024

Yeap 😄

from router-module.

mrleblanc101 avatar mrleblanc101 commented on May 23, 2024

Does not look like it's working on my side using @nuxtjs/router: 1.6.1.
If I use the above options, the page doesn't scroll to top.

{
  keepDefaultRouter: true,
  parsePages: false
}

2021-07-29 17 16 25

But If I import from .nuxt/router.scrollBehavior.js, it works:

import Vue from 'vue';

import Router from 'vue-router';
import scrollBehavior from '../.nuxt/router.scrollBehavior.js';

Vue.use(Router);
export function createRouter() {
    return new Router({
        base: '/',
        mode: 'history',
        scrollBehavior,
        routes: [
            ...
        ],
    });
}

2021-07-29 17 19 44

from router-module.

mrleblanc101 avatar mrleblanc101 commented on May 23, 2024

Oh I think I get it.
I should've been using this: https://github.com/nuxt-community/router-module#accessing-default-router
I've been completely overwriting the router this whole time, which was "fine" since I have parsePages: false;.
I thought the merging of both router was automatic.

export function createRouter(ssrContext, createDefaultRouter, routerOptions, config) {
  const options = routerOptions ? routerOptions : createDefaultRouter(ssrContext, config).options

  return new Router({
    ...options,
    routes: fixRoutes(options.routes)
  })
}

from router-module.

mrleblanc101 avatar mrleblanc101 commented on May 23, 2024

I must be doing something wrong because my 2nd and 3rd argument are null even if I have keepDefaultRouter: true;

[                                                                                                                            
  {
    req: IncomingMessage {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      socket: [Socket],
      httpVersionMajor: 1,
      httpVersionMinor: 1,
      httpVersion: '1.1',
      complete: true,
      headers: [Object],
      rawHeaders: [Array],
      trailers: {},
      rawTrailers: [],
      aborted: false,
      upgrade: false,
      url: '/repertoire/professionnels/1',
      method: 'GET',
      statusCode: null,
      statusMessage: null,
      client: [Socket],
      _consuming: false,
      _dumped: false,
      originalUrl: '/repertoire/professionnels/1',
      _parsedUrl: [Url],
      _parsedOriginalUrl: [Url],
      [Symbol(kCapture)]: false,
      [Symbol(RequestTimeout)]: undefined
    },
    res: ServerResponse {
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: false,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: true,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: null,
      _hasBody: true,
      _trailer: '',
      finished: false,
      _headerSent: false,
      socket: [Socket],
      _header: null,
      _keepAliveTimeout: 5000,
      _onPendingData: [Function: bound updateOutgoingData],
      _sent100: false,
      _expect_continue: false,
      locals: {},
      statusCode: 200,
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: null
    },
    url: '/repertoire/professionnels/1',
    target: 'server',
    spa: undefined,
    modern: false,
    runtimeConfig: {
      private: [Object],
      public: [Object]
    },
    _registeredComponents: Set(0) {},
    styles: [Getter],
    _renderStyles: [Function: renderStyles],
    _styles: {
      '3e2078a7:0': [Object],
      '92c0cd9c:0': [Object],
      '0542ed34:0': [Object],
      '778b9149:0': [Object],
      '253dfc1e:0': [Object],
      'ce243306:0': [Object],
      '4d91c5a6:0': [Object],
      '5d295e65:0': [Object],
      'bd24c34c:0': [Object]
    },
    redirected: false,
    next: [Function (anonymous)],
    beforeRenderFns: [],
    nuxt: {
      layout: 'default',
      data: [],
      fetch: {},
      error: null,
      state: null,
      serverRendered: true,
      routePath: '',
      config: [Object]
    },
    fetchCounters: {}
  },
  null,
  null,
  {
    baseURL: 'localhost:3000',
    apiURL: 'http://docs.campus-eeq.local.vici.io/api/client/v1',
    _app: {
      basePath: '/',
      assetsPath: '/_nuxt/',
      cdnURL: null
    }
  }
]

from router-module.

mrleblanc101 avatar mrleblanc101 commented on May 23, 2024

I was putting the options inside router in my nuxt.config.json instead of routerModule 🤦‍♂️

from router-module.

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.