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

@siteone/seo-toolbar

v0.4.1

Published

Component for editing SEO tags

Downloads

5

Readme

SEO toolbar

Widget for managing meta tags. Build on top of react-jsonschema-form

Default Widgets and Fields

Usage

Simply install latest stable version of @siteone/seo-toolbar

yarn add @siteone/seo-toolbar

There are two components exported as Seo Toolbar with slightly different API:

1) SeoToolbarExtended

Convenient export for minimal setup. Generates rjsf schema from data object for you and selects corresponding field widgets, labels and descriptions. But lacks sophisticated customization.

import { SeoToolbarExtended } from '@siteone/seo-toolbar'

const data = {
  title: 'Some test page title',
  sitemapChangefreq: 'DAILY',
  description: 'SEO friendly page description',
  robotsFollow: true,
}
const onSubmit = data => alert(JSON.stringify(data, null, 2))

export default function Toolbar() {
  return (
    <SeoToolbarExtended
      data={data}
      onSubmit={onSubmit}
    />
  )
}

2) SeoToolbar

Allows complex setup but requires deeper understanding of rjsf

For easier use, @siteone/seo-toolbar also exports transformObjectToSchema and generateUiSchema for generating basic settins. These functions generates JSON schema with predefined form labels, descriptions and uiSchema with widgets for your data.

Note that it form labels, descriptions, select options and widgets are only applied to standardized SeoToolbarData

Other data will also work but may not look exactly how you desire.

For that case, you may consider using more customized Seo Toolbar

import SeoToolbar, { transformObjectToSchema, generateUiSchema } from '@siteone/seo-toolbar'

const data = {
  title: 'Some test page title',
  sitemapChangefreq: 'DAILY',
  description: 'SEO friendly page description',
  robotsFollow: true,
}
const onSubmit = data => alert(JSON.stringify(data, null, 2))

const schema = transformObjectToSchema(data)
const uiSchema = generateUiSchema(schema)

export default function Toolbar() {
  return (
    <SeoToolbar
      schema={schema}
      onSubmit={onSubmit}
      uiSchema={uiSchema}
    />
  )
}

If you want to have more control, here's how to achieve the same result as above without utility functions

import SeoToolbar from '@siteone/seo-toolbar'

const data = {
  title: 'Some test page title',
  sitemapChangefreq: 'DAILY',
  description: 'SEO friendly page description',
  robotsFollow: true,
}
const onSubmit = data => alert(JSON.stringify(data, null, 2))

const schema = {
  type: 'object',
  properties: {
    title: {
      type: 'string',
      default: 'Some test page title',
      title: 'Title',
    },
    sitemapChangefreq: {
      type: 'string',
      default: 'DAILY',
      enum: [ 'ALWAYS', 'HOURLY', 'DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY', 'NEVER' ],
      title: 'Sitemap (changefreq)',
      description: 'Jak často má Google reindexovat tuto stránku? (je to jen hint, ne příkaz)',
    },
    description: {
      type: 'string',
      default: 'SEO friendly page description',
      title: 'Description',
    },
    robotsFollow: {
      type: 'boolean',
      default: true,
      title: 'Robots (follow): mají vyhledávače nasledovat odkazy na této stránce?',
    },
  }
}
const uiSchema = {
  description: {
    'ui:widget': 'textarea',
  },
}

export default function Toolbar() {
  return (
    <SeoToolbar
      schema={schema}
      onSubmit={onSubmit}
      uiSchema={uiSchema}
    />
  )
}

Customizing Send button

By default, submit button with basic caption and styling is applied. But what if you need a little customization?

import { SeoToolbarExtended } from '@siteone/seo-toolbar'

const data = {
  title: 'Some test page title',
  sitemapChangefreq: 'DAILY',
  description: 'SEO friendly page description',
  robotsFollow: true,
}
const onSubmit = data => alert(JSON.stringify(data, null, 2))

export default function Toolbar() {
  return (
    <SeoToolbarExtended
      data={data}
      onSubmit={onSubmit}
    >
        <button type={'reset'}>Reset</button>
        <button type={'submit'}>Send</button>
    </SeoToolbarExtended>
  )
}

It's only important to use type="submit" so that onSubmit function is mapped properly

Remember to import this package on non user-facing pages so that is does not get into your main bundle, or load it asynchronously. This package contains @rjsf/core package which is quite hefty

Documentation

You can use all props from @rjsf/core on both SeoToolbarExtended and SeoToolbar.

import { SeoToolbarExtended } from '@siteone/seo-toolbar'

| Prop | Type | Default | Required | Description | | :--- | :--- | :---: | :--- | :--- | | data | SeoToolbarData | | ✓ | Initial data from which the rjsf schema will be constructed. | | onSubmit | (data: SeoToolbarData) => void | | ✓ | Function called after form is submitted | | titles | Object<String, String> | | | If you want to override default form labels for data. Object keys must match data keys | | required | Array | | | Required fields. Strings must match data keys | | title | String | | | Title of the form group. By default represented by a legend element inside a fieldset |

import SeoToolbar from '@siteone/seo-toolbar'

| Prop | Type | Default | Required | Description | | :--- | :--- | :---: | :--- | :--- | | schema | Object | | ✓ | JSON schema | | onSubmit | (data: SeoToolbarData) => void | | ✓ | Function called after form is submitted |

Input Data

type SeoToolbarData = {
  uri?: String,
  title?: String,
  keywords?: String,
  description?: String,
  robotsIndex?: Boolean,
  robotsFollow?: Boolean,
  robotsArchive?: Boolean,
  robotsSnippet?: Boolean,
  sitemapChangefreq?: 'ALWAYS' | 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY' | 'NEVER',
  sitemapPriority?: '1.0' | '0.9' | '0.8' | '0.7' | '0.6' | '0.5' | '0.4' | '0.3' | '0.2' | '0.1' | '0.0',
  updateDatetime?: String,
  note?: String
}

Development

This package uses storybook for development and examples

Check it outwith:

yarn install && yarn dev

Build & Deployment

This package uses microbundle package for bundling. Run basic build with

yarn build