Added blog functionality, reworked backend api requests
This commit is contained in:
1 parent
a4b69c5b9a
commit
dae95810f2
16 files changed
+696
-171
No files matched your search
@@ -28,30 +28,35 @@
|
||||
z-index: 10; /* Ensure the text and button are above the canvas */
|
||||
}
|
||||
|
||||
.error-message h2 {
|
||||
font-size: 10rem;
|
||||
margin: 0;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
.blog-container {
|
||||
max-width: 900px;
|
||||
margin-top: 120px;
|
||||
margin-bottom: 80px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.error-message p {
|
||||
font-size: 1.5rem;
|
||||
margin: 20px 0;
|
||||
font-weight: 400;
|
||||
color: white;
|
||||
.article-card {
|
||||
z-index: 10;
|
||||
background: linear-gradient(135deg, #9c27b0, #6200ea);
|
||||
padding: 15px;
|
||||
margin: 25px 0;
|
||||
cursor: pointer;
|
||||
border-radius: 45px;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
transition: background-color 0.3s, transform 0.2s;
|
||||
}
|
||||
|
||||
.error-message-mobile h2 {
|
||||
font-size: 4.0rem;
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
color: white;
|
||||
.article-card:hover {
|
||||
background: linear-gradient(135deg, #b737cd, #773ec6);
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.error-message-mobile p {
|
||||
font-size: 1.2rem;
|
||||
margin: 10px 0;
|
||||
font-weight: 400;
|
||||
color: white;
|
||||
h2 {
|
||||
font-size: 1.6rem;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1rem;
|
||||
color: #dcdcdc;
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
<div id="vanta-blog-bg"></div>
|
||||
<div class="height-container">
|
||||
<ng-container *ngIf="!isMobile; else mobileError">
|
||||
<div class="error-message">
|
||||
<h2>Soon™</h2>
|
||||
<p>Under Construction!</p>
|
||||
<div class="blog-container">
|
||||
<div *ngIf="articles$ | async as articles; else noArticles">
|
||||
<div *ngFor="let article of articles" (click)="navigateToArticle(article.slug)" class="article-card">
|
||||
<h2>{{ (article.title | slice:0:45) + (article.title.length > 40 ? '...' : '')}}</h2>
|
||||
<p>{{ (article.content | slice:0:80) + (article.content.length > 80 ? '...' : '')}}</p>
|
||||
<p><small>By {{ article.authorName }} | {{ article.createdAt | date: 'short' }}</small></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-template #mobileError>
|
||||
<div class="error-message-mobile">
|
||||
<h2>Soon™</h2>
|
||||
<p>Under Construction!</p>
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #noArticles>
|
||||
<h2>No Articles yet!</h2>
|
||||
</ng-template>
|
||||
</div>
|
||||
@@ -1,31 +1,45 @@
|
||||
import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core';
|
||||
import {DeviceDetectorService} from '../services/device-detector.service'
|
||||
import {isPlatformBrowser, NgIf} from '@angular/common';
|
||||
import {DatePipe, isPlatformBrowser, NgIf, NgFor, AsyncPipe, SlicePipe} from '@angular/common';
|
||||
import {VantaBackgroundService} from '../services/vanta-background.service';
|
||||
import { ArticleService } from '../services/article.service';
|
||||
import { Router } from '@angular/router';
|
||||
import {Observable} from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-blog',
|
||||
imports: [
|
||||
NgIf
|
||||
NgIf,
|
||||
NgFor,
|
||||
DatePipe,
|
||||
AsyncPipe,
|
||||
SlicePipe
|
||||
],
|
||||
templateUrl: './blog.component.html',
|
||||
styleUrl: './blog.component.css'
|
||||
})
|
||||
export class BlogComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
articles$: Observable<any[]> | undefined;
|
||||
private readonly elementId = 'vanta-blog-bg';
|
||||
isMobile: boolean = false;
|
||||
constructor(
|
||||
private deviceService: DeviceDetectorService,
|
||||
private vantaService: VantaBackgroundService,
|
||||
private articleService: ArticleService,
|
||||
private router: Router,
|
||||
@Inject(PLATFORM_ID) private platformId: Object
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.isMobile = this.deviceService.isMobile;
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
window.addEventListener('resize', this.onResize.bind(this));
|
||||
}
|
||||
this.articles$ = this.articleService.getAllArticles();
|
||||
}
|
||||
|
||||
navigateToArticle(slug: string): void {
|
||||
this.router.navigate([`/blog/${slug}`]);
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
|
||||
Reference in new issue
Block a user