Code Monkey home page Code Monkey logo

Comments (13)

davidhorak avatar davidhorak commented on May 23, 2024

@UIX-Design Hello there. This is not related to the router itself. It depends on your local server configuration. When you enter the URL directly into your browser, the localhost server (node express, Apache, ngnix, etc.) must serve the index.html which is not a default behavior of server - it tried to open a index file in the given directory. I.e. you have to setup rewrite rules to serve the index.html. As soon as the index.html is shown, than the URL changes are done directly by the router.

from svelte-router.

UIX-Design avatar UIX-Design commented on May 23, 2024

@davidhorak OK thank you for your detailed answer. Later, when I build my Svelte app and deploy to a server, I try to use the following rewrite rules:

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) /index.html [QSA,L]
</ifModule>

Is there a way to fix the problem in the dev environment, so if I'm running npm run dev?

from svelte-router.

davidhorak avatar davidhorak commented on May 23, 2024

@UIX-Design That should work for apache. For the dev, it depends how you run the local server. What does the "dev" script do/runs?

from svelte-router.

UIX-Design avatar UIX-Design commented on May 23, 2024

@davidhorak the dev script run the following commands:

"dev": "run-p build:auto serve:dev"

Another question: The activeClass works great, but i am using a dropdown menu like this:

{#if open}
    <nav in:slide out:slide class="">
       //my dropdown menu
    </nav>
{/if}

The activeClass does not keep on my dropdown menu if it is not displayed again. How can I solve this?

from svelte-router.

davidhorak avatar davidhorak commented on May 23, 2024

@UIX-Design Assuming that "serve:dev" is webpack dev server than - https://stackoverflow.com/questions/31945763/how-to-tell-webpack-dev-server-to-serve-index-html-for-any-route

from svelte-router.

UIX-Design avatar UIX-Design commented on May 23, 2024

@davidhorak thanks for sharing the link, but how can i edit or expand the webpack.config.js? I am a newcomer of Svelte... And please take a look at my updated comment to my activeClass Issue... Thanks for your help

from svelte-router.

davidhorak avatar davidhorak commented on May 23, 2024

@UIX-Design Respectfully, this is not related to Svelte, nor this router repository, rather the webpack basics, please explore the https://webpack.js.org/guides/getting-started/ to see how to setup the webpack config.

from svelte-router.

davidhorak avatar davidhorak commented on May 23, 2024

@UIX-Design Regarding the activeClass, also not sure if this is related to the router, but rather to your app structure.

from svelte-router.

UIX-Design avatar UIX-Design commented on May 23, 2024

@davidhorak When i open my dropdown and click on a link:

The activeClass is hello - looks good

Bildschirmfoto 2019-09-03 um 15 34 53

After i close and open the dropdown again...

Bildschirmfoto 2019-09-03 um 15 35 52

The active link does not retain the activeClass even though the page has not been left...

from svelte-router.

UIX-Design avatar UIX-Design commented on May 23, 2024

@davidhorak I think i have a solution for my activeClass Issue... It is possible to get the current route, inside a component?

from svelte-router.

davidhorak avatar davidhorak commented on May 23, 2024

@UIX-Design yes, https://github.com/spaceavocado/svelte-router#auto-passed-route-prop

from svelte-router.

UIX-Design avatar UIX-Design commented on May 23, 2024

@davidhorak thank you very much. One last question: It is possible to use the Link Events like on:completed={handleOnCompleted} on the router layer, maybe inside the createRouter function? Because i want to pass a prop to my header comp, there is located in the App.svelte - the same place for my route config.

from svelte-router.

davidhorak avatar davidhorak commented on May 23, 2024

@UIX-Design you can you these router level event handlers: https://github.com/spaceavocado/svelte-router#onnavigationchanged https://github.com/spaceavocado/svelte-router#onerror or https://github.com/spaceavocado/svelte-router#onbeforenavigation

from svelte-router.

Related Issues (16)

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.