npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aurelia-router-metadata

v0.12.0

Published

Adds decorator configuration with conventions and eager loading capabilities to aurelia-router

Downloads

82

Readme

aurelia-router-metadata

Metadata extension for aurelia-router aimed at simplifying router configuration and providing "eager loading" capabilities.

The @routeConfig({...}) and @configureRouter([...]) decorators largely eliminate the need for configureRouter() and make configuration a bit more like the [Route()] attributes in ASP.NET.

NEW SINCE 0.9: Static code analysis and smart autoconfiguration. See the demo app pages for example config combinations that work.

This is enabled by default. It can be disabled in the settings (see below).

View a LIVE DEMO

Installation

Install the npm dependency via

npm i aurelia-router-metadata

or via the Aurelia CLI

au install aurelia-router-metadata

If you are using webpack, no additional steps are required. Simply import a decorator and it will work.

Aurelia-CLI

For Aurelia-CLI projects based on RequireJS or SystemJS, the following will install and declare the dependency in your aurelia.json:

au install aurelia-router-metadata

or if you have already installed and only need to add the dependency to aurelia.json:

au import aurelia-router-metadata

alternatively you can manually add the dependency to your vendor.bundles:

"dependencies": [
  {
    "name": "aurelia-router-metadata",
    "path": "../node_modules/aurelia-router-metadata/dist/amd",
    "main": "aurelia-router-metadata"
  }
]

Configuration

IMPORTANT: as of version 0.9, configuring the plugin via FrameworkConfiguration is mandatory

import { Aurelia } from "aurelia-framework";
import { RouterMetadataSettings } from "aurelia-router-metadata";

export function configure(au: Aurelia) {
  au.use.standardConfiguration();

  au.use.plugin("aurelia-router-metadata", (settings: RouterMetadataSettings) => {
    settings.routerConfiguration.title = "Foo";
    settings.enableStaticAnalysis = false; // enabled by default
  });

  au.start().then(() => au.setRoot());
}

Usage

  • With decorators
import { configureRouter } from "aurelia-router-metadata";

// Make sure to wrap these in `PLATFORM.moduleName` when using webpack
@configureRouter([
  "pages/foo",
  "pages/bar",
  "pages/default"
])
export class App { }

...

export class Foo { }

...

export class FooBar { }

...

import { routeConfig } from "aurelia-router-metadata";

@routeConfig({ route: "", nav: false })
export class Default {}
  • Without decorators
export class App {
  public configureRouter(config: RouterConfiguration, router: Router): void {
    // Will be statically analyzed and automatically configured
    config.map([
      { moduleId: "pages/foo" },
      { moduleId: "pages/bar" },
      { moduleId: "pages/default" }
    ]);
  }
}
  • Combined
@configureRouter(["pages/foo", "pages/bar"])
export class App {
  public configureRouter(config: RouterConfiguration, router: Router): void {
    config.map({ moduleId: "pages/default" });
  }
}

Building a navigation menu

Conceptually:

nav-menu.html

<template bindable="routes">
  <ul>
    <li repeat.for="route of routes">
      <a href.bind="route.settings.path">${route.title}</a>
      <template if.bind="route.settings.childRoutes">
        <nav-menu routes.bind="child.settings.childRoutes"></nav-menu>
      </template>
    </li>
  </ul>
</template>

For a working example see the live demo

Feedback

It's still in early development and needs more testing and feedback.

Feel free to reach out with any questions/issues/suggestions :)

Building The Code

  1. From the project folder, execute the following command:
yarn/npm install
  1. To build the code:
npm run build

Running The Tests

  1. To run the tests
npm run test
  1. To continuously run the tests
npm run develop