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

vendure-plugin-catalog-export

v1.0.9

Published

The plugin automates the generation of a comprehensive JSON representation of your product catalog. This data is made accessible via a REST API endpoint, facilitating easy retrieval for frontend applications.

Downloads

4

Readme

vendure-plugin-catalog-export

The plugin automates the generation of a comprehensive JSON representation of your product catalog. This data is made accessible via a REST API endpoint, facilitating easy retrieval for frontend applications. By leveraging this JSON data, dynamic sitemaps and product feeds can be dynamically generated, enhancing your store's SEO capabilities. Additionally, this approach helps mitigate the risk of server overload, ensuring optimal performance even during peak traffic periods

Installation

npm

npm install vendure-plugin-catalog-export

vendure config

const config: VendureConfig = {
  // ... other configurations

  plugins: [
    ProductCatalogPlugin.init({
      localPath:'../myCatalogDir', //relative to AssetUploadDir
    }),
    ProductCatalogPlugin, //save without localPath into default folder static/productcatalog
    ...
  ],
};

APIs

http://localhost:3000/productcatalog-save to init and save catalog
http://localhost:3000/productcatalog to access the json
http://localhost:3000/productcatalogAll only list all Products.

Example output

JSON

{
  "productCatalog": {
    "1": {
      "id": 1,
      "name": "Laptop",
      "slug": "laptop",
      "updatedAt": "2023-11-12T12:10:32.773Z",
      "facetValues": [
          {
              "name": "Electronics",
              "code": "electronics",
              "facet": {
                  "code": "category",
                  "name": "Category"
              }
          },
        "..."
      ],
      "assets": [
          {
              "preview": "preview/71/derick-david-409858-unsplash__preview.jpg",
              "source": "source/b6/derick-david-409858-unsplash.jpg"
          }
      ],
      "featuredAsset": {
          "preview": "preview/71/derick-david-409858-unsplash__preview.jpg",
          "source": "source/b6/derick-david-409858-unsplash.jpg",
          "name": "derick-david-409858-unsplash.jpg"
      },
      "optionsGroups": [
          {
              "id": 1,
              "code": "laptop-screen-size",
              "name": "screen size"
          },
          "..."
      ],
      "variants": [
          {
              "id": 1,
              "priceWithTax": 0,
              "outOfStockThreshold": 0,
              "sku": "L2201308",
              "name": "Laptop 13 inch 8GB",
              "assets": [],
              "featuredAsset": {},
              "options": [
                  {
                      "code": "13-inch",
                      "name": "13 inch"
                  },
                  {
                      "code": "8gb",
                      "name": "8GB"
                  }
              ]
          },
          "..."
      ]
  },
  "..."
}

Sitemap generator

In this example we use the package remix-sitemap

export const sitemap: SitemapFunction = async () => {
  const res = await fetch("http://localhost:3001/productcatalog");
  const data = await res.json();
  const allProducts = data.productCatalog;
  const sitemapProducts = [];
  for (const productId in allProducts) {
    if (allProducts.hasOwnProperty(productId)) {
      const product = allProducts[productId];
      sitemapProducts.push({
        slug: product.slug,
        updatedAt: product.updatedAt,
      });
    }
  }
  if (Array.isArray(sitemapProducts)) {
    const sitemapData = sitemapProducts.map((product) => ({
      loc: `/products/${product.slug}`,
      lastmod: product.updatedAt,
      changefreq: 'weekly',
      priority: 0.8,
    }));
    return sitemapData;
  } else {
    console.error('No "products" array found in the API response');
  }
};