Viet Tran a38d04c3d5
feat(search): overhaul relevance and curated design data
Overhaul BM25 relevance, reasoning and data-quality contracts; refresh UI styles and framework guidance; add resilient text, chip, badge and micro-interaction guidance; strengthen release, provenance and catalog refresh gates; update bilingual documentation.
2026-08-14 00:08:23 +07:00

14 KiB

1NoCategoryGuidelineDescriptionDoDon'tCode GoodCode BadSeverityDocs URLApplies ToStatusVerified At
21ArchitectureUse Islands ArchitectureAstro's partial hydration only loads JS for interactive componentsInteractive components with client directivesHydrate entire page like traditional SPA<Counter client:load />Everything as client componentHighhttps://docs.astro.build/en/concepts/islands/astro 7.1.6active2026-08-13
32ArchitectureDefault to zero JSAstro ships zero JS by default - add only when neededStatic components without client directiveAdd client:load to everything<Header /> (static)<Header client:load /> (unnecessary)Highhttps://docs.astro.build/en/basics/astro-components/astro 7.1.6active2026-08-13
43ArchitectureChoose right client directiveDifferent directives for different hydration timingclient:visible for below-fold client:idle for non-criticalclient:load for everything<Comments client:visible /><Comments client:load />Mediumhttps://docs.astro.build/en/reference/directives-reference/#client-directivesastro 7.1.6active2026-08-13
54ArchitectureUse content collectionsType-safe content management for blogs docsContent collections for structured contentLoose markdown files without schemaconst posts = await getCollection('blog')import.meta.glob('./posts/*.md')Highhttps://docs.astro.build/en/guides/content-collections/astro 7.1.6active2026-08-13
65ArchitectureDefine collection schemasZod schemas for content validationSchema with required fields and typesNo schema validationdefineCollection({ schema: z.object({...}) })defineCollection({})Highhttps://docs.astro.build/en/guides/content-collections/#defining-a-collection-schemaastro 7.1.6active2026-08-13
76RoutingUse file-based routingCreate routes by adding .astro files in pages/pages/ directory for routesManual route configurationsrc/pages/about.astroCustom router setupMediumhttps://docs.astro.build/en/basics/astro-pages/astro 7.1.6active2026-08-13
87RoutingDynamic routes with bracketsUse [param] for dynamic routesBracket notation for paramsQuery strings for dynamic contentpages/blog/[slug].astropages/blog.astro?slug=xMediumhttps://docs.astro.build/en/guides/routing/#dynamic-routesastro 7.1.6active2026-08-13
98RoutingUse getStaticPaths for SSGGenerate static pages at build timegetStaticPaths for known dynamic routesFetch at runtime for static contentexport async function getStaticPaths() { return [...] }No getStaticPaths with dynamic routeHighhttps://docs.astro.build/en/reference/api-reference/#getstaticpathsastro 7.1.6active2026-08-13
109RoutingEnable on-demand rendering when neededRender only dynamic routes on demand or choose server output for a mostly dynamic siteexport const prerender = false on selected routesUse removed output: 'hybrid'export const prerender = false;output: 'hybrid'Mediumhttps://docs.astro.build/en/guides/on-demand-rendering/astro 7.1.6active2026-08-13
1110ComponentsKeep .astro for staticUse .astro components for static contentAstro components for layout structureReact/Vue for static markup<Layout><slot /></Layout><ReactLayout>{children}</ReactLayout>Highhttps://docs.astro.build/en/basics/astro-components/astro 7.1.6active2026-08-13
1211ComponentsUse framework components for interactivityReact Vue Svelte for complex interactivityFramework component with client directiveAstro component with inline scripts<ReactCounter client:load /><script> in .astro for complex stateMediumhttps://docs.astro.build/en/guides/framework-components/astro 7.1.6active2026-08-13
1312ComponentsPass data via propsAstro components receive props in frontmatterAstro.props for component dataGlobal state for simple dataconst { title } = Astro.props;Import global storeLowhttps://docs.astro.build/en/basics/astro-components/#component-propsastro 7.1.6active2026-08-13
1413ComponentsUse slots for compositionNamed and default slots for flexible layouts<slot /> for child contentProps for HTML content<slot name="header" /><Component header={<div>...</div>} />Mediumhttps://docs.astro.build/en/basics/astro-components/#slotsastro 7.1.6active2026-08-13
1514ComponentsColocate component stylesScoped styles in component file<style> in same .astro fileSeparate CSS files for component styles<style> .card { } </style>import './Card.css'Lowastro 7.1.6active2026-08-13
1615StylingUse scoped styles by defaultAstro scopes styles to component automatically<style> for component-specific stylesGlobal styles for everything<style> h1 { } </style> (scoped)<style is:global> for everythingMediumhttps://docs.astro.build/en/guides/styling/#scoped-stylesastro 7.1.6active2026-08-13
1716StylingUse is:global sparinglyGlobal styles only when truly neededis:global for base styles or overridesis:global for component styles<style is:global> body { } </style><style is:global> .card { } </style>Mediumastro 7.1.6active2026-08-13
1817StylingIntegrate Tailwind 4 through ViteThe Astro CLI configures Tailwind 4 with the official Vite pluginUse astro add tailwind or configure @tailwindcss/viteAdd the deprecated @astrojs/tailwind integrationnpx astro add tailwind@astrojs/tailwindLowhttps://docs.astro.build/en/guides/styling/#tailwindastro 7.1.6active2026-08-13
1918StylingUse CSS variables for themingDefine tokens in :rootCSS custom properties for themesHardcoded colors everywhere:root { --primary: #3b82f6; }color: #3b82f6; everywhereMediumastro 7.1.6active2026-08-13
2019DataFetch in frontmatterData fetching in component frontmatterTop-level await in frontmatteruseEffect for initial dataconst data = await fetch(url)client-side fetch on mountHighhttps://docs.astro.build/en/guides/data-fetching/astro 7.1.6active2026-08-13
2120DataUse Astro.glob for local filesImport multiple local filesAstro.glob for markdown/data filesManual imports for each fileconst posts = await Astro.glob('./posts/*.md')import post1; import post2;Mediumastro 7.1.6active2026-08-13
2221DataPrefer content collections over globType-safe collections for structured contentgetCollection() for blog/docsAstro.glob for structured contentawait getCollection('blog')await Astro.glob('./blog/*.md')Highhttps://docs.astro.build/en/guides/content-collections/astro 7.1.6active2026-08-13
2322DataUse environment variables correctlyImport.meta.env for env varsPUBLIC_ prefix for client varsExpose secrets to clientimport.meta.env.PUBLIC_API_URLimport.meta.env.SECRET in clientHighhttps://docs.astro.build/en/guides/environment-variables/astro 7.1.6active2026-08-13
2423PerformancePreload critical assetsUse link preload for important resourcesPreload fonts above-fold imagesNo preload hints<link rel="preload" href="font.woff2" as="font">No preload for critical assetsMediumastro 7.1.6active2026-08-13
2524PerformanceOptimize images with astro:assetsBuilt-in image optimization<Image /> component for optimization<img> for local imagesimport { Image } from 'astro:assets';<img src="./image.jpg">Highhttps://docs.astro.build/en/guides/images/astro 7.1.6active2026-08-13
2625PerformanceUse picture for responsive imagesMultiple formats and sizes<Picture /> for art directionSingle image size for all screens<Picture /> with multiple sources<Image /> with single sizeMediumastro 7.1.6active2026-08-13
2726PerformanceLazy load below-fold contentDefer loading non-critical contentloading=lazy for images client:visible for componentsLoad everything immediately<img loading="lazy">No lazy loadingMediumastro 7.1.6active2026-08-13
2827PerformanceMinimize client directivesEach directive adds JS bundleAudit client: usage regularlySprinkle client:load everywhereOnly interactive components hydratedEvery component with client:loadHighhttps://docs.astro.build/en/reference/directives-reference/#client-directivesastro 7.1.6active2026-08-13
2928ViewTransitionsUse ClientRouter for client-side transitionsEnable Astro client-side routing and transition fallbacks with the current component<ClientRouter /> in the shared headUse removed <ViewTransitions />import { ClientRouter } from 'astro:transitions';<ViewTransitions />Mediumhttps://docs.astro.build/en/guides/view-transitions/astro 7.1.6active2026-08-13
3029ViewTransitionsUse transition:nameNamed elements for morphingtransition:name for persistent elementsUnnamed transitions<header transition:name="header"><header> without nameLowastro 7.1.6active2026-08-13
3130ViewTransitionsHandle transition:persistKeep state across navigationstransition:persist for media playersRe-initialize on every navigation<video transition:persist id="player">Video restarts on navigationMediumastro 7.1.6active2026-08-13
3231ViewTransitionsAdd fallback for no-JSGraceful degradationContent works without JSRequire ClientRouter for basic navigationStatic content accessibleBroken without client-side routing JSHighhttps://docs.astro.build/en/guides/view-transitions/astro 7.1.6active2026-08-13
3332SEOUse a shared head componentCentralize title canonical and metadata without assuming a built-in SEO componentReusable project Head component or explicit head tagsNo metadata or an undocumented built-in SEO API<Head title={title} description={description} /><SEO title={title} /> // package not installedHighhttps://docs.astro.build/en/basics/astro-components/astro 7.1.6active2026-08-13
3433SEOGenerate sitemapAutomatic sitemap generation@astrojs/sitemap integrationManual sitemap maintenancenpx astro add sitemapHand-written sitemap.xmlMediumhttps://docs.astro.build/en/guides/integrations-guide/sitemap/astro 7.1.6active2026-08-13
3534SEOAdd RSS feed for contentRSS for blogs and content sites@astrojs/rss for feed generationNo RSS feedrss() helper in pages/rss.xml.jsNo feed for blogLowhttps://docs.astro.build/en/guides/rss/astro 7.1.6active2026-08-13
3635SEOUse canonical URLsPrevent duplicate content issuesAstro.url for canonical generationNo canonical tags<link rel="canonical" href={Astro.url}>No canonical tagsMediumastro 7.1.6active2026-08-13
3736IntegrationsUse official integrationsAstro's integration systemnpx astro add for integrationsManual configurationnpx astro add reactManual React setupMediumhttps://docs.astro.build/en/guides/integrations-guide/astro 7.1.6active2026-08-13
3837IntegrationsConfigure integrations in astro.configCentralized configurationSupported integrations in the integrations arrayScattered configurationintegrations: [react(), sitemap()]Multiple config filesLowastro 7.1.6active2026-08-13
3938IntegrationsUse adapter for deploymentPlatform-specific adaptersCorrect adapter for hostWrong or no adapter@astrojs/vercel for VercelNo adapter for SSRHighhttps://docs.astro.build/en/guides/deploy/astro 7.1.6active2026-08-13
4039TypeScriptEnable TypeScriptType safety for Astro projectstsconfig.json with astro typesNo TypeScriptAstro TypeScript templateJavaScript onlyMediumhttps://docs.astro.build/en/guides/typescript/astro 7.1.6active2026-08-13
4140TypeScriptType component propsDefine prop interfacesProps interface in frontmatterUntyped propsinterface Props { title: string }No props typingMediumastro 7.1.6active2026-08-13
4241TypeScriptUse strict modeCatch errors earlystrict: true in tsconfigLoose TypeScript configstrictest templatebase templateLowastro 7.1.6active2026-08-13
4342MarkdownUse MDX for componentsComponents in markdown content@astrojs/mdx for interactive docsPlain markdown with workarounds<Component /> in .mdxHTML in .md filesMediumhttps://docs.astro.build/en/guides/integrations-guide/mdx/astro 7.1.6active2026-08-13
4443MarkdownConfigure markdown pluginsExtend markdown capabilitiesremarkPlugins rehypePlugins in configManual HTML for featuresremarkPlugins: [remarkToc]Manual TOC in every postLowastro 7.1.6active2026-08-13
4544MarkdownUse frontmatter for metadataStructured post metadataFrontmatter with typed schemaInline metadatatitle date in frontmatter# Title as first lineMediumastro 7.1.6active2026-08-13
4645APIUse API routes for endpointsServer endpoints in pages/apipages/api/[endpoint].ts for APIsExternal API for simple endpointspages/api/posts.json.tsSeparate Express serverMediumhttps://docs.astro.build/en/guides/endpoints/astro 7.1.6active2026-08-13
4746APIReturn proper responsesUse Response objectnew Response() with headersPlain objectsreturn new Response(JSON.stringify(data))return dataMediumastro 7.1.6active2026-08-13
4847APIHandle methods correctlyExport named method handlersexport GET POST handlersSingle default exportexport const GET = async () => {}export default async () => {}Lowastro 7.1.6active2026-08-13
4948SecuritySanitize user contentPrevent XSS in dynamic contentset:html only for trusted or sanitized contentset:html with user input<Fragment set:html={sanitized} /><div set:html={userInput} />Highhttps://docs.astro.build/en/reference/directives-reference/#sethtmlastro 7.1.6active2026-08-13
5049SecurityUse HTTPS in productionDeploy behind a host or proxy that terminates TLSHTTPS for all production sitesHTTP in productionhttps://example.comhttp://example.comHighhttps://docs.astro.build/en/guides/deploy/astro 7.1.6active2026-08-13
5150SecurityValidate API inputCheck and sanitize all inputSchema validation for endpoint inputTrust all inputconst body = schema.parse(data)const body = await request.json()Highhttps://docs.astro.build/en/guides/endpoints/astro 7.1.6active2026-08-13
5251BuildMix prerendered and on-demand routesStatic output supports selected server-rendered routes when an adapter is configuredKeep static output and set prerender false per dynamic routeUse removed output: 'hybrid'export const prerender = falseoutput: 'hybrid'Mediumhttps://docs.astro.build/en/guides/on-demand-rendering/astro 7.1.6active2026-08-13
5352BuildAnalyze bundle sizeMonitor JS bundle impactBuild output shows bundle sizesIgnore bundle growthCheck astro build outputNo size monitoringMediumastro 7.1.6active2026-08-13
5453BuildConfigure built-in prefetchPreload likely next pages with Astro's built-in prefetch configurationSet prefetch true or use data-astro-prefetchInstall the removed prefetch integrationprefetch: truenpx astro add prefetchLowhttps://docs.astro.build/en/guides/prefetch/astro 7.1.6active2026-08-13