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

strapi-plugin-custom-links

v0.3.0

Published

Create Custom-Links for your ContentTypes.

Downloads

168

Readme

A plugin for Strapi that allows you to create and edit URI for different ContentTypes.

Tested with Strapi 4.11.5

🔌 Installation

npm install strapi-plugin-custom-links

or

yarn add strapi-plugin-custom-links

⚙️ Configuration

You can configure the plugin directly from the Strapi interface in developer mode.

Go to Settings > Custom-Links Plugin > Configuration

And add content-types you wish to associate Custom-Links and just save it.

plugin settings

NOTE

Alternatively, you can create the config file by your own, by creating a file custom-links.js inside the folder config of your strapi project.

The file looks like this :

./config/custom-links.js

'use strict';

module.exports = {
  contentTypes: ['api::mycontenttype.mycontenttype', 'api::othercontentype.othercontentype'],
};

✏️ Create and edit Custom-Links

From the Content Manager

When editing a Content-Type, you will find at the right section a Custom-Link block, in wich you can create or update a Custom-Link by editing the URI field.

plugin editing

From the Custom-Links plugin section

You will be able to retrieve the list of Custom-Links from Plugins > Custom-Links section.

In this section you can search, filter, update or delete Custom-Links.

admin-custom-links

⚡️ API

Schema

| Field | Type | Unique | minLength | regExp | Description | | --------- | ------------ | ------ | --------- | --------------------- | ------------------------------------- | | id | biginteger | true | 1 | | The id of the Custom-Link | | uri | string | true | 1 | ^/[a-zA-Z0-9-_./]*$ | The uri of the Custom-Link | | kind | string | false | - | - | The uid of the ContentType associated | | contentId | biginteger | false | - | - | The id of the ContentType associated |

Basic Usage

Note on proxy pattern

Our own use of this plugin is to only rely on the URI to request every content-type (the same way you would request a node with Drupal 8) then dynamically create a template according to the nature of the data returned. This is a pattern called proxy.

Since this plugin can be enabled only on a few content-types, we reckon that you might need to fetch the custom-link collection itself (see Alternative usage)

Endpoints

As we always try to stay as close as possible of the strapi default behavior and core concept while developing this plugin, we think that per URI request shouldn't be used with a GET parameters because they prevent the request to be cached by the browser and are harder to manage behind a CDN.

| Method | URL | Description | Details | | ------ | ------------------------------ | --------------------------------------------------- | ------------------------------------------------ | | GET | /api/custom-links/proxy/:uri | Fetch the data of a Content-Type by its Custom-Link | By default components and relations are populate |

Response

/api/custom-links/proxy/my-article-uri

{
  "data": {
    "id": 1,
    "attributes": {
      "title": "My article",
      "slug": "my-article",
      "createdAt": "2022-08-01T16:32:35.878Z",
      "updatedAt": "2022-08-01T16:32:35.878Z",
      "component": [
        {
          "id": 1,
          "text": "A component"
        }
      ],
      "content": [
        {
          "__component": "core.component",
          "id": 2,
          "text": "A dyn component"
        }
      ]
    }
  },
  "meta": {
    "meta": {
      "customLink": {
        "id": "1",
        "uri": "/my-article-uri",
        "kind": "api::article.article",
        "contentId": "1"
      }
    }
  }
}

As you can see on the previous example we inject customLink data inside the meta of the result. This can also be used to retrieve a specific custom-link as seen in the following part.

Alternative Usage

You can also use the custom-link classic CRUD which exposes the same endpoints as the strapi default controller.

By requesting a Custom-Link collection, you can retrieve the kind (the Content-Type uid) and the contentId (the id of the ContentType) and then request the Content-Type associated.

This can be useful if you need to know the target content-type before making the request.

Endpoints

| Method | URL | Description | Details | | ------ | ------------------------- | ----------------------------- | --------------------------------------------- | | GET | /api/custom-links | Fetch custom links | For more information see Strapi documentation | | POST | /api/custom-links | Create a custom-link | - | | GET | /api/custom-links/:id | Fetch one custom-link | - | | GET | /api/custom-links/count | Get the count of custom-links | - | | PUT | /api/custom-links/:id | Update a custom-link | - |

🚧 Roadmap

We aim at providing a fully buffed plugin to leverage URI management and navigation issues in Strapi so it can become the true CMS it deserve. Here are a few ideas we will work on.

  • ✅ ~~Initial Release~~
  • 💡 Keep working on stability
  • 💡 Better documentation with use case and frontend examples
  • 💡 Redirections (for SEO purpose)
  • 💡 Batch import for redirections
  • 💡 Custom field with autocompletion
  • 💡 And much more !

🤝 Feedback and issues

Feel free raise an issue for any bug, feedback or idea you might have

As we have a mono repo for any current and future plugin we are developing, please specify the plugin you are raising an issue for.

🚀 Strapi Services

We are a small french agency with a strong Web Performance ortiented technical team; We work mainly with Strapi, and other NodeJS CMS, and with React and VueJS. If you need any help to develop a Strapi app or website, a Strapi plugin, if you need any services in Web Performance, feel free to contact us at [email protected]

📝 License

MIT License Copyright (c) la chose & Strapi Solutions.