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

solidus-metadata

v1.0.1

Published

[RDFa][rdfa], [Schema.org][schema], [Open Graph][open], and good ol’ [meta tags][meta]. The semantic web is really an actual thing! But getting the right tags and code in place takes time. That’s time you _should_ be spending optimizing the content as bes

Downloads

6

Readme

solidus-metadata CircleCI Status

RDFa, Schema.org, Open Graph, and good ol’ meta tags. The semantic web is really an actual thing! But getting the right tags and code in place takes time. That’s time you should be spending optimizing the content as best as you can. The plethora of API data available in a typical Solidus site offers plenty to work with. But passing that content into the right tags remains tricky, until now.

var metadata = require('metadata.json');
var addMetadata = require('solidus-metadata');

addMetadata( context, metadata );

metadata

This module adds a metadata object to your context that’s most useful in a page’s layout. Content can be defined for any of the following special properties:

title

Generally prone to truncation, so it really shouldn’t be longer than 55 characters.

description

A blob of text, that should prioritize what really needs to be said in the first ~155 characters.

image

A thumbnail, for use in og:image, twitter:image, etc.

ns:*

Open Graph tags, Twitter Cards, or any other namespaced RDF properties.

canonical

A path or URL pointing to the canonical version of the current page.

Mapping

Simple routing patterns are used to match the routes of your pages and map the desired data to their context when rendered. Any variables should be specified in {curly} syntax, just like the filesystem:

{
  "/news": {
    "title": "resources.post.title",
    "description": "resources.post.excerpt"
  },
  "/news/{id}/{slug}": {
    "title": "resources.post.title",
    "description": "resources.post.excerpt",
    "image": "resources.post.featured_image.source",
    "og:type": "article",
    "canonical": "/news/{id}/{slug}"
  }
}

YAML is recommended for sites bigger than a couple of pages. It’s a tool that helps direct focus on the content, and avoid syntax errors through a more lenient syntax than JSON. js-yaml is a good parsing module.

/news/{id}/{slug}:

  title: resources.post.title
  description: resources.post.excerpt
  image: resources.post.featured_image.source
  og:type: article
  canonical: /news/{id}/{slug}

Fallbacks / Defaults

It’s a good idea to add at least one fallback route to provide some default metadata when no other routes are matched. Just add a * at the end of a path a page should fallback to:

/anything/*:

  title: The infinite is possible.
  description: You can do anything, anything at all.

Whenever possible provide a descriptive and concise for your pages to avoid filling indexes with repetitive, unhelpful content. Fallbacks should not be relied upon as they will do just that if not used sparingly.

Content

All content is defined as strings. Aside from simple text, certain patterns trigger some additional magic when matched:

  • Files are strings that look like relative paths and end with an image file extension: gif|jpg|jpeg|png

  • URLs are strings beginning with http that are valid URLs

  • Data is a string without any spaces that can select anything in your context with dot notation. No worries, deeply nested properties will be safely accessed. Items in an array can be selected by their index with dot or bracket syntax. Properties can also be accessed from within text using {{property}} syntax. There’s no limit to how many you can select. Any markup in the resulting string will be stripped.

  • Canonical Path Variables can be specified in the same {curly} syntax as page routes, and will be replaced with any like-named variables from the matched route. Relative paths will be automatically prefixed with the current host.


MIT LICENSE copyright © 2015 sparkart group, inc.