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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@commercetools-demo/contentools-page-renderer

v1.1.5

Published

Page renderer for rendering complete pages with layout grids and components

Readme

Page Renderer Package

A React component package for rendering complete pages with layout grids and components. This package is similar to content-item-renderer but specifically designed for rendering pages with their grid layouts.

Features

  • ✅ Renders complete pages with grid layouts
  • ✅ Supports both standalone and contextual rendering
  • ✅ Error boundary implementation
  • ✅ Responsive grid system
  • ✅ Content item rendering within grid cells
  • ✅ TypeScript support
  • ✅ Proper state management integration

Usage

import { PageRenderer } from '@commercetools-demo/contentools-page-renderer';

// Using with page object
<PageRenderer
  page={pageObject}
  baseURL="https://api.example.com"
  businessUnitKey="my-business-unit"
  locale="en-US"
/>

// Using with pageKey
<PageRenderer
  pageKey="my-page-key"
  baseURL="https://api.example.com"
  businessUnitKey="my-business-unit"
  locale="en-US"
/>

Props

| Prop | Type | Description | |------|------|-------------| | page | Page | The page object to render (required if pageKey is not provided) | | pageKey | string | The key of the page to fetch and render (required if page is not provided) | | query | string | Query string for fetching pages (not yet implemented) | | isDraft | boolean | Whether to render draft version (not yet implemented) | | baseURL | string | Base URL for API calls | | businessUnitKey | string | Business unit key for scoped API calls | | locale | string | Locale for rendering (default: 'en-US') | | className | string | Additional CSS class name | | style | React.CSSProperties | Additional styles | | loading | boolean | Show loading state | | error | string \| null | Custom error message | | onError | (error: Error) => void | Error callback |

Architecture

The package follows the same pattern as content-item-renderer:

  1. PageRenderer (main entry point) - Smart wrapper with error boundary
  2. ContextualRenderer - Renders within existing StateProvider context
  3. StandaloneRenderer - Wraps in StateProvider if context missing
  4. PageResolver - Handles page fetching and resolution
  5. PageGridRenderer - Renders the actual page grid layout

Grid System

The page renderer creates a responsive CSS Grid based on the page's layout configuration:

  • Each row becomes a CSS grid container
  • Cells use grid-column: span X for responsive behavior
  • Default 12-column grid system with 1rem gaps
  • Content items are rendered within grid cells using ContentItemRenderer

Dependencies

  • @commercetools-demo/contentools-types - Type definitions
  • @commercetools-demo/contentools-state - State management
  • @commercetools-demo/contentools-content-item-renderer - For rendering content items
  • @commercetools-demo/contentools-ui-components - UI components
  • @emotion/react - Styling
  • styled-components - Component styling

Missing Features / Limitations

Compared to content-item-renderer, the following features are not yet implemented:

1. Published Version Support

  • fetchPublishedPage method not available in useStatePages hook
  • isDraft prop functionality limited
  • Impact: Can only fetch draft versions of pages currently

2. Query Support

  • queryPage / queryPublishedPage methods not available in useStatePages hook
  • query prop throws warning and error
  • Impact: Cannot fetch pages by query string

3. Advanced Grid Features

  • ❌ Grid breakpoint customization
  • ❌ Custom grid gap configuration
  • ❌ Grid alignment and justification options
  • Impact: Limited responsive design customization

4. Page-level Metadata Rendering

  • ❌ Page title, meta description, SEO tags
  • ❌ Route-based rendering
  • Impact: SEO and metadata features not available

5. Layout Validation

  • ❌ Grid layout validation and error handling
  • ❌ Cell overlap detection
  • ❌ Missing content item handling in cells
  • Impact: Potential layout issues with invalid configurations

Recommendations for Future Development

  1. Extend useStatePages hook to include:

    • fetchPublishedPage(hydratedUrl, pageKey)
    • queryPage(hydratedUrl, query)
    • queryPublishedPage(hydratedUrl, query)
  2. Add page metadata rendering:

    • Title and meta tag rendering
    • SEO optimization features
    • Open Graph and Twitter Card support
  3. Enhance grid system:

    • Custom breakpoint configuration
    • Grid template customization
    • Better responsive behavior
  4. Add layout validation:

    • Cell overlap detection
    • Grid consistency checks
    • Content item availability validation
  5. Performance optimizations:

    • Lazy loading for off-screen content
    • Content item caching
    • Grid virtualization for large layouts

Example Page Structure

{
  "key": "homepage",
  "name": "Homepage",
  "route": "/",
  "layout": {
    "rows": [
      {
        "id": "row1",
        "cells": [
          {
            "id": "cell1",
            "contentItemKey": "hero-banner",
            "colSpan": 12
          }
        ]
      },
      {
        "id": "row2", 
        "cells": [
          {
            "id": "cell2",
            "contentItemKey": "featured-products",
            "colSpan": 8
          },
          {
            "id": "cell3",
            "contentItemKey": "sidebar-banner",
            "colSpan": 4
          }
        ]
      }
    ]
  },
  "components": [
    {
      "key": "hero-banner",
      "type": "banner",
      "properties": { ... }
    },
    {
      "key": "featured-products",
      "type": "product-grid", 
      "properties": { ... }
    }
  ]
}