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

@startinblox/router

v0.12.9

Published

Startinblox router

Downloads

1,194

Readme

solid-router

This is a series of web component respecting both the web components standards and the Linked Data Platform convention. They are aimed at enabling anyone with little development skills to create their own web application by placing these components in an HTML file.

An full app example can be found in index.html:

Initialization

You first need to load the webcomponents polyfill for the browsers that have not implemented them yet, and import the components you want to use in your HTML file:

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.20/webcomponents-loader.js"></script>
<script type="module" src="https://unpkg.com/@startinblox/router@latest"></script>

Then you can use the new tags in your markup, for instance : <solid-router>. More details on each component in the following section.

Usage

Displays a menu and handle the navigation for you.

<solid-router 
    default-route="list"
    route-prefix="my-app"
    use-hash
>
    <solid-route name="list">List</solid-route>
    <solid-route name="form">Form</solid-route>
    <solid-route name="detail">Details</solid-route>
</solid-router>

<solid-router> attributes:

  • default-route: The name attribute of the default <solid-route> displayed.
  • route-prefix: If you app is not run from the root of your domain name, for instance www.your-domain.com/some-uri, you should set route-prefix to "some-uri".
  • use-hash: If you can't rewrite the URLs on your server, you might want to set this attribute to use location.hash instead of location.pathname as URLs.

<solid-route> attributes:

  • use-id: indicates that the route takes an id.
  • name: The name of the route. Must match the id of the view that is to be displayed. The same name is used as a url identifier as well.
  • rdf-type: Can be used as an alternative of name. The route will be activated if a resource with the given type is passed to the router.
  • active: This attribute is present on route being displayed by <solid-router>. It is automatically added/removed by <solid-router> and should not be tinkered manually.

solid-link

<solid-link> accepts the following attributes:

  • next: The name attribute of the <solid-route> you want to access.

Example:

<solid-link next="profile">See profile</solid-link>

solid-analytics

Manage browsing statistics.

Sign in on a web analytics service and set <solid-analytics> inside <body>, at the begining for example.

<solid-analytics> accepts the following attributes:

  • type: the type of web analytics service used (currently supports 'matomo', 'google' or 'debug').
  • url: URL of the service. For type="google" it is not necessary to specify the url attribute.
  • id: id of the website on the service.

Type 'debug' allow to test solid-analytics. It will display the route on the console each time a navigation is triggered.

Example :

<solid-analytics type="matomo" url="https://matomo.example.com/" id="1234"></solid-analytics>

Interacting with the router

bind-resources attribute

To associate the currently displayed resource to a component, add the bind-resources attribute to it. It will set its data-src attribute to the currently displayed resource's URL.

Example:

<sib-conversation bind-resources></sib-conversation>

will result in:

<sib-conversation data-src="https://your-domain/your-group-uri/3" bind-resources></sib-conversation>

RequestNavigation

To trigger a route change through javascript, you can trigger a RequestNavigation event anywhere on the DOM.

The detail part must have at least one of these two parameters:

  • route: the name of the route to activate
  • resource: a resource that will be passed to all elements with the bind-resources attribute. If no route name is given, the router tries to find a route that has a rdf-type that matches the type of the resource.

Events

navigate

This event is triggered whenever a route is activated, after the view is displayed.

License

Licence MIT