Skip to content

docs: add routing best practices prompt rules #62229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kstepien3
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

AI best practices without routing instructions.

What is the new behavior?

Add new section Routing and add best practices there.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Copy link

google-cla bot commented Jun 24, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@pullapprove pullapprove bot requested a review from kirjs June 24, 2025 09:09
@angular-robot angular-robot bot added the area: docs Related to the documentation label Jun 24, 2025
@ngbot ngbot bot added this to the Backlog milestone Jun 24, 2025
@JeanMeche JeanMeche removed the request for review from kirjs June 24, 2025 12:18
@pullapprove pullapprove bot requested a review from kirjs June 24, 2025 12:18
@google-cla google-cla bot added cla: yes and removed cla: no labels Jun 24, 2025
@AndrewKushnir AndrewKushnir requested review from AndrewKushnir and removed request for kirjs June 25, 2025 00:12
@AndrewKushnir
Copy link
Contributor

@kstepien3 thanks for the proposed change. Could you please provide more info/examples on the current (without the prompt) vs new (with the prompt) generated code and which LLM model did you use?

@kstepien3
Copy link
Author

@AndrewKushnir sure

Perplexity search/best - guidelines.md

Unsaved form & dialog on leave

Perplexity - actual
Perplexity - new

ChatGPT - best-practices.md

Refactor this code: https://v17.angular.io/guide/router-tutorial-toh#register-router-and-routes

ChatGPT - actual
ChatGPT - new

@kstepien3
Copy link
Author

Webstorm Claude 4 sonnet - Chat instructions - airules.md (cedebase on)

Suggest base router for new project

Actual


Me

Can you suggest a base router for this project? I would like to include sections for Home, Contact, and About Us.

AI Assistant

I'll help you create a base router configuration for your Angular project with the sections you mentioned. Let me first check the current project structure to understand how it's organized.Perfect! I can see this is an Angular project with routing already set up. Let me check the existing routing configuration and then suggest a complete router setup for your Home, Contact, and About Us sections.Perfect! I can see you have an Angular project with Angular Router already configured. Let me suggest a complete router setup with components for Home, Contact, and About Us pages.

First, let me create the basic components and then set up the routing configuration:

1. Home Component

import { Component } from '@angular/core';

@Component({
  selector: 'app-home',
  standalone: true,
  template: `
    <div class="home-container">
      <h1>Welcome to Our Website</h1>
      <p>This is the home page of our application.</p>
      <div class="hero-section">
        <h2>Get Started</h2>
        <p>Explore our features and discover what we have to offer.</p>
        <button class="cta-button">Learn More</button>
      </div>
    </div>
  `,
  styles: [`
    .home-container {
      padding: 2rem;
      max-width: 1200px;
      margin: 0 auto;
    }
    
    .hero-section {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
      padding: 3rem 2rem;
      border-radius: 8px;
      margin-top: 2rem;
      text-align: center;
    }
    
    .cta-button {
      background: white;
      color: #667eea;
      border: none;
      padding: 0.75rem 1.5rem;
      border-radius: 4px;
      font-weight: bold;
      cursor: pointer;
      margin-top: 1rem;
      transition: transform 0.2s;
    }
    
    .cta-button:hover {
      transform: translateY(-2px);
    }
  `]
})
export class HomeComponent {}

2. About Us Component

import { Component } from '@angular/core';

@Component({
  selector: 'app-about',
  standalone: true,
  template: `
    <div class="about-container">
      <h1>About Us</h1>
      <div class="about-content">
        <section class="mission">
          <h2>Our Mission</h2>
          <p>
            We are dedicated to providing exceptional services and creating
            meaningful experiences for our customers. Our team is passionate
            about innovation and excellence.
          </p>
        </section>
        
        <section class="values">
          <h2>Our Values</h2>
          <ul>
            <li>Innovation and creativity</li>
            <li>Customer satisfaction</li>
            <li>Quality and reliability</li>
            <li>Transparency and integrity</li>
          </ul>
        </section>
        
        <section class="team">
          <h2>Our Team</h2>
          <p>
            Our diverse team of professionals brings together expertise from
            various fields to deliver the best possible solutions for our clients.
          </p>
        </section>
      </div>
    </div>
  `,
  styles: [`
    .about-container {
      padding: 2rem;
      max-width: 1200px;
      margin: 0 auto;
    }
    
    .about-content {
      margin-top: 2rem;
    }
    
    section {
      margin-bottom: 2rem;
      padding: 1.5rem;
      border-left: 4px solid #667eea;
      background: #f8f9fa;
      border-radius: 0 8px 8px 0;
    }
    
    h2 {
      color: #667eea;
      margin-bottom: 1rem;
    }
    
    ul {
      list-style-type: none;
      padding-left: 0;
    }
    
    li {
      padding: 0.5rem 0;
      position: relative;
      padding-left: 1.5rem;
    }
    
    li:before {
      content: "✓";
      color: #667eea;
      font-weight: bold;
      position: absolute;
      left: 0;
    }
  `]
})
export class AboutComponent {}

3. Contact Component

import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

@Component({
  selector: 'app-contact',
  standalone: true,
  imports: [CommonModule, FormsModule],
  template: `
    <div class="contact-container">
      <h1>Contact Us</h1>
      
      <div class="contact-content">
        <div class="contact-info">
          <h2>Get in Touch</h2>
          <div class="info-item">
            <strong>Email:</strong> info@yourcompany.com
          </div>
          <div class="info-item">
            <strong>Phone:</strong> +1 (555) 123-4567
          </div>
          <div class="info-item">
            <strong>Address:</strong> 123 Business Street, City, State 12345
          </div>
        </div>
        
        <div class="contact-form">
          <h2>Send us a Message</h2>
          <form (ngSubmit)="onSubmit()" #contactForm="ngForm">
            <div class="form-group">
              <label for="name">Name</label>
              <input 
                type="text" 
                id="name" 
                name="name" 
                [(ngModel)]="formData.name" 
                required
                #name="ngModel"
              >
              <div *ngIf="name.invalid && name.touched" class="error">
                Name is required
              </div>
            </div>
            
            <div class="form-group">
              <label for="email">Email</label>
              <input 
                type="email" 
                id="email" 
                name="email" 
                [(ngModel)]="formData.email" 
                required
                email
                #email="ngModel"
              >
              <div *ngIf="email.invalid && email.touched" class="error">
                Please enter a valid email
              </div>
            </div>
            
            <div class="form-group">
              <label for="message">Message</label>
              <textarea 
                id="message" 
                name="message" 
                [(ngModel)]="formData.message" 
                required
                rows="5"
                #message="ngModel"
              ></textarea>
              <div *ngIf="message.invalid && message.touched" class="error">
                Message is required
              </div>
            </div>
            
            <button 
              type="submit" 
              [disabled]="contactForm.invalid"
              class="submit-button"
            >
              Send Message
            </button>
          </form>
        </div>
      </div>
    </div>
  `,
  styles: [`
    .contact-container {
      padding: 2rem;
      max-width: 1200px;
      margin: 0 auto;
    }
    
    .contact-content {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 3rem;
      margin-top: 2rem;
    }
    
    .contact-info {
      background: #f8f9fa;
      padding: 2rem;
      border-radius: 8px;
    }
    
    .info-item {
      margin-bottom: 1rem;
      padding: 0.5rem 0;
    }
    
    .contact-form {
      background: white;
      padding: 2rem;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    .form-group {
      margin-bottom: 1.5rem;
    }
    
    label {
      display: block;
      margin-bottom: 0.5rem;
      font-weight: bold;
      color: #333;
    }
    
    input, textarea {
      width: 100%;
      padding: 0.75rem;
      border: 1px solid #ddd;
      border-radius: 4px;
      font-size: 1rem;
      box-sizing: border-box;
    }
    
    input:focus, textarea:focus {
      outline: none;
      border-color: #667eea;
    }
    
    .submit-button {
      background: #667eea;
      color: white;
      border: none;
      padding: 0.75rem 2rem;
      border-radius: 4px;
      font-size: 1rem;
      cursor: pointer;
      transition: background-color 0.3s;
    }
    
    .submit-button:hover:not(:disabled) {
      background: #5a6fd8;
    }
    
    .submit-button:disabled {
      background: #ccc;
      cursor: not-allowed;
    }
    
    .error {
      color: #dc3545;
      font-size: 0.875rem;
      margin-top: 0.25rem;
    }
    
    @media (max-width: 768px) {
      .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
      }
    }
  `]
})
export class ContactComponent {
  formData = {
    name: '',
    email: '',
    message: ''
  };

  onSubmit() {
    if (this.formData.name && this.formData.email && this.formData.message) {
      console.log('Form submitted:', this.formData);
      // Here you would typically send the data to your backend
      alert('Thank you for your message! We will get back to you soon.');
      
      // Reset form
      this.formData = {
        name: '',
        email: '',
        message: ''
      };
    }
  }
}

4. Updated Router Configuration

import { Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { ContactComponent } from './contact/contact.component';

export const routes: Routes = [
  { path: '', redirectTo: '/home', pathMatch: 'full' },
  { path: 'home', component: HomeComponent },
  { path: 'about', component: AboutComponent },
  { path: 'contact', component: ContactComponent },
  { path: '**', redirectTo: '/home' } // Wildcard route for 404 pages
];

5. Updated App Component with Navigation

<nav class="navbar">
  <div class="nav-container">
    <a routerLink="/home" class="nav-brand">Your Company</a>
    <ul class="nav-menu">
      <li class="nav-item">
        <a routerLink="/home" routerLinkActive="active" class="nav-link">Home</a>
      </li>
      <li class="nav-item">
        <a routerLink="/about" routerLinkActive="active" class="nav-link">About Us</a>
      </li>
      <li class="nav-item">
        <a routerLink="/contact" routerLinkActive="active" class="nav-link">Contact</a>
      </li>
    </ul>
  </div>
</nav>

<main class="main-content">
  <router-outlet></router-outlet>
</main>

<footer class="footer">
  <div class="footer-content">
    <p>&copy; 2024 Your Company. All rights reserved.</p>
  </div>
</footer>
import { Component } from '@angular/core';
import { RouterOutlet, RouterLink, RouterLinkActive } from '@angular/router';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet, RouterLink, RouterLinkActive],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent {
  title = 'your-app';
}

6. App Component Styles

.navbar {
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.nav-brand {
  font-size: 1.5rem;
  font-weight: bold;
  color: #667eea;
  text-decoration: none;
  
  &:hover {
    color: #5a6fd8;
  }
}

.nav-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 2rem;
}

.nav-item {
  margin: 0;
}

.nav-link {
  text-decoration: none;
  color: #333;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.3s ease;
  
  &:hover {
    background: #f8f9fa;
    color: #667eea;
  }
  
  &.active {
    background: #667eea;
    color: white;
  }
}

.main-content {
  min-height: calc(100vh - 120px); // Adjust based on navbar and footer height
}

.footer {
  background: #333;
  color: white;
  padding: 2rem 0;
  margin-top: 2rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  padding: 0 2rem;
}

// Responsive design
@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    height: auto;
    padding: 1rem 2rem;
  }
  
  .nav-menu {
    margin-top: 1rem;
    gap: 1rem;
  }
  
  .main-content {
    min-height: calc(100vh - 160px);
  }
}

This router setup provides:

  1. Clean URL structure with routes for /home, /about, and /contact
  2. Responsive navigation with active link highlighting
  3. Standalone components following Angular's latest best practices
  4. Form handling in the contact component with validation
  5. Professional styling with a modern, clean design
  6. Mobile-responsive design that works on all devices
  7. Proper routing configuration with default route and 404 handling

The components are styled with inline styles for simplicity, but you can move these to separate SCSS files if you prefer. The navigation automatically highlights the active page, and the contact form includes proper validation.

@kstepien3
Copy link
Author

Webstorm Claude 4 sonnet - Chat instructions - airules.md (cedebase on)

Suggest base router for new project

New


Me

Can you suggest a base router for this project? I would like to include sections for Home, Contact, and About Us.

AI Assistant

I'll help you create a base router configuration for your Angular project with the sections you mentioned. Let me first explore the project structure to understand the current setup.Perfect! I can see you have an Angular project already set up with routing files. Let me check the current routing configuration and then suggest a complete router setup for your Home, Contact, and About Us sections.I can see your Angular project already has a basic routing setup. Let me suggest a complete router configuration with the sections you requested: Home, Contact, and About Us. I'll provide both the routing configuration and the necessary components.

First, let's update the routing configuration:

import { Routes } from '@angular/router';
import { HomeComponent } from './pages/home/home.component';
import { AboutComponent } from './pages/about/about.component';
import { ContactComponent } from './pages/contact/contact.component';

export const routes: Routes = [
  { path: '', redirectTo: '/home', pathMatch: 'full' },
  { path: 'home', component: HomeComponent },
  { path: 'about', component: AboutComponent },
  { path: 'contact', component: ContactComponent },
  { path: '**', redirectTo: '/home' } // Wildcard route for 404 page
];

Now, let's create the component files for each page:

Home Component:

import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
  selector: 'app-home',
  standalone: true,
  imports: [CommonModule],
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent {
  title = 'Welcome to Our Website';
}
<div class="home-container">
  <h1>{{ title }}</h1>
  <p>This is the home page of our application. Welcome!</p>
  <div class="features">
    <h2>What We Offer</h2>
    <ul>
      <li>Quality services</li>
      <li>Professional support</li>
      <li>Innovative solutions</li>
    </ul>
  </div>
</div>
.home-container {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;

  h1 {
    color: #333;
    text-align: center;
    margin-bottom: 1rem;
  }

  p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
  }

  .features {
    background-color: #f5f5f5;
    padding: 1.5rem;
    border-radius: 8px;

    h2 {
      color: #555;
      margin-bottom: 1rem;
    }

    ul {
      list-style-type: none;
      padding: 0;

      li {
        padding: 0.5rem 0;
        border-bottom: 1px solid #ddd;

        &:last-child {
          border-bottom: none;
        }
      }
    }
  }
}

About Component:

import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
  selector: 'app-about',
  standalone: true,
  imports: [CommonModule],
  templateUrl: './about.component.html',
  styleUrls: ['./about.component.scss']
})
export class AboutComponent {
  companyInfo = {
    name: 'Our Company',
    founded: '2020',
    mission: 'To provide excellent services and innovative solutions to our clients.',
    values: ['Quality', 'Innovation', 'Customer Focus', 'Integrity']
  };
}
<div class="about-container">
  <h1>About {{ companyInfo.name }}</h1>
  
  <section class="company-info">
    <h2>Our Story</h2>
    <p>Founded in {{ companyInfo.founded }}, we have been dedicated to excellence in everything we do.</p>
    <p>{{ companyInfo.mission }}</p>
  </section>

  <section class="values">
    <h2>Our Values</h2>
    <div class="values-grid">
      <div class="value-card" *ngFor="let value of companyInfo.values">
        {{ value }}
      </div>
    </div>
  </section>

  <section class="team">
    <h2>Our Team</h2>
    <p>We are a dedicated team of professionals committed to delivering the best results for our clients.</p>
  </section>
</div>
.about-container {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;

  h1 {
    color: #333;
    text-align: center;
    margin-bottom: 2rem;
  }

  section {
    margin-bottom: 2rem;

    h2 {
      color: #555;
      border-bottom: 2px solid #007bff;
      padding-bottom: 0.5rem;
      margin-bottom: 1rem;
    }

    p {
      line-height: 1.6;
      margin-bottom: 1rem;
    }
  }

  .values-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;

    .value-card {
      background-color: #007bff;
      color: white;
      padding: 1rem;
      border-radius: 8px;
      text-align: center;
      font-weight: bold;
    }
  }
}

Contact Component:

import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';

@Component({
  selector: 'app-contact',
  standalone: true,
  imports: [CommonModule, ReactiveFormsModule],
  templateUrl: './contact.component.html',
  styleUrls: ['./contact.component.scss']
})
export class ContactComponent {
  contactForm: FormGroup;
  submitted = false;

  constructor(private formBuilder: FormBuilder) {
    this.contactForm = this.formBuilder.group({
      name: ['', Validators.required],
      email: ['', [Validators.required, Validators.email]],
      subject: ['', Validators.required],
      message: ['', Validators.required]
    });
  }

  onSubmit() {
    this.submitted = true;
    if (this.contactForm.valid) {
      console.log('Form Submitted:', this.contactForm.value);
      // Here you would typically send the form data to a service
      alert('Thank you for your message! We will get back to you soon.');
      this.contactForm.reset();
      this.submitted = false;
    }
  }

  get f() {
    return this.contactForm.controls;
  }
}
<div class="contact-container">
  <h1>Contact Us</h1>
  
  <div class="contact-info">
    <h2>Get in Touch</h2>
    <p>We'd love to hear from you. Send us a message and we'll respond as soon as possible.</p>
    
    <div class="info-grid">
      <div class="info-item">
        <h3>Email</h3>
        <p>info@ourcompany.com</p>
      </div>
      <div class="info-item">
        <h3>Phone</h3>
        <p>+1 (555) 123-4567</p>
      </div>
      <div class="info-item">
        <h3>Address</h3>
        <p>123 Business St<br>City, State 12345</p>
      </div>
    </div>
  </div>

  <form [formGroup]="contactForm" (ngSubmit)="onSubmit()" class="contact-form">
    <h2>Send us a Message</h2>
    
    <div class="form-group">
      <label for="name">Name *</label>
      <input 
        type="text" 
        id="name" 
        formControlName="name"
        [class.is-invalid]="submitted && f['name'].errors">
      <div *ngIf="submitted && f['name'].errors" class="invalid-feedback">
        Name is required
      </div>
    </div>

    <div class="form-group">
      <label for="email">Email *</label>
      <input 
        type="email" 
        id="email" 
        formControlName="email"
        [class.is-invalid]="submitted && f['email'].errors">
      <div *ngIf="submitted && f['email'].errors" class="invalid-feedback">
        <div *ngIf="f['email'].errors['required']">Email is required</div>
        <div *ngIf="f['email'].errors['email']">Email is invalid</div>
      </div>
    </div>

    <div class="form-group">
      <label for="subject">Subject *</label>
      <input 
        type="text" 
        id="subject" 
        formControlName="subject"
        [class.is-invalid]="submitted && f['subject'].errors">
      <div *ngIf="submitted && f['subject'].errors" class="invalid-feedback">
        Subject is required
      </div>
    </div>

    <div class="form-group">
      <label for="message">Message *</label>
      <textarea 
        id="message" 
        formControlName="message" 
        rows="5"
        [class.is-invalid]="submitted && f['message'].errors"></textarea>
      <div *ngIf="submitted && f['message'].errors" class="invalid-feedback">
        Message is required
      </div>
    </div>

    <button type="submit" class="submit-btn">Send Message</button>
  </form>
</div>
.contact-container {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;

  h1 {
    color: #333;
    text-align: center;
    margin-bottom: 2rem;
  }

  .contact-info {
    margin-bottom: 2rem;

    h2 {
      color: #555;
      margin-bottom: 1rem;
    }

    p {
      line-height: 1.6;
      margin-bottom: 1.5rem;
    }

    .info-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 1.5rem;
      margin-top: 1.5rem;

      .info-item {
        background-color: #f8f9fa;
        padding: 1.5rem;
        border-radius: 8px;
        text-align: center;

        h3 {
          color: #007bff;
          margin-bottom: 0.5rem;
        }

        p {
          margin: 0;
          color: #666;
        }
      }
    }
  }

  .contact-form {
    background-color: #f8f9fa;
    padding: 2rem;
    border-radius: 8px;

    h2 {
      color: #555;
      margin-bottom: 1.5rem;
      text-align: center;
    }

    .form-group {
      margin-bottom: 1.5rem;

      label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: bold;
        color: #555;
      }

      input, textarea {
        width: 100%;
        padding: 0.75rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        font-size: 1rem;
        box-sizing: border-box;

        &:focus {
          outline: none;
          border-color: #007bff;
          box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
        }

        &.is-invalid {
          border-color: #dc3545;
        }
      }

      .invalid-feedback {
        color: #dc3545;
        font-size: 0.875rem;
        margin-top: 0.25rem;
      }
    }

    .submit-btn {
      background-color: #007bff;
      color: white;
      padding: 0.75rem 2rem;
      border: none;
      border-radius: 4px;
      font-size: 1rem;
      cursor: pointer;
      width: 100%;
      transition: background-color 0.3s ease;

      &:hover {
        background-color: #0056b3;
      }

      &:active {
        background-color: #004085;
      }
    }
  }
}

Finally, let's update the main app component to include navigation:

<div class="app-container">
  <nav class="navbar">
    <div class="nav-brand">
      <a routerLink="/home">Your Company</a>
    </div>
    <ul class="nav-menu">
      <li><a routerLink="/home" routerLinkActive="active">Home</a></li>
      <li><a routerLink="/about" routerLinkActive="active">About Us</a></li>
      <li><a routerLink="/contact" routerLinkActive="active">Contact</a></li>
    </ul>
  </nav>
  
  <main class="main-content">
    <router-outlet></router-outlet>
  </main>
  
  <footer class="footer">
    <p>&copy; 2024 Your Company. All rights reserved.</p>
  </footer>
</div>
import { Component } from '@angular/core';
import { RouterOutlet, RouterLink, RouterLinkActive } from '@angular/router';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet, RouterLink, RouterLinkActive],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent {
  title = 'your-app';
}
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  background-color: #343a40;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);

  .nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;

    &:hover {
      color: #007bff;
    }
  }

  .nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 2rem;

    li a {
      color: white;
      text-decoration: none;
      padding: 0.5rem 1rem;
      border-radius: 4px;
      transition: all 0.3s ease;

      &:hover {
        background-color: #495057;
      }

      &.active {
        background-color: #007bff;
      }
    }
  }
}

.main-content {
  flex: 1;
  min-height: calc(100vh - 140px);
}

.footer {
  background-color: #f8f9fa;
  padding: 1rem;
  text-align: center;
  border-top: 1px solid #dee2e6;
  margin-top: auto;

  p {
    margin: 0;
    color: #6c757d;
  }
}

// Responsive design
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    padding: 1rem;

    .nav-menu {
      margin-top: 1rem;
      gap: 1rem;
    }
  }
}

Summary

This router setup provides:

  1. Clean URL structure: /home, /about, /contact
  2. Default routing: Empty path redirects to home
  3. 404 handling: Wildcard route redirects unknown paths to home
  4. Responsive navigation: Mobile-friendly navbar
  5. Active link highlighting: Shows current page in navigation
  6. Standalone components: Uses Angular's modern standalone component approach
  7. Form handling: Contact form with validation
  8. Professional styling: Clean, modern design

To use this setup, you'll need to create the directory structure:

  • src/app/pages/home/
  • src/app/pages/about/
  • src/app/pages/contact/

The routing is already configured in your app.config.ts since Angular Router is included in your dependencies. This setup provides a solid foundation for your website with the three main sections you requested.

@kstepien3
Copy link
Author

I see webstorm has the worst results. Perhaps because the instructions were entered in the settings instead of directly in the chat

@AndrewKushnir AndrewKushnir self-assigned this Jun 25, 2025
@AndrewKushnir AndrewKushnir added the ai Issue related to using AI agents label Jun 25, 2025

## Routing
- Use `provideRouter()` with standalone components instead of RouterModule.forRoot()
- Implement lazy loading using loadComponent for feature routes and standalone components
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would not limit to features routes as a common limitation: depending on the pap, not everyone lands on the 'home/default' page so it should be lazy loaded too. I'd just state to lazy load by default.

- Use functional route guards (`CanActivateFn`, `CanDeactivateFn`) instead of class-based guards
- Configure preloading strategies:
- Use NoPreloading as default (conserves bandwidth)
- Implement custom strategies for critical routes only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd await the 'prompt user' (^^) to explain what's a critical route. In my opinion, we can't rely on the AI to choose if it's critical or not. Because it's not only based on the feature but the target too: some applications are mainly used in a low network situation, where specific strategy will not be related ot the features themselves;

- Structure routes hierarchically with clear parent-child relationships
- Keep your routing configuration clean and maintainable by separating routes into their own files, especially for different features.
- Define wildcard routes (`**`) for 404 handling when needed
- Use route resolvers to pre-fetch critical data before component activation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue about 'critical'. The AI might end up using route resolvers everywhere as seeing related data as required for the component. Using a resolver is a strategy you need to explain, i would not include it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai Issue related to using AI agents area: docs Related to the documentation cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants