A modern web application exploring classical virtues through interactive storytelling and content. Built with Next.js, powered by BaseHub CMS, and enhanced with beautiful typography and responsive design.
This project implements a dual-content architecture with BaseHub CMS as the primary content source and MDX fallback capabilities:
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ BaseHub CMS โโโโโโ Next.js App โโโโโโ Static Site โ
โ โ โ โ โ โ
โ โข Stories โ โ โข ISR Caching โ โ โข SEO Optimized โ
โ โข Images โ โ โข Type Safety โ โ โข Performance โ
โ โข Rich Content โ โ โข Webhooks โ โ โข Responsive โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
Core Framework:
- Next.js 14 with App Router and TypeScript
- BaseHub CMS for headless content management
- Tailwind CSS with custom design system
Content & Media:
- BaseHub for story content, images, and metadata
- MDX support for rich content authoring
- Next/Image for optimized image delivery
- Audio Player component for story narration
Developer Experience:
- TypeScript with BaseHub's generated types
- shadcn/ui component library
- ESLint and Prettier for code quality
- Vercel deployment with automatic CI/CD
Performance & SEO:
- ISR (Incremental Static Regeneration) caching
- Dynamic sitemap generation
- OpenGraph and Twitter Card meta tags
- JSON-LD structured data
- Vercel Analytics integration
- Node.js 18+ and pnpm
- BaseHub account and project setup
- Vercel account for deployment
-
Clone and install dependencies:
git clone <your-repo> cd classical-virtues pnpm install
-
Environment setup:
cp .env.example .env.local # Add your BaseHub token and webhook secret -
Generate BaseHub types and start development:
pnpm run dev # Runs: basehub dev & next dev
pnpm run dev # Start development server with BaseHub type generation
pnpm run build # Generate types and build for production
pnpm run start # Start production server
pnpm run lint # Run ESLint
pnpm run basehub # Generate BaseHub types onlysrc/
โโโ app/ # Next.js App Router
โ โโโ page.tsx # Home page with story grid
โ โโโ stories/[slug]/ # Dynamic story pages
โ โโโ sitemap.ts # Dynamic sitemap generation
โ โโโ revalidate-sitemap/ # BaseHub webhook endpoint
โโโ components/ # Reusable UI components
โ โโโ ui/ # shadcn/ui components
โ โโโ AudioPlayer.tsx # Story audio narration
โ โโโ summaryCard.tsx # Story preview cards
โโโ lib/ # Core utilities and data layer
โ โโโ basehub.ts # BaseHub API client and types
โ โโโ stories.ts # Unified story data interface
โโโ types/ # TypeScript definitions
BaseHub Schema:
- Stories Collection: Main content with rich text, images, audio
- Generated Types: Full TypeScript safety with auto-generated interfaces
- Draft Mode: Development preview of unpublished content
Data Flow:
BaseHub CMS โ basehub().query() โ Type-safe data โ Next.js pages โ Static site
The project includes automated content revalidation when BaseHub content changes:
-
Configure BaseHub Webhook:
- URL:
https://your-domain.com/revalidate-sitemap - Method:
POST - Enable Svix signature verification
- Secret: Set
BASEHUB_WEBHOOK_SECRETenvironment variable
- URL:
-
Webhook Security:
- Uses Svix HMAC-SHA256 signature verification
- Implements timestamp validation (5-minute window)
- Validates all required headers (
svix-id,svix-timestamp,svix-signature)
-
Revalidation Behavior:
// src/app/revalidate-sitemap/route.ts revalidatePath('/sitemap.xml') # Updates sitemap with new stories revalidatePath('/stories') # Clears story list cache
# Required for BaseHub integration
BASEHUB_TOKEN=bshb_pk_... # BaseHub API token
BASEHUB_WEBHOOK_SECRET=whsec_... # Webhook signature secret
# Optional
NEXT_PUBLIC_VERCEL_URL=... # For absolute URLs in production- Connect repository to Vercel
- Configure environment variables:
BASEHUB_TOKEN=bshb_pk_... BASEHUB_WEBHOOK_SECRET=whsec_...
- Deploy automatically on git push
- ISR Caching: Stories are statically generated with on-demand revalidation
- Image Optimization: BaseHub images are automatically optimized by Next.js
- SEO: Dynamic sitemaps and meta tags are generated from BaseHub content
- Performance: Lazy-loaded audio player and optimized font loading
Implement BaseHub Pump Component:
// Potential implementation in src/app/stories/[slug]/page.tsx
import { Pump } from 'basehub/next-pump'
export default function StoryPage() {
return (
<Pump
queries={[{ stories: { items: { /* fields */ } } }]}
next={{ revalidate: 60 }}
>
{async ([data]) => {
// Real-time content rendering
return <StoryContent story={data.stories.items[0]} />
}}
</Pump>
)
}Benefits:
- Real-time content updates without full page reloads
- Automatic cache management
- Better developer experience for content editing
- Reduced server load with intelligent caching
Option A: Remove Abstraction Layer
// Direct BaseHub usage in components
import { basehub } from 'basehub'
import type { StoriesItem } from '../../../basehub-types'
// Components use BaseHub's native field names (_title, _slug)
function StoryCard({ story }: { story: StoriesItem }) {
return <h2>{story._title}</h2> // Direct BaseHub field access
}Option B: Enhanced Abstraction
// Improved abstraction with better type inference
export const useStories = () => {
return useMemo(() => basehub().query(STORIES_QUERY), [])
}Content Management Enhancements:
- Rich text editor integration for BaseHub
- Image gallery component for multiple story images
- Category/tag system for story organization
- Search functionality with full-text search
- Content scheduling for timed story releases
Performance Optimizations:
- Edge caching strategy with Vercel Edge Functions
- Prefetching for story navigation
- Image placeholder generation
- Progressive Web App features
Developer Experience:
- Storybook integration for component development
- E2E testing with Playwright
- Performance monitoring with Core Web Vitals
- Content validation schemas
Multi-language Support:
// i18n with BaseHub
const { stories } = await basehub().query({
stories: {
__args: { filter: { locale: { eq: 'es' } } }
}
})Advanced Analytics:
- Story reading time tracking
- Popular content analytics
- User engagement metrics
- A/B testing for content presentation
โ Completed Features:
- BaseHub CMS integration with type safety
- Webhook-based content revalidation
- SEO optimization with dynamic sitemaps
- Audio player for story narration
- Responsive design with Tailwind CSS
- Vercel deployment with CI/CD
๐ In Progress:
- Content workflow optimization
- Performance monitoring setup
๐ Planned:
- Pump component integration for real-time updates
- Abstraction layer evaluation and potential simplification
- Enhanced content management features
Core Technologies:
- Next.js Documentation - Framework fundamentals
- BaseHub Documentation - Headless CMS integration
- Tailwind CSS - Utility-first styling
- shadcn/ui - Modern component library
Advanced Concepts:
- BaseHub Pump - Real-time content updates
- Next.js ISR - Caching strategies
- Vercel Analytics - Performance monitoring
MIT