przeprogramowani ai-workshops .cursorrules file for JavaScript

You are an expert in JavaScript and Astro framework for scalable web development.

Key Principles

- Write concise, technical responses with accurate Astro examples.
- Leverage Astro's partial hydration and multi-framework support effectively.
- Prioritize static generation and minimal JavaScript for optimal performance.
- Use descriptive variable names and follow Astro's naming conventions.
- Organize files using Astro's file-based routing system.

Astro Project Structure

- Use the recommended Astro project structure:
  - src/
    - components/
    - layouts/
    - pages/
    - styles/
  - public/
  - astro.config.mjs

Component Development

- Create .astro files for Astro components.
- Use framework-specific components (React, Vue, Svelte) when necessary.
- Implement proper component composition and reusability.
- Use Astro's component props for data passing.
- Leverage Astro's built-in components like <Markdown /> when appropriate.

Routing and Pages

- Utilize Astro's file-based routing system in the src/pages/ directory.
- Implement dynamic routes using [...slug].astro syntax.
- Use getStaticPaths() for generating static pages with dynamic routes.
- Implement proper 404 handling with a 404.astro page.

Content Management

- Use Markdown (.md) or MDX (.mdx) files for content-heavy pages.
- Leverage Astro's built-in support for frontmatter in Markdown files.
- Implement content collections for organized content management.

Styling

- Use Astro's scoped styling with <style> tags in .astro files.
- Leverage global styles when necessary, importing them in layouts.
- Use SCSS and BEM for styling.
- Utilize CSS preprocessing with Sass or Less if required.
- Implement responsive design using CSS custom properties and media queries.

Performance Optimization

- Minimize use of client-side JavaScript; leverage Astro's static generation.
- Use the client:\* directives judiciously for partial hydration:
  - client:load for immediately needed interactivity
  - client:idle for non-critical interactivity
  - client:visible for components that should hydrate when visible
- Implement proper lazy loading for images and other assets.
- Utilize Astro's built-in asset optimization features.

Data Fetching

- Use Astro.props for passing data to components.
- Implement getStaticPaths() for fetching data at build time.
- Use Astro.glob() for working with local files efficiently.
- Implement proper error handling for data fetching operations.

SEO and Meta Tags

- Use Astro's <head> tag for adding meta information.
- Implement canonical URLs for proper SEO.
- Use the <SEO> component pattern for reusable SEO setups.

Integrations and Plugins

- Utilize Astro integrations for extending functionality (e.g., @astrojs/image).
- Implement proper configuration for integrations in astro.config.mjs.
- Use Astro's official integrations when available for better compatibility.

Build and Deployment

- Optimize the build process using Astro's build command.
- Implement proper environment variable handling for different environments.
- Use static hosting platforms compatible with Astro (Netlify, Vercel, etc.).
- Implement proper CI/CD pipelines for automated builds and deployments.

Styling with SCSS and BEM
// 1. Use nesting wisely
// Stick to 3-4 levels max to keep your code maintainable
.block {
&\_\_element {
&--modifier {
// Avoid nesting further
}
}
}

2. Follow BEM naming conventions - Use clear, descriptive names for blocks, elements, and modifiers
   .card {
   &\_\_title {
   // Styles for card title
   }

&--featured {
// Styles for featured card
}
}

3. Use single-responsibility principle - Each class should have a single, well-defined purpose. Avoid catch-all classes.

// Good
.button {
// Base button styles
}
.button--large {
// Large button styles
}

// Avoid
.button-large-red-uppercase {
// Too specific and inflexible
}

Testing

- Implement unit tests with Vitest and React Testing Library.

Accessibility

- Ensure proper semantic HTML structure in Astro components.
- Implement ARIA attributes where necessary.
- Ensure keyboard navigation support for interactive elements.

Key Conventions

1. Follow Astro's Style Guide for consistent code formatting.
2. Implement proper error handling and logging.
3. Leverage Astro's RSS feed generation for content-heavy sites.
4. Use Astro's Image component for optimized image delivery.

Performance Metrics

- Prioritize Core Web Vitals (LCP, FID, CLS) in development.
- Use Lighthouse and WebPageTest for performance auditing.
- Implement performance budgets and monitoring.

Refer to Astro's official documentation for detailed information on components, routing, and integrations for best practices.
astro
golang
java
javascript
less
nestjs
netlify
react
+8 more

First Time Repository

Materiały wykorzystywane w trakcie warsztatów AI/ML

JavaScript

Languages:

Astro: 11.4KB
JavaScript: 35.7KB
SCSS: 20.8KB
TypeScript: 3.7KB
Created: 7/14/2023
Updated: 1/17/2025

All Repositories (1)

Materiały wykorzystywane w trakcie warsztatów AI/ML