From 4422cf448bdf20450be40c8b237c70fb003aec93 Mon Sep 17 00:00:00 2001 From: ItzMineyy Date: Wed, 25 Dec 2024 17:45:48 +0100 Subject: [PATCH] Changes to SSR --- angular.json | 45 +++++++++++++------------------- src/app/about/about.component.ts | 8 +++--- src/app/app.component.css | 21 +++++++++++++++ src/app/app.component.html | 8 ++++-- src/app/app.component.ts | 17 +++++++++--- 5 files changed, 63 insertions(+), 36 deletions(-) diff --git a/angular.json b/angular.json index 6905435..05c7df7 100644 --- a/angular.json +++ b/angular.json @@ -30,36 +30,21 @@ "@angular/material/prebuilt-themes/magenta-violet.css", "src/styles.css" ], - "scripts": [], - "server": "src/main.server.ts", - "outputMode": "server", - "ssr": { - "entry": "src/server.ts" - } + "scripts": [] }, "configurations": { - "production": { - "budgets": [ - { - "type": "initial", - "maximumWarning": "500kB", - "maximumError": "1MB" - }, - { - "type": "anyComponentStyle", - "maximumWarning": "4kB", - "maximumError": "8kB" - } - ], - "outputHashing": "all" + "csr": { + "browser": "src/main.ts" }, - "development": { - "optimization": false, - "extractLicenses": false, - "sourceMap": true + "ssr": { + "browser": "src/main.ts", + "server": "src/main.server.ts", + "outputMode": "server", + "ssr": { + "entry": "src/server.ts" + } } - }, - "defaultConfiguration": "production" + } }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", @@ -69,9 +54,15 @@ }, "development": { "buildTarget": "itzmineydev:build:development" + }, + "csr": { + "buildTarget": "itzmineydev:build:csr" + }, + "ssr": { + "buildTarget": "itzmineydev:build:ssr" } }, - "defaultConfiguration": "development" + "defaultConfiguration": "csr" }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n" diff --git a/src/app/about/about.component.ts b/src/app/about/about.component.ts index 2ebc5c5..a16d665 100644 --- a/src/app/about/about.component.ts +++ b/src/app/about/about.component.ts @@ -57,11 +57,11 @@ export class AboutComponent implements OnInit, OnDestroy, AfterViewInit { } ngOnDestroy() { 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 + 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 + } } initVanta() { diff --git a/src/app/app.component.css b/src/app/app.component.css index f4d4bd2..fb80e11 100644 --- a/src/app/app.component.css +++ b/src/app/app.component.css @@ -6,3 +6,24 @@ width: 100%; height: 100%; } + +html, body { + height: 100%; + margin: 0; + display: flex; + flex-direction: column; +} + +app-root { + display: flex; + flex-direction: column; + min-height: 100%; +} + +main { + flex: 1; /* Pushes the footer to the bottom */ +} + +app-footer { + margin-top: auto; /* Ensures it sticks to the bottom */ +} diff --git a/src/app/app.component.html b/src/app/app.component.html index 220ec2c..a59b7c4 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,4 +1,8 @@ - - + + + + + + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index b4b17dd..9db36ac 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Inject, PLATFORM_ID} from '@angular/core'; import {NgIf} from '@angular/common'; import { DeviceDetectorService } from 'ngx-device-detector'; import {RouterOutlet, ActivatedRoute, Router, NavigationEnd} from '@angular/router'; @@ -7,6 +7,7 @@ import {MobileNavbarComponent} from './mobile-navbar/mobile-navbar.component'; import {FooterComponent} from './footer/footer.component'; import { Title, Meta } from '@angular/platform-browser'; import { filter, map, mergeMap } from 'rxjs/operators'; +import { isPlatformBrowser } from '@angular/common'; @Component({ selector: 'app-root', @@ -22,12 +23,22 @@ export class AppComponent implements OnInit { private router: Router, private activatedRoute: ActivatedRoute, private titleService: Title, - private metaService: Meta + private metaService: Meta, + @Inject(PLATFORM_ID) private platformId: Object ) { - this.isMobile = this.deviceService.isMobile(); + if (isPlatformBrowser(this.platformId)) { + // Use client-side logic to determine if it's mobile + this.isMobile = window.innerWidth <= 768; // Adjust breakpoint as needed + } else { + // Default fallback for SSR + this.isMobile = false; // Or any other logic to handle SSR + } } ngOnInit() { + if (isPlatformBrowser(this.platformId)) { + this.isMobile = window.innerWidth <= 768; + } this.router.events .pipe( filter(event => event instanceof NavigationEnd),