Refactored complex custom meta jank to use Angular SSR instead
This commit is contained in:
1 parent
d291409097
commit
febbc63f35
21 files changed
+1659
-636
No files matched your search
@@ -47,7 +47,7 @@ jobs:
|
|||||||
set -eux
|
set -eux
|
||||||
npm run build
|
npm run build
|
||||||
test -d dist/itzmineydev/browser
|
test -d dist/itzmineydev/browser
|
||||||
test -d dist/itzmineydev/meta
|
test -d dist/itzmineydev/server
|
||||||
deploy:
|
deploy:
|
||||||
needs: test-and-build
|
needs: test-and-build
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
@@ -86,9 +86,11 @@ jobs:
|
|||||||
|
|
||||||
rsync -az -e "ssh $SSH_ARGS" ./dist/itzmineydev/ itzmineydev@localhost:"$TARGET_DIR/"
|
rsync -az -e "ssh $SSH_ARGS" ./dist/itzmineydev/ itzmineydev@localhost:"$TARGET_DIR/"
|
||||||
|
|
||||||
ssh $SSH_ARGS itzmineydev@localhost "test -d $TARGET_DIR/browser && test -d $TARGET_DIR/meta"
|
ssh $SSH_ARGS itzmineydev@localhost "test -d $TARGET_DIR/browser && test -d $TARGET_DIR/server"
|
||||||
ssh $SSH_ARGS itzmineydev@localhost "ln -sfn $TARGET_DIR $CURRENT_LINK"
|
ssh $SSH_ARGS itzmineydev@localhost "ln -sfn $TARGET_DIR $CURRENT_LINK"
|
||||||
|
|
||||||
|
ssh $SSH_ARGS itzmineydev@localhost "sudo systemctl restart itzmineydev-ssr"
|
||||||
|
|
||||||
echo "Successfully published frontend release $RELEASE_ID"
|
echo "Successfully published frontend release $RELEASE_ID"
|
||||||
|
|
||||||
- name: Cleanup old releases
|
- name: Cleanup old releases
|
||||||
|
|||||||
+13
-1
@@ -32,9 +32,21 @@
|
|||||||
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/brands.min.css",
|
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/brands.min.css",
|
||||||
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/solid.min.css"
|
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/solid.min.css"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [],
|
||||||
|
"server": "src/main.server.ts",
|
||||||
|
"outputMode": "server",
|
||||||
|
"security": {
|
||||||
|
"allowedHosts": [
|
||||||
|
"localhost",
|
||||||
|
"localhost:4000",
|
||||||
|
"itzminey.dev",
|
||||||
|
"*.itzminey.dev"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"ssr": {
|
||||||
|
"entry": "src/server.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
"budgets": [
|
"budgets": [
|
||||||
|
|||||||
Generated
+1301
-584
File diff suppressed because it is too large.
Load diff
+18
-14
@@ -4,19 +4,23 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build && node ./scripts/prerender-meta.js",
|
"build": "ng build",
|
||||||
"watch": "ng build --watch --configuration development"
|
"watch": "ng build --watch --configuration development",
|
||||||
|
"serve:ssr:itzmineydev": "node dist/itzmineydev/server/server.mjs"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": "^22.2.3",
|
"@angular/common": "^22.2.5",
|
||||||
"@angular/compiler": "^22.2.3",
|
"@angular/compiler": "^22.2.5",
|
||||||
"@angular/core": "^22.2.3",
|
"@angular/core": "^22.2.5",
|
||||||
"@angular/forms": "^22.2.3",
|
"@angular/forms": "^22.2.5",
|
||||||
"@angular/platform-browser": "^22.2.3",
|
"@angular/platform-browser": "^22.2.5",
|
||||||
"@angular/router": "^22.2.3",
|
"@angular/platform-server": "^22.2.5",
|
||||||
|
"@angular/router": "^22.2.5",
|
||||||
|
"@angular/ssr": "^22.2.6",
|
||||||
"@ngx-translate/core": "^16.0.4",
|
"@ngx-translate/core": "^16.0.4",
|
||||||
"@ngx-translate/http-loader": "^16.0.1",
|
"@ngx-translate/http-loader": "^16.0.1",
|
||||||
|
"express": "^5.1.0",
|
||||||
"marked": "^17.0.4",
|
"marked": "^17.0.4",
|
||||||
"ngx-markdown": "^22.0.0",
|
"ngx-markdown": "^22.0.0",
|
||||||
"parallax-js": "^3.1.0",
|
"parallax-js": "^3.1.0",
|
||||||
@@ -25,14 +29,14 @@
|
|||||||
"zone.js": "~0.15.0"
|
"zone.js": "~0.15.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular/build": "^22.0.6",
|
"@angular/build": "^22.2.6",
|
||||||
"@angular/cli": "^22.0.6",
|
"@angular/cli": "^22.2.6",
|
||||||
"@angular/compiler-cli": "^22.2.3",
|
"@angular/compiler-cli": "^22.2.5",
|
||||||
"@types/node": "^26.1.1",
|
"@types/express": "^5.0.1",
|
||||||
|
"@types/node": "^22.12.0",
|
||||||
"@types/parallax-js": "^3.1.3",
|
"@types/parallax-js": "^3.1.3",
|
||||||
"istanbul-lib-instrument": "^6.0.3",
|
"istanbul-lib-instrument": "^6.0.3",
|
||||||
"typescript": "~6.0.3"
|
"typescript": "~6.0.3"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
import {AfterViewInit, Component, ElementRef, HostListener, OnInit, ViewChild, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
|
import {
|
||||||
|
AfterViewInit, Component, ElementRef, HostListener, OnInit, ViewChild, ViewEncapsulation, ChangeDetectionStrategy,
|
||||||
|
inject, PLATFORM_ID
|
||||||
|
} from '@angular/core';
|
||||||
|
import { isPlatformBrowser } from '@angular/common';
|
||||||
import {ViewportService} from '../shared/services/viewport.service';
|
import {ViewportService} from '../shared/services/viewport.service';
|
||||||
import {Title} from '@angular/platform-browser';
|
|
||||||
import {TranslatePipe} from '@ngx-translate/core';
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
||||||
import {NgStyle} from '@angular/common';
|
import {NgStyle} from '@angular/common';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {TerminalEmulatorComponent} from '../shared/terminal-emulator/terminal-emulator.component';
|
import {TerminalEmulatorComponent} from '../shared/terminal-emulator/terminal-emulator.component';
|
||||||
|
import {SeoService} from '../shared/services/seo.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-about',
|
selector: 'app-about',
|
||||||
@@ -22,6 +26,7 @@ import {TerminalEmulatorComponent} from '../shared/terminal-emulator/terminal-em
|
|||||||
styleUrls: ['./about.component.css']
|
styleUrls: ['./about.component.css']
|
||||||
})
|
})
|
||||||
export class AboutComponent implements OnInit, AfterViewInit {
|
export class AboutComponent implements OnInit, AfterViewInit {
|
||||||
|
private platformId = inject(PLATFORM_ID);
|
||||||
isNarrow: boolean = false;
|
isNarrow: boolean = false;
|
||||||
terminalShouldBoot: boolean = false;
|
terminalShouldBoot: boolean = false;
|
||||||
|
|
||||||
@@ -29,23 +34,37 @@ export class AboutComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private deviceService: ViewportService,
|
private deviceService: ViewportService,
|
||||||
private titleService: Title
|
private seo: SeoService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle('itzMiney\'s Home');
|
this.seo.update({
|
||||||
|
title: 'itzMiney\'s Home',
|
||||||
|
desc: 'Welcome to itzMiney\'s Homepage! Here you can find my portfolio and other cool stuff.',
|
||||||
|
suffix: false,
|
||||||
|
buttons: [
|
||||||
|
{ label: 'About', url: 'https://itzminey.dev/about' },
|
||||||
|
{ label: 'Portfolio', url: 'https://itzminey.dev/portfolio' },
|
||||||
|
{ label: 'Socials', url: 'https://itzminey.dev/socials' },
|
||||||
|
{ label: 'Blog', url: 'https://itzminey.dev/blog' }
|
||||||
|
]
|
||||||
|
});
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
this.checkTerminalTrigger();
|
this.checkTerminalTrigger();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@HostListener('window:scroll')
|
@HostListener('window:scroll')
|
||||||
onWindowScroll() {
|
onWindowScroll() {
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
this.checkTerminalTrigger();
|
this.checkTerminalTrigger();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private checkTerminalTrigger() {
|
private checkTerminalTrigger() {
|
||||||
if (this.terminalShouldBoot || !this.contentTrigger) return;
|
if (this.terminalShouldBoot || !this.contentTrigger) return;
|
||||||
@@ -58,6 +77,8 @@ export class AboutComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scrollDown() {
|
scrollDown() {
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
document.getElementById('content')?.scrollIntoView({behavior: 'smooth'});
|
document.getElementById('content')?.scrollIntoView({behavior: 'smooth'});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,11 @@ import {Component, OnDestroy, OnInit, ChangeDetectionStrategy} from '@angular/co
|
|||||||
import {Router, RouterLink} from '@angular/router';
|
import {Router, RouterLink} from '@angular/router';
|
||||||
import {ArticleService} from '../shared/services/article.service';
|
import {ArticleService} from '../shared/services/article.service';
|
||||||
import {UserService} from '../shared/services/user.service';
|
import {UserService} from '../shared/services/user.service';
|
||||||
|
import {SeoService} from '../shared/services/seo.service';
|
||||||
import {NgClass, NgStyle, TitleCasePipe} from '@angular/common';
|
import {NgClass, NgStyle, TitleCasePipe} from '@angular/common';
|
||||||
import {Observer, Subscription, interval} from 'rxjs';
|
import {Observer, Subscription, interval} from 'rxjs';
|
||||||
import {FormsModule, NgForm} from '@angular/forms';
|
import {FormsModule, NgForm} from '@angular/forms';
|
||||||
import {ViewportService} from '../shared/services/viewport.service';
|
import {ViewportService} from '../shared/services/viewport.service';
|
||||||
import {Title} from '@angular/platform-browser';
|
|
||||||
import {ModalComponent} from '../shared/modal/modal.component';
|
import {ModalComponent} from '../shared/modal/modal.component';
|
||||||
import {AuthService} from '../shared/services/auth.service';
|
import {AuthService} from '../shared/services/auth.service';
|
||||||
import {ShortenerComponent} from '../shared/shortener/shortener.component';
|
import {ShortenerComponent} from '../shared/shortener/shortener.component';
|
||||||
@@ -89,13 +89,17 @@ export class AdminComponent implements OnInit, OnDestroy {
|
|||||||
private articleService: ArticleService,
|
private articleService: ArticleService,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
private seo: SeoService,
|
||||||
private deviceService: ViewportService,
|
private deviceService: ViewportService,
|
||||||
private titleService: Title,
|
|
||||||
protected authService: AuthService
|
protected authService: AuthService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle('Admin Panel | itzMiney')
|
this.seo.update({
|
||||||
|
title: 'Admin Panel',
|
||||||
|
desc: 'Management & Administration Panel'
|
||||||
|
});
|
||||||
|
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
this.startTokenValidation();
|
this.startTokenValidation();
|
||||||
this.loadArticles();
|
this.loadArticles();
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
||||||
|
import { provideServerRendering, withRoutes } from '@angular/ssr';
|
||||||
|
import { appConfig } from './app.config';
|
||||||
|
import { serverRoutes } from './app.routes.server';
|
||||||
|
|
||||||
|
const serverConfig: ApplicationConfig = {
|
||||||
|
providers: [
|
||||||
|
provideServerRendering(withRoutes(serverRoutes))
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
||||||
@@ -43,6 +43,6 @@ export const appConfig: ApplicationConfig = {
|
|||||||
deps: [HttpClient]
|
deps: [HttpClient]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
),
|
), provideClientHydration(),
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { RenderMode, ServerRoute } from '@angular/ssr';
|
||||||
|
|
||||||
|
export const serverRoutes: ServerRoute[] = [
|
||||||
|
{
|
||||||
|
path: '**',
|
||||||
|
renderMode: RenderMode.Server
|
||||||
|
}
|
||||||
|
];
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import {Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
|
import {Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
|
||||||
import {DatePipe, NgClass, NgStyle} from '@angular/common';
|
import {DatePipe, NgClass, NgStyle} from '@angular/common';
|
||||||
import {ArticleService} from '../../shared/services/article.service';
|
import {ArticleService} from '../../shared/services/article.service';
|
||||||
|
import { SeoService } from '../../shared/services/seo.service';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {Title} from '@angular/platform-browser';
|
|
||||||
import {TranslatePipe} from '@ngx-translate/core';
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
import {ParallaxComponent} from '../../shared/parallax/parallax.component';
|
import {ParallaxComponent} from '../../shared/parallax/parallax.component';
|
||||||
import {MarkdownModule} from 'ngx-markdown';
|
import {MarkdownModule} from 'ngx-markdown';
|
||||||
@@ -52,7 +52,7 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private articleService: ArticleService,
|
private articleService: ArticleService,
|
||||||
private titleService: Title,
|
private seo: SeoService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private viewportService: ViewportService
|
private viewportService: ViewportService
|
||||||
) {
|
) {
|
||||||
@@ -69,7 +69,9 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
this.isNarrow = this.viewportService.isNarrow;
|
this.isNarrow = this.viewportService.isNarrow;
|
||||||
|
|
||||||
if (!slug) {
|
if (!slug) {
|
||||||
this.titleService.setTitle('Error | itzMiney');
|
this.seo.update({ title: 'Error', desc: 'Page not found' });
|
||||||
|
this.error = true;
|
||||||
|
this.loading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,13 +81,23 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
this.article = null;
|
this.article = null;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.error = true;
|
this.error = true;
|
||||||
|
this.seo.update({
|
||||||
|
title: '404 | Article Not Found',
|
||||||
|
desc: 'The requested article could not be found.',
|
||||||
|
suffix: false
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.article = article;
|
this.article = article;
|
||||||
this.renderedContent = this.transformCustomBlocks(article.content);
|
this.renderedContent = this.transformCustomBlocks(article.content);
|
||||||
this.titleService.setTitle(`${article.title} | itzMiney`);
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
|
this.seo.update({
|
||||||
|
title: article.title,
|
||||||
|
desc: article.content.substring(0, 150).replace(/[#*`_]/g, '') + '...', // Clean excerpt for description
|
||||||
|
img: article.thumb_url || undefined
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Error fetching article:', error);
|
console.error('Error fetching article:', error);
|
||||||
@@ -94,6 +106,11 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
|
|
||||||
if (error.status === 404) {
|
if (error.status === 404) {
|
||||||
this.error = true;
|
this.error = true;
|
||||||
|
this.seo.update({
|
||||||
|
title: '404 | Article Not Found',
|
||||||
|
desc: 'The requested article could not be found.',
|
||||||
|
suffix: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr class="rounded">
|
<hr class="rounded">
|
||||||
<div class="blog-container">
|
<div class="blog-container">
|
||||||
|
@if (hasError) {
|
||||||
|
<div class="error-state">
|
||||||
|
<h2>Error: Couldn't fetch articles!</h2>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
@if (articles$ | async; as articles) {
|
@if (articles$ | async; as articles) {
|
||||||
|
@if (articles.length === 0) {
|
||||||
|
<div class="empty-state">
|
||||||
|
<h2>{{ 'ARTICLES_NONE' | translate }}</h2>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
<div>
|
<div>
|
||||||
@for (article of articles.slice(); track article) {
|
@for (article of articles.slice(); track article) {
|
||||||
<div (click)="navigateToArticle(article.slug)" class="article-card" [ngClass]="{ 'narrow': isNarrow }">
|
<div (click)="navigateToArticle(article.slug)" class="article-card" [ngClass]="{ 'narrow': isNarrow }">
|
||||||
@@ -31,8 +41,8 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
} @else {
|
}
|
||||||
<h2>{{ 'ARTICLES_NONE' | translate }}</h2>
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -3,10 +3,11 @@ import {ViewportService} from '../shared/services/viewport.service'
|
|||||||
import {DatePipe, AsyncPipe, SlicePipe, NgStyle, NgClass} from '@angular/common';
|
import {DatePipe, AsyncPipe, SlicePipe, NgStyle, NgClass} from '@angular/common';
|
||||||
import { ArticleService } from '../shared/services/article.service';
|
import { ArticleService } from '../shared/services/article.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable, of} from 'rxjs';
|
||||||
import {Title} from '@angular/platform-browser';
|
import {catchError} from 'rxjs/operators';
|
||||||
import {TranslatePipe} from '@ngx-translate/core';
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
||||||
|
import {SeoService} from '../shared/services/seo.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-blog',
|
selector: 'app-blog',
|
||||||
@@ -25,6 +26,7 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
|||||||
})
|
})
|
||||||
export class BlogComponent implements OnInit {
|
export class BlogComponent implements OnInit {
|
||||||
articles$: Observable<any[]> | undefined;
|
articles$: Observable<any[]> | undefined;
|
||||||
|
hasError: boolean = false;
|
||||||
isNarrow: boolean = false;
|
isNarrow: boolean = false;
|
||||||
readonly defaultThumbUrl = '/assets/ogimg.png';
|
readonly defaultThumbUrl = '/assets/ogimg.png';
|
||||||
|
|
||||||
@@ -32,13 +34,23 @@ export class BlogComponent implements OnInit {
|
|||||||
private deviceService: ViewportService,
|
private deviceService: ViewportService,
|
||||||
private articleService: ArticleService,
|
private articleService: ArticleService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private titleService: Title
|
private seo: SeoService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle('Blog | itzMiney')
|
this.seo.update({
|
||||||
|
title: 'Blog',
|
||||||
|
desc: 'I post updates on the stuff I do here! (sometimes)'
|
||||||
|
});
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
this.articles$ = this.articleService.getAllArticles();
|
|
||||||
|
this.articles$ = this.articleService.getAllArticles().pipe(
|
||||||
|
catchError((err) => {
|
||||||
|
console.error('Failed to fetch articles from API:', err);
|
||||||
|
this.hasError = true;
|
||||||
|
return of([]);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onThumbError(event: Event): void {
|
onThumbError(event: Event): void {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import {AuthService} from '../shared/services/auth.service';
|
|||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {ViewportService} from '../shared/services/viewport.service';
|
import {ViewportService} from '../shared/services/viewport.service';
|
||||||
import { Title } from '@angular/platform-browser';
|
|
||||||
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
||||||
|
import {SeoService} from '../shared/services/seo.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
@@ -27,11 +27,14 @@ export class LoginComponent implements OnInit {
|
|||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private deviceService: ViewportService,
|
private deviceService: ViewportService,
|
||||||
private titleService: Title,
|
private seo: SeoService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle('Login | itzMiney')
|
this.seo.update({
|
||||||
|
title:'Login',
|
||||||
|
desc: 'Admin Panel Login'
|
||||||
|
})
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
|
|
||||||
if (this.authService.token) {
|
if (this.authService.token) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';
|
import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';
|
||||||
import {Title} from '@angular/platform-browser';
|
|
||||||
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
||||||
|
import {SeoService} from '../shared/services/seo.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-not-found',
|
selector: 'app-not-found',
|
||||||
@@ -15,11 +15,15 @@ import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
|||||||
export class NotFoundComponent implements OnInit {
|
export class NotFoundComponent implements OnInit {
|
||||||
isNarrow: boolean = false;
|
isNarrow: boolean = false;
|
||||||
constructor(
|
constructor(
|
||||||
private titleService: Title,
|
private seo: SeoService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle('404 | Page Not Found')
|
this.seo.update({
|
||||||
|
title: '404 | Page Not Found',
|
||||||
|
desc: 'How the hell did you end up here?',
|
||||||
|
suffix: false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import {Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
|
import {Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
|
||||||
import {ViewportService} from '../shared/services/viewport.service';
|
import {ViewportService} from '../shared/services/viewport.service';
|
||||||
import { CommonModule, NgStyle } from '@angular/common';
|
import { CommonModule, NgStyle } from '@angular/common';
|
||||||
import {Title} from '@angular/platform-browser';
|
|
||||||
import {AudioPlayerComponent} from '../shared/audio-player/audio-player.component';
|
import {AudioPlayerComponent} from '../shared/audio-player/audio-player.component';
|
||||||
import {TranslatePipe} from '@ngx-translate/core';
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
||||||
|
import {SeoService} from '../shared/services/seo.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-portfolio',
|
selector: 'app-portfolio',
|
||||||
@@ -47,11 +47,14 @@ export class PortfolioComponent implements OnInit {
|
|||||||
isNarrow: boolean = false;
|
isNarrow: boolean = false;
|
||||||
constructor(
|
constructor(
|
||||||
private deviceService: ViewportService,
|
private deviceService: ViewportService,
|
||||||
private titleService: Title,
|
private seo: SeoService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle('Portfolio | itzMiney');
|
this.seo.update({
|
||||||
|
title: 'Portfolio',
|
||||||
|
desc: 'This is my portfolio where you can find examples of my designs and other projects!'
|
||||||
|
})
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {AfterViewInit, Component, OnInit, ChangeDetectionStrategy} from '@angular/core';
|
import {AfterViewInit, Component, OnInit, ChangeDetectionStrategy} from '@angular/core';
|
||||||
import {ViewportService} from '../shared/services/viewport.service';
|
import {ViewportService} from '../shared/services/viewport.service';
|
||||||
import {Title} from '@angular/platform-browser';
|
|
||||||
import {TranslatePipe} from '@ngx-translate/core';
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
||||||
|
import {SeoService} from '../shared/services/seo.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-services',
|
selector: 'app-services',
|
||||||
@@ -22,7 +22,7 @@ export class PrivacyComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private deviceService: ViewportService,
|
private deviceService: ViewportService,
|
||||||
private titleService: Title,
|
private seo: SeoService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
scrollToSection(event: Event, targetId: string): void {
|
scrollToSection(event: Event, targetId: string): void {
|
||||||
@@ -39,7 +39,10 @@ export class PrivacyComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle('Privacy Policy | itzMiney');
|
this.seo.update({
|
||||||
|
title: 'Privacy Policy',
|
||||||
|
desc: 'Information about the data collected on this site and how it is used.'
|
||||||
|
});
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import {Inject, Injectable} from '@angular/core';
|
||||||
|
import { Title, Meta } from '@angular/platform-browser';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
|
||||||
|
export interface DiscordButton {
|
||||||
|
label: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
|
||||||
|
export class SeoService {
|
||||||
|
private readonly rootDomain = 'https://itzminey.dev';
|
||||||
|
private readonly defaultImage = 'https://meta.itzminey.dev/assets/ogimg.png';
|
||||||
|
private readonly siteColor = '#0095a4';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private titleService: Title,
|
||||||
|
private metaService: Meta,
|
||||||
|
private router: Router,
|
||||||
|
@Inject(DOCUMENT) private document: Document
|
||||||
|
) {}
|
||||||
|
|
||||||
|
update(config: { title: string; desc: string; img?: string; suffix?: boolean; buttons?: DiscordButton[];}) {
|
||||||
|
const siteName = 'itzMiney';
|
||||||
|
const appendSuffix = config.suffix ?? true;
|
||||||
|
|
||||||
|
const title = appendSuffix && !config.title.includes(siteName)
|
||||||
|
? `${config.title} | ${siteName}`
|
||||||
|
: config.title;
|
||||||
|
|
||||||
|
const description = config.desc;
|
||||||
|
const image = config.img || this.defaultImage;
|
||||||
|
const currentUrl = `${this.rootDomain}${this.router.url}`;
|
||||||
|
|
||||||
|
this.titleService.setTitle(title );
|
||||||
|
|
||||||
|
this.metaService.updateTag({ name: 'description', content: description });
|
||||||
|
this.metaService.updateTag({ property: 'og:title', content: title });
|
||||||
|
this.metaService.updateTag({ property: 'og:description', content: description });
|
||||||
|
this.metaService.updateTag({ property: 'og:image', content: image });
|
||||||
|
this.metaService.updateTag({ property: 'og:url', content: currentUrl });
|
||||||
|
this.metaService.updateTag({ name: 'theme-color', content: this.siteColor });
|
||||||
|
|
||||||
|
this.injectDiscordButtons(config.buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
private injectDiscordButtons( buttons?: DiscordButton[] ) {
|
||||||
|
const existingScript = this.document.getElementById('discord:component-embed');
|
||||||
|
if (existingScript) {
|
||||||
|
existingScript.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!buttons || buttons.length === 0) return;
|
||||||
|
|
||||||
|
const componentPayload = {
|
||||||
|
component: {
|
||||||
|
type: 17,
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
type: 1,
|
||||||
|
components: buttons.map(btn => ({
|
||||||
|
type: 2,
|
||||||
|
label: btn.label,
|
||||||
|
style: 5,
|
||||||
|
url: btn.url
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const script = this.document.createElement('script');
|
||||||
|
script.id = 'discord:component-embed';
|
||||||
|
script.type = 'application/json';
|
||||||
|
script.text = JSON.stringify(componentPayload, null, 2);
|
||||||
|
this.document.head.appendChild(script);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';
|
import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core';
|
||||||
import {NgStyle} from '@angular/common';
|
import {NgStyle} from '@angular/common';
|
||||||
import {ViewportService} from '../shared/services/viewport.service';
|
import {ViewportService} from '../shared/services/viewport.service';
|
||||||
import {Title} from '@angular/platform-browser';
|
|
||||||
import {TranslatePipe} from '@ngx-translate/core';
|
import {TranslatePipe} from '@ngx-translate/core';
|
||||||
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
import {ParallaxComponent} from '../shared/parallax/parallax.component';
|
||||||
|
import {SeoService} from '../shared/services/seo.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-socials',
|
selector: 'app-socials',
|
||||||
@@ -22,11 +22,14 @@ export class SocialsComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private deviceService: ViewportService,
|
private deviceService: ViewportService,
|
||||||
private titleService: Title
|
private seo: SeoService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle('Socials | itzMiney');
|
this.seo.update({
|
||||||
|
title: 'Socials',
|
||||||
|
desc: 'Here you can find links to all the places I exist on!'
|
||||||
|
})
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { BootstrapContext, bootstrapApplication } from '@angular/platform-browser';
|
||||||
|
import { AppComponent } from './app/app.component';
|
||||||
|
import { config } from './app/app.config.server';
|
||||||
|
|
||||||
|
const bootstrap = (context: BootstrapContext) =>
|
||||||
|
bootstrapApplication(AppComponent, config, context);
|
||||||
|
|
||||||
|
export default bootstrap;
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import {
|
||||||
|
AngularNodeAppEngine,
|
||||||
|
createNodeRequestHandler,
|
||||||
|
isMainModule,
|
||||||
|
writeResponseToNodeResponse,
|
||||||
|
} from '@angular/ssr/node';
|
||||||
|
import express from 'express';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
|
||||||
|
const browserDistFolder = join(import.meta.dirname, '../browser');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const angularApp = new AngularNodeAppEngine();
|
||||||
|
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proxy /api requests to backend API server on port 7020
|
||||||
|
*/
|
||||||
|
app.use('/api', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const backendUrl = `http://127.0.0.1:7020${req.originalUrl}`;
|
||||||
|
const headers = new Headers();
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(req.headers)) {
|
||||||
|
if (value && key !== 'host' && key !== 'connection') {
|
||||||
|
headers.set(key, Array.isArray(value) ? value.join(', ') : value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchOptions: RequestInit = {
|
||||||
|
method: req.method,
|
||||||
|
headers,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!['GET', 'HEAD'].includes(req.method)) {
|
||||||
|
fetchOptions.body = JSON.stringify(req.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiRes = await fetch(backendUrl, fetchOptions);
|
||||||
|
res.status(apiRes.status);
|
||||||
|
|
||||||
|
apiRes.headers.forEach((val, key) => {
|
||||||
|
res.setHeader(key, val);
|
||||||
|
});
|
||||||
|
|
||||||
|
const buffer = await apiRes.arrayBuffer();
|
||||||
|
res.send(Buffer.from(buffer));
|
||||||
|
} catch (err) {
|
||||||
|
res.status(500).json({ error: 'SSR API Proxy failed', details: String(err) });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serve static files from /browser
|
||||||
|
*/
|
||||||
|
app.use(
|
||||||
|
express.static(browserDistFolder, {
|
||||||
|
maxAge: '1y',
|
||||||
|
index: false,
|
||||||
|
redirect: false,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle all other requests by rendering the Angular application.
|
||||||
|
*/
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
angularApp
|
||||||
|
.handle(req)
|
||||||
|
.then((response) =>
|
||||||
|
response ? writeResponseToNodeResponse(response, res) : next(),
|
||||||
|
)
|
||||||
|
.catch(next);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the server if this module is the main entry point, or it is ran via PM2.
|
||||||
|
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
|
||||||
|
*/
|
||||||
|
if (isMainModule(import.meta.url) || process.env['pm_id']) {
|
||||||
|
const port = process.env['PORT'] || 4000;
|
||||||
|
app.listen(port, (error) => {
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Node Express server listening on http://localhost:${port}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request handler used by the Angular CLI (for dev-server and during build) or Firebase Cloud Functions.
|
||||||
|
*/
|
||||||
|
export const reqHandler = createNodeRequestHandler(app);
|
||||||
+4
-1
@@ -5,10 +5,13 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./out-tsc/app",
|
"outDir": "./out-tsc/app",
|
||||||
"types": [
|
"types": [
|
||||||
|
"node"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src/main.ts"
|
"src/main.ts",
|
||||||
|
"src/main.server.ts",
|
||||||
|
"src/server.ts"
|
||||||
],
|
],
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.d.ts"
|
"src/**/*.d.ts"
|
||||||
|
|||||||
Reference in new issue
Block a user