oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.02k stars 47 forks source link

Custom path not working #142

Closed coldagofee closed 9 months ago

coldagofee commented 9 months ago

default config

it working as expected stackblitz default config

router.ts:

// Generouted, changes to this file will be overriden
/* eslint-disable */

import { components, hooks } from '@generouted/solid-router/client'

export type Path =
  | `/`
  | `/about`

export type Params = {

}

export type ModalPath = never

export const { A, Navigate } = components<Path, Params>()
export const { useMatch, useModals, useNavigate, useParams } = hooks<Path, Params, ModalPath>()

custom path config

i followed this example, but my app just showing blank page. stackblitz custom config

vite.config.ts:

import { defineConfig } from 'vite';
import solid from 'vite-plugin-solid';
import generouted from '@generouted/solid-router/plugin';

export default defineConfig({
  plugins: [
    solid(),
    generouted({
      source: {
        routes: './src/custom/**/[\\w[-]*.{jsx,tsx}',
        modals: './src/custom/**/[+]*.{jsx,tsx}',
      },
    }),
  ],
});

router.ts:

// Generouted, changes to this file will be overriden
/* eslint-disable */

import { components, hooks } from '@generouted/solid-router/client'

export type Path =
  | `///src/custom`
  | `///src/custom/about`

export type Params = {

}

export type ModalPath = never

export const { A, Navigate } = components<Path, Params>()
export const { useMatch, useModals, useNavigate, useParams } = hooks<Path, Params, ModalPath>()
oedotme commented 9 months ago

@coldagofee The routes directory should always end with src/pages as a convention, this option was introduced for certain projects that requires a certain nested structure as in full stack non-js projects or non-workspace monorepo tooling.

You can replace the config directory with ./some-directory/src/pages/..., also you'd need to have a custom ./some-directory/src/routes.tsx similar to ./client/src/routes.tsx to scan the routes correctly based on the custom path.

coldagofee commented 9 months ago

@oedotme oooh thanks for the explaination