Skip to content

Commit

Permalink
feat: Updated src/app/secondary-components/publica
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 9, 2024
1 parent 3317f59 commit 1055321
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Publication } from 'src/app/models/publication.model';
import { ApiService } from 'src/app/services/api.service';

Expand All @@ -14,7 +15,8 @@ export class PublicationsComponent implements OnInit {
scholarImage: string;

constructor(
private apiService: ApiService
private apiService: ApiService,
private activatedRoute: ActivatedRoute
) { }

async ngOnInit(): Promise<void> {
Expand Down Expand Up @@ -58,6 +60,29 @@ export class PublicationsComponent implements OnInit {

sanitizeHTML(html: string): string {
const doc = new DOMParser().parseFromString(html, 'text/html');
}

filterPublications(): void {
this.activatedRoute.queryParams.subscribe(params => {
const searchQuery = params['search']?.toLowerCase();
if (!searchQuery) return;

this.blogPublications = this.blogPublications.filter(publication =>
publication.title.toLowerCase().includes(searchQuery) ||
publication.categories.some(category => category.toLowerCase().includes(searchQuery))
);

this.sciPublications = this.sciPublications.filter(publication =>
publication.title.toLowerCase().includes(searchQuery) ||
publication.categories.some(category => category.toLowerCase().includes(searchQuery))
);
});
}
setTimeout(() => {
this.loading = true;
}, 600);

this.filterPublications();
return doc.body.textContent || '';
}
}

0 comments on commit 1055321

Please sign in to comment.