Switched to using Server Side Rendering

This commit is contained in:
ItzMineyy committed 2024-12-25 13:14:59 +01:00
1 parent 199b19459b
commit 06ab3b06bd
14 files changed
+574 -340

No files matched your search

+54 -24
View File
@@ -1,6 +1,10 @@
import {AfterViewInit, Component, OnDestroy, OnInit} from '@angular/core';
import {AfterViewInit, Component, OnDestroy, OnInit, Inject} from '@angular/core';
import { DeviceDetectorService } from 'ngx-device-detector';
import {NgIf} from '@angular/common';
import {Meta, Title} from '@angular/platform-browser';
import {ActivatedRoute} from '@angular/router';
import { isPlatformBrowser } from '@angular/common';
import { PLATFORM_ID } from '@angular/core';
@Component({
selector: 'app-portfolio',
@@ -11,13 +15,32 @@ import {NgIf} from '@angular/common';
styleUrl: './portfolio.component.css'
})
export class PortfolioComponent implements OnInit, OnDestroy, AfterViewInit {
constructor(private deviceService: DeviceDetectorService) {
constructor(
private deviceService: DeviceDetectorService,
private meta: Meta,
private title: Title,
private route: ActivatedRoute,
@Inject(PLATFORM_ID) private platformId: Object
) {
this.isMobile = this.deviceService.isMobile();
}
isMobile: boolean;
private vantaEffect: any;
ngOnInit() {
const metaData = this.route.snapshot.data['meta'];
if (metaData?.title) {
this.title.setTitle(metaData.title);
}
if (metaData?.description) {
this.meta.updateTag({ name: 'description', content: metaData.description });
}
if (metaData?.image) {
this.meta.updateTag({ property: 'og:image', content: metaData.image });
}
if (metaData?.url) {
this.meta.updateTag({ property: 'og:url', content: metaData.url });
}
window.addEventListener('resize', this.onResize.bind(this)); // Add resize listener for responsiveness
const bgElement = document.getElementById('vanta-portfolio-bg');
@@ -27,34 +50,41 @@ export class PortfolioComponent implements OnInit, OnDestroy, AfterViewInit {
}
ngAfterViewInit() {
this.initVanta();
this.resizeVanta();
if (isPlatformBrowser(this.platformId)) {
// Initialize VANTA effect only in the browser
this.initVanta();
this.resizeVanta();
}
}
ngOnDestroy() {
if (this.vantaEffect) {
this.vantaEffect.destroy(); // Clean up the effect on destroy
if (isPlatformBrowser(this.platformId)) {
if (this.vantaEffect) {
this.vantaEffect.destroy(); // Clean up the effect on destroy
}
window.removeEventListener('resize', this.onResize); // Remove the listener when the component is destroyed
}
window.removeEventListener('resize', this.onResize); // Remove the listener when the component is destroyed
}
initVanta() {
// Initialize the Vanta effect on the element with ID 'vanta-bg'
this.vantaEffect = window.VANTA.NET({
el: '#vanta-portfolio-bg',
mouseControls: true,
touchControls: true,
gyroControls: false,
scale: 1.00,
scaleMobile: 1.00,
points: 20.00,
maxDistance: 25.00,
spacing: 18.00,
showDots: false,
minWidth: window.innerWidth,
minHeight: window.innerHeight,
color: 0xac1f4e,
backgroundColor: 0x191522
});
if (isPlatformBrowser(this.platformId)) {
// Initialize the Vanta effect on the element with ID 'vanta-bg'
this.vantaEffect = window.VANTA.NET({
el: '#vanta-portfolio-bg',
mouseControls: true,
touchControls: true,
gyroControls: false,
scale: 1.00,
scaleMobile: 1.00,
points: 20.00,
maxDistance: 25.00,
spacing: 18.00,
showDots: false,
minWidth: window.innerWidth,
minHeight: window.innerHeight,
color: 0xac1f4e,
backgroundColor: 0x191522
});
}
}
onResize() {