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

@websolutespa/payload-plugin-seo

v0.1.1

Published

SEO plugin for PayloadCms

Downloads

282

Readme

@websolutespa/payload-plugin-seo

npm version

status alpha

SEO plugin for PayloadCms.

Payload SEO Plugin

A plugin that allows you to manage the meta tags associated with the pages in your site.

Create rules for managing the meta tags of all the documents in specific collections or a global rule for all collections. Use of tokens allows you to add dynamic values to each meta field.

Requirements:

  • Payload version 2.28.0 or higher is required.

Installation

npm i @websolutespa/payload-plugin-seo

Usage

import { buildConfig } from 'payload/config';
import seo from '@websolutespa/payload-plugin-seo';

export default buildConfig({
  plugins: [
    seo({
      collections: [
        Homepage.slug,
        Post.slug,
      ],
      additionalFields: [
        {
          name: 'robots',
          type: 'text',
        },
      ],
      customTokens: [
        {
          name: 'uppercase-title',
          replacementFunction: async (req, collection, doc: { title?: string }, locale) => {
            if (!doc.title) {
              return '';
            }

            if (locale) {
              const fieldConfig = getDataField(collection.fields, 'title');
              return fieldConfig.localized ? doc.title[locale.code]?.toUpperCase() : doc.title.toUpperCase();
            }
            else {
              return doc.title.toUpperCase();
            }
          },
        },
      ],
      metatagsRulesAccess: {
        read: ({ req: { user } }) => { return Boolean(user); },
        create: ({ req: { user } }) => { return Boolean(user); },
        update: ({ req: { user } }) => { return Boolean(user); },
        delete: ({ req: { user } }) => { return Boolean(user); },
      },
      qsMetatagsRules: 'seoMetatagsRules',
    }),
    // The rest of your plugins config goes here
  ],
});

Plugin options

| Option | Type | Description | |----------------------|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | collections | string[] | An array of collection slugs. The creation of a global rule will only affect the meta tags of the collections specified through this option. During the creation of a rule, only collections specified through this option will be selectable. | | additionalFields | DataField[] | An array of additional fields. These fields will be added to the metatags rules collection, so that you can define rules for additional custom meta tags in addition to those provided from the plugin. | | customTokens | (SeoToken)[] | An array of custom tokens objects. Each token has a name and a replacementFunction. The function has the following parameters:- req: Payload request object- collection: CollectionConfing of the requested document- doc: the document and all its data - locale: the locale for which to return the token value. Only present if the request has the locale=ALL parameter set, otherwise this parameter is null. | | metatagsRulesAccess | (MetatagsRuleAccess)[] | Define the access control functions for the metatags rule collection. | | qsMetatagsRules | string | The name of the querystring parameter which needs to be added to the REST API requests to trigger the evaluation of the metatags rules associated with the requested document. |

Features

  • allows the creation of rules for managing the meta tags of all the documents in specific collections or a global rule for all collections
  • use of tokens allows you to add dynamic values to each meta field
  • define custom tokens with custom replacement functions
  • custom meta tags can be defined in addition to those provided by the plugin
  • this plugin is fully compatible with the official Payload SEO plugin: rules will not override meta tags defined at the document level
this library is for internal usage and not production ready