diff --git a/public/assets/ogimg.png b/public/assets/ogimg.png index a0fb484..b0b41a7 100644 Binary files a/public/assets/ogimg.png and b/public/assets/ogimg.png differ diff --git a/scripts/prerender-meta.js b/scripts/prerender-meta.js index d9e03ad..e0f9128 100755 --- a/scripts/prerender-meta.js +++ b/scripts/prerender-meta.js @@ -31,15 +31,6 @@ const staticMeta = { url: 'https://itzminey.dev/socials', color: '#eb284c' }, - /* - '/services': { - title: 'Services | itzMiney', - description: 'All the Services I offer are listed here!', - image: 'https://meta.itzminey.dev/assets/ogimg.png', - url: 'https://itzminey.dev/services', - color: '#eb284c' - }, - */ '/blog': { title: 'Blog | itzMiney', description: 'Welcome to my blog! I\'ll post occasional updates here on the stuff I\'m currently up to.', @@ -68,15 +59,6 @@ const staticMeta = { url: 'https://itzminey.dev/404', color: '#eb284c', }, - /* - '/tos': { - title: 'Terms of Service | itzMiney', - description: 'My Terms of Service for the Freelancing work I provide', - image: 'https://meta.itzminey.dev/assets/ogimg.png', - url: 'https://itzminey.dev/tos', - color: '#eb284c' - }, - */ '/privacy': { title: 'Privacy Policy | itzMiney', description: 'My Privacy Policy for the data collected on this site', @@ -90,16 +72,7 @@ const staticMeta = { image: 'https://meta.itzminey.dev/assets/ogimg.png', url: 'https://itzminey.dev/imprint', color: '#eb284c' - }, - /* - '/shortener': { - title: 'Shortener | itzMiney', - description: 'URL Shortener', - image: 'https://meta.itzminey.dev/assets/ogimg.png', - url: 'https://itzminey.dev/shortener', - color: '#eb284c' } - */ }; // Output directory for pre-rendered metadata diff --git a/src/app/admin/admin.component.css b/src/app/admin/admin.component.css index 76c9dee..ce42537 100644 --- a/src/app/admin/admin.component.css +++ b/src/app/admin/admin.component.css @@ -113,6 +113,16 @@ form { width: 100%; } +#thumbUrl { + margin: 0 0 0 15px; +} + +.action-bar.mobile #thumbUrl { + width: 100%; + margin: 0; + box-sizing: border-box; +} + #submitBtn, #modeSel { display: flex; diff --git a/src/app/admin/admin.component.html b/src/app/admin/admin.component.html index 8cce45c..47e2220 100644 --- a/src/app/admin/admin.component.html +++ b/src/app/admin/admin.component.html @@ -29,6 +29,14 @@ [required]="articleMode === 'create'" [disabled]="articleMode === 'delete' || (articleMode === 'edit' && !editArticleLoaded)" /> +
{ alert('Article created successfully.'); this.articleIdValue = null; @@ -137,7 +145,7 @@ export class AdminComponent implements OnInit, OnDestroy { }); } - editArticle(articleId: number, title?: string, content?: string): void { + editArticle(articleId: number, title?: string, content?: string, thumb_url?: string ): void { if (!articleId || isNaN(Number(articleId))) { alert('Invalid input. Please enter a valid article ID.'); return; @@ -156,12 +164,15 @@ export class AdminComponent implements OnInit, OnDestroy { const titleChanged = updatedTitle !== this.originalTitle; const contentChanged = updatedContent !== this.originalContent; - if (!titleChanged && !contentChanged) { + const updatedThumbUrl = thumb_url?.trim() ?? ''; + const thumbUrlChanged = updatedThumbUrl !== this.originalThumbUrl; + + if (!titleChanged && !contentChanged && !thumbUrlChanged) { alert('No changes detected.'); return; } - const updates: { title?: string; content?: string } = {}; + const updates: { title?: string; content?: string, thumb_url?: string | null } = {}; if (titleChanged) { updates.title = updatedTitle; @@ -171,6 +182,10 @@ export class AdminComponent implements OnInit, OnDestroy { updates.content = updatedContent; } + if (thumbUrlChanged) { + updates.thumb_url = updatedThumbUrl || null; + } + this.authService.validateToken().subscribe({ next: (valid) => { if (!valid) return; @@ -192,6 +207,11 @@ export class AdminComponent implements OnInit, OnDestroy { this.content = updatedContent; } + if (thumbUrlChanged) { + this.originalThumbUrl = updatedThumbUrl; + this.thumb_url = updatedThumbUrl; + } + this.loadedArticle = { ...this.loadedArticle, ...response @@ -258,6 +278,9 @@ export class AdminComponent implements OnInit, OnDestroy { this.title = this.originalTitle; this.content = this.originalContent; + this.originalThumbUrl = article.thumb_url ?? ''; + this.thumb_url = this.originalThumbUrl; + this.editArticleLoaded = true; this.loadingEditArticle = false; this.articleNotFound = false; @@ -483,8 +506,10 @@ export class AdminComponent implements OnInit, OnDestroy { this.articleNotFound = false; this.originalTitle = ''; this.originalContent = ''; + this.originalThumbUrl = ''; this.title = ''; this.content = ''; + this.thumb_url = ''; } markArticleNotFound(): void { @@ -523,10 +548,12 @@ export class AdminComponent implements OnInit, OnDestroy { this.loadedArticle = article; this.originalTitle = article.title ?? ''; this.originalContent = article.content ?? ''; + this.originalThumbUrl = article.thumb_url ?? ''; if (this.articleMode === 'edit') { this.title = this.originalTitle; this.content = this.originalContent; + this.thumb_url = this.originalThumbUrl; this.editArticleLoaded = true; } }, @@ -539,7 +566,11 @@ export class AdminComponent implements OnInit, OnDestroy { } get hasArticleChanges(): boolean { - return this.title !== this.originalTitle || this.content !== this.originalContent; + return ( + this.title !== this.originalTitle || + this.content !== this.originalContent || + this.thumb_url !== this.originalThumbUrl + ); } isArticleSubmitDisabled(): boolean { @@ -564,9 +595,9 @@ export class AdminComponent implements OnInit, OnDestroy { submitArticle() { if (this.articleMode === 'create') { - this.createArticle(this.title, this.content); + this.createArticle(this.title, this.content, this.thumb_url); } else if (this.articleMode === 'edit') { - this.editArticle(Number(this.articleIdValue), this.title, this.content); + this.editArticle(Number(this.articleIdValue), this.title, this.content, this.thumb_url); } else if (this.articleMode === 'delete') { this.deleteArticle(Number(this.articleIdValue)); } diff --git a/src/app/blog/article-page/article-page.component.css b/src/app/blog/article-page/article-page.component.css index 38f375f..caaf22e 100644 --- a/src/app/blog/article-page/article-page.component.css +++ b/src/app/blog/article-page/article-page.component.css @@ -24,6 +24,7 @@ } h1 { + position: relative; font-size: 2.5rem; background: linear-gradient(to top, #a0eddb 0%, #ffffff 100%); -webkit-background-clip: text; @@ -32,6 +33,7 @@ h1 { margin-top: 120px; margin-bottom: 40px; font-weight: 600; + z-index: 10; } .article-content { @@ -51,6 +53,39 @@ h1 { line-height: 1.2; } +.article-thumb { + width: 70%; + aspect-ratio: 2.5 / 1; + object-fit: cover; + border-radius: 25px 25px 0 0; + margin: 67px auto -200px auto; + z-index: -100; + + -webkit-mask-image: linear-gradient( + to bottom, + black 0%, + rgba(0, 0, 0, 0.95) 50%, + rgba(0, 0, 0, 0.7) 70%, + rgba(0, 0, 0, 0.3) 85%, + transparent 100% + ); + mask-image: linear-gradient( + to bottom, + black 0%, + rgba(0, 0, 0, 0.95) 50%, + rgba(0, 0, 0, 0.7) 70%, + rgba(0, 0, 0, 0.3) 85%, + transparent 100% + ); + + filter: brightness(0.9); +} + +.article-thumb.narrow { + width: 100%; + margin: 50px auto -160px auto; +} + .article-meta { font-size: 1rem; color: #D6DAEFBD; diff --git a/src/app/blog/article-page/article-page.component.html b/src/app/blog/article-page/article-page.component.html index 7bc9e16..d81ef14 100644 --- a/src/app/blog/article-page/article-page.component.html +++ b/src/app/blog/article-page/article-page.component.html @@ -15,6 +15,13 @@
+

{{ article.title }}

@for (article of articles.slice(); track article) { -
-

{{ (article.title | slice:0:45) + (article.title.length > 40 ? '...' : '')}}

-

{{ truncateContent(article.content, 80) }}

-

By {{ article.authorName }} | {{ article.createdAt | date: 'dd/MM/yy, HH:mm' }}

+
+ +
+

{{ (article.title | slice:0:45) + (article.title.length > 40 ? '...' : '')}}

+

{{ truncateContent(article.content, 80) }}

+

By {{ article.authorName }} | {{ article.createdAt | date: 'dd/MM/yy, HH:mm' }}

+
}
diff --git a/src/app/blog/blog.component.ts b/src/app/blog/blog.component.ts index 3645214..e950546 100644 --- a/src/app/blog/blog.component.ts +++ b/src/app/blog/blog.component.ts @@ -1,6 +1,6 @@ import {Component, OnInit} from '@angular/core'; import {ViewportService} from '../shared/services/viewport.service' -import { DatePipe, AsyncPipe, SlicePipe, NgStyle } from '@angular/common'; +import {DatePipe, AsyncPipe, SlicePipe, NgStyle, NgClass} from '@angular/common'; import { ArticleService } from '../shared/services/article.service'; import { Router } from '@angular/router'; import {Observable} from 'rxjs'; @@ -16,7 +16,8 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component'; SlicePipe, NgStyle, TranslatePipe, - ParallaxComponent + ParallaxComponent, + NgClass ], templateUrl: './blog.component.html', styleUrl: './blog.component.css' @@ -24,6 +25,8 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component'; export class BlogComponent implements OnInit { articles$: Observable | undefined; isNarrow: boolean = false; + readonly defaultThumbUrl = '/assets/ogimg.png'; + constructor( private deviceService: ViewportService, private articleService: ArticleService, @@ -37,6 +40,14 @@ export class BlogComponent implements OnInit { this.articles$ = this.articleService.getAllArticles(); } + onThumbError(event: Event): void { + const img = event.target as HTMLImageElement; + + if (img.src.endsWith(this.defaultThumbUrl)) return; + + img.src = this.defaultThumbUrl; + } + navigateToArticle(slug: string): void { this.router.navigate([`/blog/${slug}`]).then( (success) => { diff --git a/src/app/shared/services/article.service.ts b/src/app/shared/services/article.service.ts index a1220ca..6b7499a 100644 --- a/src/app/shared/services/article.service.ts +++ b/src/app/shared/services/article.service.ts @@ -8,6 +8,7 @@ interface Article { title: string; slug: string; content: string; + thumb_url: string | null; createdAt: string; updatedAt: string; views: number; @@ -46,10 +47,16 @@ export class ArticleService { ); } - postArticle(token: string, title: string, content: string ): Observable { + postArticle( + token: string, + title: string, + content: string , + thumb_url?: string | null + ): Observable { return this.http.post(this.apiUrl, { title, - content + content, + thumb_url: thumb_url?.trim() || null, },{ headers: { 'Authorization': `Bearer ${token}` @@ -70,7 +77,7 @@ export class ArticleService { editArticle( id: number, token: string | null, - updates: { title?: string; content?: string } + updates: { title?: string; content?: string, thumb_url?: string | null } ): Observable { const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`); return this.http.put(`${this.apiUrl}/${id}`, updates, { headers });