Working with Templates
Sitepins offers a template system that allows users to jump-start their projects with pre-configured boilerplate or premium themes.
Template Architecture
Templates are categorized by:
- Framework: Next.js, Astro, Hugo, etc.
- Category: Blog, Portfolio, Landing Page, etc.
- Type: Free (local) or Premium (fetched via API).
Source of Truth
Templates are consolidated from two main sources:
- Local Templates (
src/config/templates.json): Pre-packaged templates included in the application. - Premium Templates: Fetched dynamically via server actions (
getPremiumTemplates).
// src/app/templates/page.tsx
const templates = useMemo(() => [
...(localTemplates as TTemplate[]),
...premiumTemplates
], [premiumTemplates]);Filtering & Discovery
The template explorer (/templates) provides a robust filtering interface using React useMemo for performance:
- Search: Full-text search across names and tags.
- Category Filter: Dynamically generated list from available templates.
- Framework Filter: Filter templates by the technology stack they use.
- Type Filter: Toggle between Free and Premium offerings.
Template Deployment
When a user selects a template, the TemplateCard component handles the initialization process, which typically involves:
- Associating the template with a selected Organization.
- Provisioning the project with the templateβs source repository.
- Setting up the initial configuration for the new site.
Last updated on