Enhance public access and error handling in site-related views and loaders

- Updated `DebugScopedRateThrottle` to allow public access for blueprint list requests with site filters.
- Modified `SiteViewSet` and `SiteBlueprintViewSet` to permit public read access for list requests.
- Enhanced `loadSiteDefinition` to resolve site slugs to IDs, improving the loading process for site definitions.
- Improved error handling in `SiteDefinitionView` and `loadSiteDefinition` for better user feedback.
- Adjusted CSS styles for better layout and alignment in shared components.
This commit is contained in:
IGNY8 VPS (Salman)
2025-11-18 22:40:00 +00:00
parent 8ab15d1d79
commit 6c6133a683
14 changed files with 361 additions and 76 deletions

View File

@@ -56,26 +56,31 @@ export function renderLayout(siteDefinition: SiteDefinition): React.ReactElement
* Uses shared DefaultLayout component with fully styled modern design.
*/
function renderDefaultLayout(siteDefinition: SiteDefinition): React.ReactElement {
// Find home page for hero
// Find home page for hero (only show hero on home page or when showing all pages)
const homePage = siteDefinition.pages.find(p => p.slug === 'home');
const heroBlock = homePage?.blocks?.find(b => b.type === 'hero');
const hero: React.ReactNode = heroBlock ? (renderTemplate(heroBlock) as React.ReactNode) : undefined;
// Only show hero if we're on home page or showing all pages
const isHomePage = siteDefinition.pages.length === 1 && siteDefinition.pages[0]?.slug === 'home';
const showHero = isHomePage || (homePage && siteDefinition.pages.length > 1);
const hero: React.ReactNode = (showHero && heroBlock) ? (renderTemplate(heroBlock) as React.ReactNode) : undefined;
// Render all pages as sections (excluding hero from home page if it exists)
const sections = siteDefinition.pages
.filter((page) => page.status !== 'draft')
.filter((page) => page.status !== 'draft' && page.status !== 'generating')
.sort((a, b) => (a.order || 0) - (b.order || 0))
.map((page) => {
// Filter out hero block if it's the home page (already rendered as hero)
const blocksToRender = page.slug === 'home' && heroBlock
const blocksToRender = page.slug === 'home' && heroBlock && showHero
? page.blocks?.filter(b => b.type !== 'hero') || []
: page.blocks || [];
return (
<div key={page.id} className="page" data-page-slug={page.slug}>
{page.slug !== 'home' && <h2>{page.title}</h2>}
<div key={page.id} className="page" data-page-slug={page.slug} style={{ textAlign: 'center' }}>
{page.slug !== 'home' && <h2 style={{ textAlign: 'center', marginBottom: '1.5rem' }}>{page.title}</h2>}
{blocksToRender.length > 0 ? (
blocksToRender.map((block, index) => (
<div key={index} className="block" data-block-type={block.type}>
<div key={index} className="block" data-block-type={block.type} style={{ textAlign: 'center' }}>
{renderTemplate(block)}
</div>
))