تحسين محركات البحث (SEO)
Dynamic Meta Data Updates in Angular with Router Integration | الديناميكي
المرجع:
make Assuming your component has access to router
constructor(private breakpointObserver: BreakpointObserver,
private popupAdsService: PopupAdsService,
private router: Router,
private titleService: TitleService,
private metaService: MetaService,
public translateService: TranslateService) { }
ngOnInit() {
const data:any = this.router.config.find(a=>{return a.path === 'home'}); // Assuming your component has access to router
if (data) {
this.titleService.setTitle(data.data.title);
this.metaService.updateTags({ name: 'description', content: data.data.description });
// Update other meta tags as needed
}
this.popupAdsService.getCurrentPin().subscribe((data: any) => {
this.popupPin = data;
});
setTimeout(() => { this.visible = true }, 2000);
}
}
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { WishlistComponent } from './components/wishlist/wishlist.component';
import { AboutUsComponent } from './pages/about-us/about-us.component';
import { HomeComponent } from './pages/home/home.component';
import { JobsComponent } from './pages/jobs/jobs.component';
import { MediaCenterComponent } from './pages/media-center/media-center.component';
import { OffersComponent } from './pages/offers/offers.component';
import { StoreLocatorComponent } from './pages/store-locator/store-locator.component';
import { RequestEmployeeComponent } from './pages/request-employee/request-employee.component';
import { PrivatePolicyComponent } from './pages/private-policy/private-policy.component';
import { RewardsComponent } from './pages/rewards/rewards.component';
import { CustomerCareComponent } from './pages/customer-care/customer-care.component';
import { InquiriesSuggestionsComponent } from './pages/inquiries-suggestions/inquiries-suggestions.component';
import { GreetingCardsComponent } from './pages/greeting-cards/greeting-cards.component';
import { RequestAssetComponent } from './pages/request-asset/request-asset.component';
import { MaintenanceTicketsComponent } from './pages/maintenance-tickets/maintenance-tickets.component';
import { TermsAndConditionsDialogComponent } from './popups/terms-and-conditions-dialog/terms-and-conditions-dialog.component';
import { ViewMediaCenterComponent } from './pages/media-center/view-media-center/view-media-center.component';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent, data: { title: 'الصفحة الرئيسية | Home', description: '' } },
{ path: 'about-us', component: AboutUsComponent, data: { title: 'حولنا | About Us', description: '' } },
{ path: 'store-locator', component: StoreLocatorComponent, data: { title: 'الفروع | Branches', description: '' } },
{ path: 'media-center', component: MediaCenterComponent, data: { title: 'المركز الإعلامي | Media Center', description: '' } },
{ path: 'media-center/:id', component: ViewMediaCenterComponent },
{ path: 'offers', component: OffersComponent, data: { title: 'العروض | Offers', description: '' } },
{ path: 'jobs', component: JobsComponent, data: { title: 'التوظيف | Jobs', description: '' } },
{ path: 'wishlist', component: WishlistComponent, data: { title: 'قائمة الرغبات | Wishlist', description: '' } },
{ path: 'request-employee', component: RequestEmployeeComponent, data: { title: 'الاستعلام عن موظف | Request Employee', description: '' } },
{ path: 'request-asset', component: RequestAssetComponent, data: { title: 'الاستعلام عن أصل | Request Asset', description: '' } },
{ path: 'private-policy', component: PrivatePolicyComponent, data: { title: 'الاستعلام عن موظف | Request Employee', description: 'سياسة الخصوصية | Private Policy' } },
{ path: 'rewards', component: RewardsComponent, data: { title: 'نقاط اليحيى | Alyahya Rewards', description: '' } },
{ path: 'rewards-conditions', component: TermsAndConditionsDialogComponent, data: { title: 'شروط نقاط اليحيى | Y Rewards Conditions', description: '' } },
{ path: 'customer-care', component: CustomerCareComponent, data: { title: 'خدمة العملاء | Customer Care', description: '' } },
{ path: 'suggestions', component: InquiriesSuggestionsComponent, data: { title: 'تقديم شكوى أو مقترح | Complaints & Suggestions', description: '' } },
{ path: 'greeding-card', component: GreetingCardsComponent, data: { title: 'بطاقات التهنئة | Greeding Cards', description: '' } },
{ path: 'greeding-cards', component: GreetingCardsComponent, data: { title: 'بطاقات التهنئة | Greeding Cards', description: '' } },
{ path: 'maintenance_tickets', component: MaintenanceTicketsComponent, data: { title: 'تذاكر الصيانة | Maintenance Tickets', description: '' } },
{ path: '**', redirectTo: '/home' },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
<!-- البحث العام -->
<meta name="title" content="أسواق ومخابز اليحيى للمواد الغذائية">
<meta name="author" content="م. عبدالله السالم">
<meta name="url" content="https://al-yahya.sa">
<meta name="domain" content="al-yahya.sa">
<meta name="type" content="website">
<meta name="description" content="نقدم لكم أفضل المنتجات بأفضل الأسعار - أسواق ومخابز اليحيى">
<meta name="keywords"
content="أسواق اليحيى, مخابز اليحيى, بوابة اليحيى, Al Yahya Foodstuff Supermarkets, Al Yahya Foodstuff, Al Yahya,Yahya Foodstuff Supermarkets,أسواق اليحيى للمواد الغذائية,اليحيى,يحيى للمواد الغذائية, مخابز يحيى">
<meta name="image" content="https://al-yahya.sa/assets/img/logos/circle_logo.png">
<!-- بحث وسائل التواصل -->
<meta name="og:title" content="أسواق ومخابز اليحيى للمواد الغذائية">
<meta name="og:url" content="https://al-yahya.sa">
<meta name="og:type" content="website">
<meta name="og:description" content="نقدم لكم أفضل المنتجات بأفضل الأسعار - أسواق ومخابز اليحيى">
<meta name="og:image" content="https://al-yahya.sa/assets/img/logos/circle_logo.png">
<!-- بحث منصة X -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="أسواق ومخابز اليحيى للمواد الغذائية">
<meta name="twitter:url" content="https://al-yahya.sa">
<meta name="twitter:domain" content="al-yahya.sa">
<meta name="twitter:description" content="نقدم لكم أفضل المنتجات بأفضل الأسعار - أسواق ومخابز اليحيى">
<meta name="twitter:image" content="https://al-yahya.sa/assets/img/logos/circle_logo.png">
تعليقات
إرسال تعليق