@marvalt/shcoder
v0.1.39
Published
Shortcode renderer components for DigiValt CPTs (Members, Testimonials, Projects, etc.)
Readme
@marvalt/shcoder
Shortcode renderer components for DigiValt Custom Post Types (Members, Testimonials, Projects, etc.)
Documentation
- After install:
node_modules/@marvalt/shcoder/docs/README.md - Requires
wp-custom-api-endpointsWordPress plugin and staticwordpress-data.jsonfrom@marvalt/digivalt-core.
Overview
This package provides React components and hooks for rendering WordPress shortcodes in headless React applications. It works in conjunction with the wp-custom-api-endpoints WordPress plugin, which auto-discovers CPTs and registers shortcodes dynamically.
Installation
npm install @marvalt/shcoderUsage
Components
Member Components
- MemberCard - Displays a single member profile
- MemberCardsGrid - Displays multiple members in a grid layout
- MemberSlideshow - Displays members in a rotating slideshow
Post Components
- PostCard - Displays a single post
- PostCardsGrid - Displays posts in a grid
- PostSlideshow - Displays posts one at a time
getPostShortcodeHandlers() merges [post_card], [post_cards], [post_slideshow], and [latest_posts] into a wparser registry. Call setPostsStaticDataProvider with static posts, categories, and tags before render. @marvalt/digivalt-core does this from createContentRegistry().
Testimonial Components
- TestimonialCard - Displays a single testimonial
- TestimonialCardsGrid - Displays multiple testimonials in a grid layout
- TestimonialSlideshow - Displays testimonials in a rotating slideshow
Hooks
- useMembers - Fetch members based on shortcode attributes
- useMember - Fetch a single member by ID
- useTestimonials - Fetch testimonials based on shortcode attributes
- useTestimonial - Fetch a single testimonial by ID
- usePosts / usePost - Fetch posts from the static provider (or REST if none is set)
WordPress Shortcodes
The following shortcodes are automatically registered by the wp-custom-api-endpoints plugin:
Member Shortcodes
[member_card id="123"]- Single member profile[member_cards tax="leadership" cols="3" image="true"]- Member grid[member_slideshow category="leadership" interval="5000" show_bio="true"]- Member slideshow
Testimonial Shortcodes
[testimonial_card id="123"]- Single testimonial[testimonial_cards category="external" cols="2"]- Testimonial grid[testimonial_slideshow category="external" interval="5000"]- Testimonial slideshow
Post Shortcodes
Registered by name in wp-custom-api-endpoints (the built-in post type is not part of the CPT loop):
[post_card id="123"]- Single post[post_cards category="news" tag="release" cols="3" limit="6" image="true"]- Post grid.categoryandtagtake a slug or a numeric id.[post_slideshow category="news" interval="5000" show_image="true"]- One post at a time[latest_posts limit="3"]- Alias ofpost_cards
Configuration
Static data is loaded via @marvalt/digivalt-core/static after build-time generation — not live REST from the browser. Include CPT slugs in VITE_ENABLED_POST_TYPES. See docs/ENVIRONMENT.md.
License
GPL-3.0-or-later
