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

@oak-digital/nextjs-strapi-plugin-seo

v0.1.2

Published

This library provides Nextjs [`<Head>`](https://nextjs.org/docs/api-reference/next/head) components for [`strapi-plugin-seo`](https://github.com/strapi/strapi-plugin-seo). This makes it easy to utilize `strapi-plugin-seo` without much to do in your fronte

Downloads

65

Readme

Nextjs components for strapi-plugin-seo

This library provides Nextjs <Head> components for strapi-plugin-seo. This makes it easy to utilize strapi-plugin-seo without much to do in your frontend application.

Getting started

Installation

Install the library

# pnpm
pnpm install @oak-digital/nextjs-strapi-plugin-seo
# npm
npm install @oak-digital/nextjs-strapi-plugin-seo
# yarn
yarn add @oak-digital/nextjs-strapi-plugin-seo

Usage - App router

In a page.tsx file you should use generateMetadata where you fetch the entry from strapi with the seo field populated. And then you can create the metadata with the getMetadataFromSeo function.

import { getMetadataFromSeo } from '@oak-digital/nextjs-strapi-plugin-seo';

export const generateMetadata = (props) => {
    // This should be your fetcher
    const page = await fetchPageWithSeo();

    const seoMetadata = getMetadataFromSeo({ seo: page.attributes.seo });

    return {
        ...seoMetadata,
        // Here you can add any other fields that you may want on the meta data
    };
};

Usage - Pages router

On your page that fetches the seo component you can simply import the Seo component and pass the data. NOTE: It should not be wrapped in a next/head component, this is done internally.

import { Seo, SeoProps } from '@oak-digital/nextjs-strapi-plugin-seo';

type Props = {
    seo: SeoProps['seo'];
    pageProps: any;
};

const MyPage: NextPage<Props> = ({ seo }) => {
    return (
        <main>
            <Seo seo={seo} strapiUrl={'https://your-strapi-url.example:1337'} />
        </main>
    );
};

Fetching

When fetching you may also want to populate the fields for seo, for this there is added a helper array with the fields that needs to be populated (seoDeepPopulateFields ). This can easily be used with qs or some other strapi client.

Example with qs

This example assumes that your seo component's name is seo from the content type, edit the populate seo to the one that you use.

const query = qs.stringify({
    populate: {
        seo: {
            populate: seoDeepPopulateFields,
        },
    },
});

Testing locally

For testing purposes, there has been added an /example directory, where a strapi instance can be started and nextjs to make sure all the seo fields are correctly added.

Read more

Publishing

Publishing will happen automatically with github actions. Just run pnpm run release