Changes to SSR
This commit is contained in:
1 parent
8ccee4a70f
commit
4422cf448b
4 files changed
+56
-29
No files matched your search
+15
-24
@@ -30,37 +30,22 @@
|
|||||||
"@angular/material/prebuilt-themes/magenta-violet.css",
|
"@angular/material/prebuilt-themes/magenta-violet.css",
|
||||||
"src/styles.css"
|
"src/styles.css"
|
||||||
],
|
],
|
||||||
"scripts": [],
|
"scripts": []
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"csr": {
|
||||||
|
"browser": "src/main.ts"
|
||||||
|
},
|
||||||
|
"ssr": {
|
||||||
|
"browser": "src/main.ts",
|
||||||
"server": "src/main.server.ts",
|
"server": "src/main.server.ts",
|
||||||
"outputMode": "server",
|
"outputMode": "server",
|
||||||
"ssr": {
|
"ssr": {
|
||||||
"entry": "src/server.ts"
|
"entry": "src/server.ts"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"configurations": {
|
|
||||||
"production": {
|
|
||||||
"budgets": [
|
|
||||||
{
|
|
||||||
"type": "initial",
|
|
||||||
"maximumWarning": "500kB",
|
|
||||||
"maximumError": "1MB"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "anyComponentStyle",
|
|
||||||
"maximumWarning": "4kB",
|
|
||||||
"maximumError": "8kB"
|
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"outputHashing": "all"
|
|
||||||
},
|
|
||||||
"development": {
|
|
||||||
"optimization": false,
|
|
||||||
"extractLicenses": false,
|
|
||||||
"sourceMap": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultConfiguration": "production"
|
|
||||||
},
|
|
||||||
"serve": {
|
"serve": {
|
||||||
"builder": "@angular-devkit/build-angular:dev-server",
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
"configurations": {
|
"configurations": {
|
||||||
@@ -69,9 +54,15 @@
|
|||||||
},
|
},
|
||||||
"development": {
|
"development": {
|
||||||
"buildTarget": "itzmineydev:build:development"
|
"buildTarget": "itzmineydev:build:development"
|
||||||
|
},
|
||||||
|
"csr": {
|
||||||
|
"buildTarget": "itzmineydev:build:csr"
|
||||||
|
},
|
||||||
|
"ssr": {
|
||||||
|
"buildTarget": "itzmineydev:build:ssr"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultConfiguration": "development"
|
"defaultConfiguration": "csr"
|
||||||
},
|
},
|
||||||
"extract-i18n": {
|
"extract-i18n": {
|
||||||
"builder": "@angular-devkit/build-angular:extract-i18n"
|
"builder": "@angular-devkit/build-angular:extract-i18n"
|
||||||
|
|||||||
@@ -6,3 +6,24 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 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>
|
<ng-container *ngIf="!isMobile; else mobileNavbar">
|
||||||
<app-mobile-navbar *ngIf="isMobile"></app-mobile-navbar>
|
<app-navbar></app-navbar>
|
||||||
|
</ng-container>
|
||||||
|
<ng-template #mobileNavbar>
|
||||||
|
<app-mobile-navbar></app-mobile-navbar>
|
||||||
|
</ng-template>
|
||||||
<router-outlet />
|
<router-outlet />
|
||||||
<app-footer></app-footer>
|
<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 {NgIf} from '@angular/common';
|
||||||
import { DeviceDetectorService } from 'ngx-device-detector';
|
import { DeviceDetectorService } from 'ngx-device-detector';
|
||||||
import {RouterOutlet, ActivatedRoute, Router, NavigationEnd} from '@angular/router';
|
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 {FooterComponent} from './footer/footer.component';
|
||||||
import { Title, Meta } from '@angular/platform-browser';
|
import { Title, Meta } from '@angular/platform-browser';
|
||||||
import { filter, map, mergeMap } from 'rxjs/operators';
|
import { filter, map, mergeMap } from 'rxjs/operators';
|
||||||
|
import { isPlatformBrowser } from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@@ -22,12 +23,22 @@ export class AppComponent implements OnInit {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private activatedRoute: ActivatedRoute,
|
private activatedRoute: ActivatedRoute,
|
||||||
private titleService: Title,
|
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() {
|
ngOnInit() {
|
||||||
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
|
this.isMobile = window.innerWidth <= 768;
|
||||||
|
}
|
||||||
this.router.events
|
this.router.events
|
||||||
.pipe(
|
.pipe(
|
||||||
filter(event => event instanceof NavigationEnd),
|
filter(event => event instanceof NavigationEnd),
|
||||||
|
|||||||
Reference in new issue
Block a user