Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-remark-related-posts

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-remark-related-posts

Calculate the similarity between posts by tf-idf and Cosine similarity.

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
411
decreased by-6.59%
Maintainers
1
Weekly downloads
 
Created
Source

npm version

Calculate the similarity between posts by tf-idf and Cosine similarity.

Installation

npm i --save gatsby-remark-related-posts

Example projects

Usage

// In your gatsby-config.js
plugins: [
  // ... other plugins
  `gatsby-remark-related-posts`,
  // ... other plugins
];

or

// In your gatsby-config.js
plugins: [
  // ... other plugins
  {
    resolve: 'gatsby-remark-related-posts',
    options: {
      doc_lang: 'en', // optional
      target_node: 'MarkdownRemark', // optional
      getMarkdown: (node) => node.rawMarkdownBody, // optional
      each_bow_size: 30, // optional
    },
  },
  // ... other plugins
];
optiontypedescription
doc_lang"en" | "ja" (default: "en")ISO 639-1 language code of your post.
target_node"MarkdownRemark" | "Mdx" | "StrapiArticle" (default: "MarkdownRemark")Gatsby node name to calculate similarity.
getMarkdownFunction: (node) => string (default: (node) => node.rawMarkdownBody)Function to get Markdown text from Gatsby node.
each_bow_sizenumber (default: 30)Adjust the size of the Bow vector. If you encounter problems during build, set it to a small value.

Querying Example

// query
`
{
  relatedMarkdownRemarks(parent: {id: {eq: $markdownRemarksId}}) {
    posts {
      frontmatter {
        title
      }
      fields {
        slug
      }
    }
  }
}
`;
// result
{
  "data": {
    "relatedMarkdownRemarks": {
      "posts": [
        {
          "frontmatter": {
            "title": "English language"
          },
          "fields": {
            "slug": "/11/"
          }
        },
        {
          "frontmatter": {
            "title": "Japanese language"
          },
          "fields": {
            "slug": "/12/"
          }
        },
        {
          "frontmatter": {
            "title": "Spanish language"
          },
          "fields": {
            "slug": "/13/"
          }
        },
        // ...
      ]
    }
  },
}

posts is array of MarkdownRemark ordered by related to $markdownRemarksId.

Licence

MIT

Keywords

FAQs

Package last updated on 12 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc