Changes to SSR
This commit is contained in:
1 parent
8ccee4a70f
commit
4422cf448b
5 files changed
+63
-36
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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 */
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
<app-navbar *ngIf="!isMobile"></app-navbar>
|
||||
<app-mobile-navbar *ngIf="isMobile"></app-mobile-navbar>
|
||||
<ng-container *ngIf="!isMobile; else mobileNavbar">
|
||||
<app-navbar></app-navbar>
|
||||
</ng-container>
|
||||
<ng-template #mobileNavbar>
|
||||
<app-mobile-navbar></app-mobile-navbar>
|
||||
</ng-template>
|
||||
<router-outlet />
|
||||
<app-footer></app-footer>
|
||||
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user