2.1.2 • Published 7 years ago

limosa v2.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 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

7 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago