A reusable package of Astro components and utilities for building local service provider websites with automatic updates, smart image handling, and location-based content generation.
Current Version: 1.0.29
- 🚀 Pre-built Components: Hero sections, service grids, contact forms, and more
- 🖼️ Smart Image System: Automatic image matching and optimization
- 📍 Location Pages: Dynamic generation for service areas
- 🎨 Tailwind CSS v4: Modern styling with custom configurations
- 🔄 Automatic Updates: Keep client sites in sync with template improvements
- 📱 Fully Responsive: Mobile-first design approach
- 🔍 SEO Optimized: Built-in meta tags and sitemap generation
Install directly from GitHub repository (no authentication required):
npm install github:mcoster/astro-local-package#mainOr add to your package.json:
{
"dependencies": {
"@mcoster/astro-local-package": "github:mcoster/astro-local-package#main"
}
}- Create a
.npmrcfile in your project root:
@astro-local:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}- Set your GitHub token as an environment variable:
export GITHUB_TOKEN=your_github_personal_access_token- Install the package:
npm install @mcoster/astro-local-package# Clone the client site template
git clone https://github.com/mcoster/astro-local-client-template my-client-site
cd my-client-site
# Install dependencies
npm install
# Configure your business details
cp config/business.example.yaml config/business.yaml
# Edit config/business.yaml with your client's information
# Start development server
npm run devmy-client-site/
├── config/
│ └── business.yaml # Business configuration
├── business-images/ # Client-specific images
│ ├── pending/ # Upload new images here
│ ├── approved/ # Processed images
│ └── stock/ # Downloaded stock photos
├── src/
│ ├── pages/ # Site pages
│ └── content/ # Custom content
├── public/ # Static assets
└── package.json # Dependencies
All template components are available through the package:
---
// In your .astro files
import Layout from '@mcoster/astro-local-package/layouts/Layout.astro';
import Hero from '@mcoster/astro-local-package/components/Hero.astro';
import ServicesGrid from '@mcoster/astro-local-package/components/ServicesGrid.astro';
---
<Layout title="Home">
<Hero />
<ServicesGrid />
</Layout>Layout- Base layout with header/footerPageLayout- Standard page layout
Hero- Hero section with CTAHeroWithForm- Hero with embedded quote formServicesGrid- Service cards gridServiceAreas- Location coverage displayWhyUs- Benefits/features sectionCTABanner- Call-to-action bannerContactInfo- Contact details section
SmartImage- Intelligent image loadingHeader- Site navigationFooter- Site footerContactForm- Contact formQuoteForm- Quote request formServiceCard- Service display cardBreadcrumb- Navigation breadcrumbsSEO- Meta tags component
Configure your client's business details:
business:
name: Your Business Name
logo: /images/logo.png
tagline: Your Business Tagline
phone: (08) 1234 5678
email: info@example.com
address:
street: 123 Main St
city: Adelaide
state: SA
postcode: "5000"
service:
main_category: Your Service
main_location: Adelaide
radius_km: 30
colors:
primary: 1E40AF
secondary: 059669
accent: DC2626
cta: FF6B35
footer:
featured_suburbs:
- Salisbury # Shows single best match by default
- Modbury
- Burleigh # Will match "Burleigh Heads" with improved matching
suburb_selection_mode: best_match # or 'all_variations' to show all matches
suburb_limit: 15 # Optional: limit number of suburbs displayed
auto_supplement: false # Optional: disable auto-adding suburbs (default: true)The footer displays service area suburbs with flexible configuration options:
footer:
featured_suburbs: ["Surfers Paradise", "Broadbeach", "Robina"]
# Selection mode for handling multiple matches
suburb_selection_mode: best_match # Default: 'best_match'
# Options:
# - 'best_match': Shows single best match per suburb name
# - 'all_variations': Shows all matching variations
# Maximum suburbs to display (optional)
suburb_limit: 20 # No default limit
# Auto-supplement with smart selection if fewer than 11 suburbs
auto_supplement: true # Default: true- No radius restriction - Featured suburbs can be outside your service radius
- No forced limits - Display exactly the number of suburbs you specify
- Duplicate prevention - Same suburb won't appear twice
- Better matching - "Burleigh" now correctly matches "Burleigh Heads"
- Flexible display - Show 5, 11, 15, or any number of suburbs
Best Match Mode (default):
featured_suburbs: ["Salisbury"]
suburb_selection_mode: best_match
# Result: Shows only "Salisbury" (or best variant if base doesn't exist)All Variations Mode:
featured_suburbs: ["Salisbury"]
suburb_selection_mode: all_variations
# Result: Shows Salisbury, Salisbury North, Salisbury South, etc.- Default behavior change: Manual suburbs no longer auto-supplement to 11 unless
auto_supplement: true - To restore v1.0.28 behavior: Leave
auto_supplementas default (true) - To disable auto-supplementing: Set
auto_supplement: false
The template includes an intelligent image system:
# Process client images
npm run images:process
# Individual commands
npm run images:manifest # Scan for required images
npm run images:analyze # AI analysis of images
npm run images:match # Match to website sections
npm run images:fetch-stock # Download stock photosPlace client images in business-images/pending/ and run the processing pipeline.
Client sites use Git references to automatically stay up-to-date with the package:
{
"dependencies": {
"@mcoster/astro-local-package": "github:mcoster/astro-local-package#main"
}
}We use Git references instead of versioned packages for several key reasons:
-
Zero Authentication Issues: GitHub Package Registry requires authentication even for public packages. Git references work seamlessly with the default
GITHUB_TOKENin GitHub Actions. -
Truly Hands-Off Updates: Sites automatically get the latest updates when they rebuild on platforms like Netlify, without any manual intervention.
-
No Token Management: No need to create, store, or rotate Personal Access Tokens (PATs) for each new site.
-
Programmatic Simplicity: New sites can be created programmatically without configuring authentication secrets.
The main tradeoff is less granular version control. However, this is mitigated through:
- Careful branch management in the package repository
- Feature branches for development
- Optional use of stable branches for production sites
Use a specific Git tag:
{
"dependencies": {
"@mcoster/astro-local-package": "github:mcoster/astro-local-package#v1.0.13"
}
}Use a feature branch:
{
"dependencies": {
"@mcoster/astro-local-package": "github:mcoster/astro-local-package#feature/new-component"
}
}Create local components that extend template components:
---
// src/components/CustomHero.astro
import Hero from '@mcoster/astro-local-package/components/Hero.astro';
// Add custom props or logic
---
<Hero class="custom-hero">
<slot />
</Hero>
<style>
.custom-hero {
/* Custom styles */
}
</style>Use Tailwind CSS to customize appearance:
/* src/styles/custom.css */
@import '@mcoster/astro-local-package/styles/base.css';
/* Your custom styles */
.hero {
@apply bg-blue-600;
}We use semantic versioning:
- Major (X.0.0): Breaking changes
- Minor (0.X.0): New features, backwards compatible
- Patch (0.0.X): Bug fixes
Configure version acceptance in package.json:
{
"dependencies": {
"@mcoster/astro-local-package": "^1.0.0" // Accept minor and patch updates
}
}- Install the package
- Update import paths in your pages
- Move custom components to local src/
- Update configuration files
- Test thoroughly
Example migration:
---
- import Layout from '../layouts/Layout.astro';
- import Hero from '../components/Hero.astro';
+ import Layout from '@mcoster/astro-local-package/layouts/Layout.astro';
+ import Hero from '@mcoster/astro-local-package/components/Hero.astro';
---import {
loadConfig,
processTemplate,
generateLocations
} from '@mcoster/astro-local-package/utils';
// Load business configuration
const config = await loadConfig();
// Process template with variables
const content = processTemplate(template, variables);
// Generate location pages
const locations = await generateLocations(config);Package not found
- Ensure
.npmrcis configured correctly - Check GitHub token has
read:packagespermission
Components not rendering
- Verify import paths are correct
- Check Astro version compatibility
Images not loading
- Run
npm run images:process - Check image paths in manifest.json
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
See CHANGELOG.md for detailed release notes.
- Fixed featured suburbs: Now correctly fetches ALL specified suburbs, even outside service radius
- Flexible display: No more forced 11 suburb limit - show exactly what you specify
- Improved matching: "Burleigh" now matches "Burleigh Heads" correctly
- Duplicate prevention: Suburbs can't appear twice in the footer
- New configuration options: Control selection mode, limits, and auto-supplementing
- Backward compatible: Default settings maintain v1.0.28 behavior
- Fixed footer duplicate location links issue
- Improved location filtering logic
- Better handling of main location in footer
MIT License - See LICENSE file for details
- GitHub Issues: Report bugs
- Example Implementation: astro-local-template
- Documentation: Full docs
- Email: support@example.com