2.1.2 • Published 8 years ago

limosa v2.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

limosa NPM version

DEPRECATED: replaced by router-segments

Fast router for both browser and server

Build Status Coverage

See the auto-generated docs

How to use

import { RouterBuilder, RoutesTranslations } from 'limosa';


const routesLangsConfig = new Map([
    ['login', new Map([['en', 'login'], ['fr', 'connexion']])],
    ['post', new Map([['en', 'post'], ['fr', 'article']])],
    ['view', new Map([['en', 'view'], ['fr', 'afficher']])],
]);

const routesTranslations = new RoutesTranslations(routesLangsConfig);

const builder = new RouterBuilder(routesTranslations, ['en', 'fr']);
module.exports = builder.router;

builder
    .add('/', '/', 'site.index')
    .add('postView', '/post/${id}-${slug}', 'post.view', {
        namedParamsDefinition: { slug: '[A-Za-z\-]+' },
        extension: 'htm'
    })
    .addDefaultRoutes();

Build a router

  • Named parameter: ${name}
  • Optional route part: [] like '/post[/${tagKey}]/${id}-${slug}'
  • Special named parameters: controller, action, queryString, hash.

Url Generator

router.urlGenerator('en', 'postView', { id: '001', 'a-slug' });
// /post/001-a-slug
2.1.2

8 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.6

9 years ago

2.0.5

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago