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

@x3m-group/strapi-plugin-auto-links

v1.0.8

Published

Auto generate links for resources (self, canonical, alternates, ...)

Downloads

3

Readme

strapi-plugin-auto-links

A plugin for Strapi that auto generate links for resources (self, canonical, alternates, ...)

Downloads Install size Package version

Requirements

The installation requirements are the same as Strapi itself and can be found in the documentation on the Quick Start page in the Prerequisites info card.

Supported Strapi versions

  • v4.x.x

Installation

npm install @x3m-group/strapi-plugin-auto-links

# or

yarn add @x3m-group/strapi-plugin-auto-links

Configuration

The plugin configuration is stored in a config file located at ./config/plugins.js or ./config/plugins.ts.

A minimal configuration

module.exports = ({ env }) => ({
  // ...
  "auto-links": {
    enabled: true,
    config: {
      contentTypes: {
        article: {},
      },
    },
  },
  // ...
});

Custom Canonical configuration

module.exports = ({ env }) => ({
  // ...
  "auto-links": {
    enabled: true,
    config: {
      canonical: {
        host: "https://{item.locale}.example.com",
        path: "/resources/{model.info.pluralName}/{item.slug}",
      },
      contentTypes: {
        author: {},
        article: {},
        tag: {
          canonical: {
            host: "https://tags.example.com",
            path: "/{item.slug}?q=all",
          },
        },
      },
    },
  },
  // ...
});

Example result

http://localhost:1337/api/articles?populate=*

{
  "data": [
    {
      "id": 1,
      "attributes": {
        "title": "My First Article English",
        "slug": "my-first-article-english",
        "locale": "en",
        "localizations": {
          "data": [
            ...
          ]
        },

        // newly auto generated links
        "links": {
          "self": "http:/localhost:1337/api/articles/1",
          "canonical": "https:/example.com/articles/my-first-article-english",
          "alternates": [
            {
              "locale": "nl",
              "self": "http:/localhost:1337/api/articles/2",
              "canonical": "https:/example.com/articles/mijn-eerste-artikel-nederlands"
            }
          ]
        }
        // ...

      }
    }
  ],
  "meta": {
    ...
  }
}

Configuration Object

| Property | Description | Type | Default | Required | |----------|-------------|------|---------|----------| | self | global self configuration | Object | {} | No | | self.enabled | enable self url rendering | Boolean | true | No | | self.host | default global self host pattern | String | env SELF_HOST or http://localhost:1337 | No | | self.path | default global self path pattern | String | /api/{model.info.pluralName}/{item.id} | No | | canonical | global canonical configuration | Object | {} | No | | canonical.enabled | enable canonical url rendering | Boolean | true | No | | canonical.host | default global canonical host pattern | String | env CANONICAL_HOST or https://example.com | No | | canonical.path | default global canonical path pattern | String | /{item.locale}/{model.info.pluralName}/{item.slug} | No | | alternates | global alternates configuration | Object | {} | No | | alternates.enabled | enable alternates url rendering (localized links) | Boolean | true | No | | contentTypes | The Content Types to add auto links | Object | {} | No | | contentTypes[modelName] | The model name of the content type (it is the singularName in the model schema) | Object | {} | Yes | | contentTypes[modelName].self | override global self configuration | Object | {} | No | | contentTypes[modelName].self.enabled | enable self url rendering | Boolean | true | No | | contentTypes[modelName].self.host | self host pattern | String | global value | No | |contentTypes[modelName].self.path | self path pattern | String | global value | No | | contentTypes[modelName].canonical | override global canonical configuration | Object | {} | No | | contentTypes[modelName].canonical.enabled | enable canonical url rendering | Boolean | true | No | | contentTypes[modelName].canonical.host | canonical host pattern | String | global value | No | | contentTypes[modelName].canonical.path | canonical path pattern | String | global value | No | | contentTypes[modelName].alternates | override global alternates configuration | Object | {} | No | | contentTypes[modelName].alternates.enabled | enable alternates url rendering (localized links) | Boolean | true | No |

Context Vars

| Property | Description | Type | |----------|-------------|------| | item | the current resource item | Object | | item.* | all available properties of the resource item (must be selected/populated) | Any | | model | the current resource schema information | Object | | model.kind | defines if the content-type is collectionType or singleType | String | | model.collectionName | database table name in which the data should be stored | String | | model.info | strapi model information | Object | | model.info.displayName | default name to use in the admin panel | String | | model.info.singularName | singular form of the content-type name | String | | model.info.pluralName | plural form of the content-type name | String |