Switched to using Server Side Rendering
This commit is contained in:
1 parent
199b19459b
commit
06ab3b06bd
14 files changed
+573
-339
No files matched your search
+6
-1
@@ -30,7 +30,12 @@
|
||||
"@angular/material/prebuilt-themes/magenta-violet.css",
|
||||
"src/styles.css"
|
||||
],
|
||||
"scripts": []
|
||||
"scripts": [],
|
||||
"server": "src/main.server.ts",
|
||||
"outputMode": "server",
|
||||
"ssr": {
|
||||
"entry": "src/server.ts"
|
||||
}
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
|
||||
Generated
+203
-229
File diff suppressed because it is too large.
Load diff
+15
-9
@@ -6,22 +6,26 @@
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test"
|
||||
"test": "ng test",
|
||||
"serve:ssr:itzmineydev": "node dist/itzmineydev/server/server.mjs"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^19.0.0",
|
||||
"@angular/animations": "^19.0.5",
|
||||
"@angular/cdk": "^19.0.4",
|
||||
"@angular/common": "^19.0.0",
|
||||
"@angular/compiler": "^19.0.0",
|
||||
"@angular/common": "^19.0.5",
|
||||
"@angular/compiler": "^19.0.5",
|
||||
"@angular/core": "^19.0.5",
|
||||
"@angular/forms": "^19.0.0",
|
||||
"@angular/forms": "^19.0.5",
|
||||
"@angular/material": "^19.0.4",
|
||||
"@angular/platform-browser": "^19.0.0",
|
||||
"@angular/platform-browser-dynamic": "^19.0.0",
|
||||
"@angular/router": "^19.0.0",
|
||||
"@angular/platform-browser": "^19.0.5",
|
||||
"@angular/platform-browser-dynamic": "^19.0.5",
|
||||
"@angular/platform-server": "^19.0.5",
|
||||
"@angular/router": "^19.0.5",
|
||||
"@angular/ssr": "^19.0.6",
|
||||
"@fortawesome/fontawesome-free": "^6.7.2",
|
||||
"@types/three": "^0.171.0",
|
||||
"express": "^4.18.2",
|
||||
"ngx-device-detector": "^9.0.0",
|
||||
"react": "^19.0.0",
|
||||
"rxjs": "~7.8.0",
|
||||
@@ -33,8 +37,10 @@
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^19.0.6",
|
||||
"@angular/cli": "^19.0.6",
|
||||
"@angular/compiler-cli": "^19.0.0",
|
||||
"@angular/compiler-cli": "^19.0.5",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"@types/node": "^18.18.0",
|
||||
"jasmine-core": "~5.4.0",
|
||||
"karma": "~6.4.0",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import {Component, OnInit, OnDestroy, AfterViewInit} from '@angular/core';
|
||||
import {Component, OnInit, OnDestroy, AfterViewInit, 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-about',
|
||||
@@ -11,13 +15,32 @@ import {NgIf} from '@angular/common';
|
||||
styleUrls: ['./about.component.css']
|
||||
})
|
||||
export class AboutComponent 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-about-bg');
|
||||
@@ -26,32 +49,39 @@ export class AboutComponent 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-about-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,
|
||||
});
|
||||
if (isPlatformBrowser(this.platformId)) {
|
||||
// Initialize the Vanta effect on the element with ID 'vanta-bg'
|
||||
this.vantaEffect = window.VANTA.NET({
|
||||
el: '#vanta-about-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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onResize() {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
||||
import { provideServerRendering } from '@angular/platform-server';
|
||||
import { provideServerRoutesConfig } from '@angular/ssr';
|
||||
import { appConfig } from './app.config';
|
||||
import { serverRoutes } from './app.routes.server';
|
||||
|
||||
const serverConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideServerRendering(),
|
||||
provideServerRoutesConfig(serverRoutes)
|
||||
]
|
||||
};
|
||||
|
||||
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
||||
@@ -3,7 +3,8 @@ import { provideRouter } from '@angular/router';
|
||||
|
||||
import { routes } from './app.routes';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import { provideClientHydration, withEventReplay } from '@angular/platform-browser';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideAnimationsAsync()]
|
||||
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideAnimationsAsync(), provideClientHydration(withEventReplay())]
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
import {RenderMode, ServerRoute} from '@angular/ssr';
|
||||
|
||||
export const serverRoutes: ServerRoute[] = [
|
||||
{
|
||||
path: '',
|
||||
renderMode: RenderMode.Client,
|
||||
},
|
||||
{
|
||||
path: 'about',
|
||||
renderMode: RenderMode.Prerender,
|
||||
},
|
||||
{
|
||||
path: 'portfolio',
|
||||
renderMode: RenderMode.Prerender,
|
||||
},
|
||||
{
|
||||
path: 'blog',
|
||||
renderMode: RenderMode.Prerender,
|
||||
},
|
||||
{
|
||||
path: '**',
|
||||
renderMode: RenderMode.Client,
|
||||
}
|
||||
]
|
||||
+11
-3
@@ -8,7 +8,15 @@ export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: '/about',
|
||||
pathMatch: 'full'
|
||||
pathMatch: 'full',
|
||||
data: {
|
||||
meta: {
|
||||
title: 'itzMiney\'s Home',
|
||||
description: 'Welcome to itzMiney\'s Homepage! \bHere you can find my portfolio and other cool stuff.',
|
||||
image: 'https://itzminey.dev/assets/ogimg.png',
|
||||
url: 'https://itzminey.dev/about'
|
||||
}
|
||||
}
|
||||
}, // Redirect default route to 'about'
|
||||
{
|
||||
path: 'about',
|
||||
@@ -16,7 +24,7 @@ export const routes: Routes = [
|
||||
data: {
|
||||
meta: {
|
||||
title: 'itzMiney\'s Home',
|
||||
description: 'Welcome to itzMiney\'s Homepage!\bHere you can find my portfolio and other cool stuff.',
|
||||
description: 'Welcome to itzMiney\'s Homepage! \bHere you can find my portfolio and other cool stuff.',
|
||||
image: 'https://itzminey.dev/assets/ogimg.png',
|
||||
url: 'https://itzminey.dev/about'
|
||||
}
|
||||
@@ -40,7 +48,7 @@ export const routes: Routes = [
|
||||
data: {
|
||||
meta: {
|
||||
title: 'Blog | itzMiney',
|
||||
description: 'Welcome to my blog!\bI\'ll post occasional updates here on the stuff I\'m currently up to.',
|
||||
description: 'Welcome to my blog! \bI\'ll post occasional updates here on the stuff I\'m currently up to.',
|
||||
image: 'https://itzminey.dev/assets/ogimg.png',
|
||||
url: 'https://itzminey.dev/blog'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import {Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core';
|
||||
import {Component, OnInit, OnDestroy, AfterViewInit, 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-blog',
|
||||
@@ -11,13 +15,32 @@ import {NgIf} from '@angular/common';
|
||||
styleUrl: './blog.component.css'
|
||||
})
|
||||
export class BlogComponent 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-blog-bg');
|
||||
@@ -27,34 +50,41 @@ export class BlogComponent 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-blog-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-blog-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() {
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import {Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core';
|
||||
import {Component, OnInit, OnDestroy, AfterViewInit, Inject} from '@angular/core';
|
||||
import {DeviceDetectorService} from 'ngx-device-detector';
|
||||
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-not-found',
|
||||
@@ -8,10 +13,32 @@ import {Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core';
|
||||
})
|
||||
|
||||
export class NotFoundComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
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-not-found-bg');
|
||||
@@ -21,34 +48,41 @@ export class NotFoundComponent 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-not-found-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-not-found-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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { AppComponent } from './app/app.component';
|
||||
import { config } from './app/app.config.server';
|
||||
import { platformServer } from '@angular/platform-server';
|
||||
|
||||
const bootstrap = () => bootstrapApplication(AppComponent, config);
|
||||
|
||||
export default bootstrap;
|
||||
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
AngularNodeAppEngine,
|
||||
createNodeRequestHandler,
|
||||
isMainModule,
|
||||
writeResponseToNodeResponse,
|
||||
} from '@angular/ssr/node';
|
||||
import express from 'express';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
||||
const browserDistFolder = resolve(serverDistFolder, '../browser');
|
||||
|
||||
const app = express();
|
||||
const angularApp = new AngularNodeAppEngine();
|
||||
|
||||
/**
|
||||
* Example Express Rest API endpoints can be defined here.
|
||||
* Uncomment and define endpoints as necessary.
|
||||
*
|
||||
* Example:
|
||||
* ```ts
|
||||
* app.get('/api/**', (req, res) => {
|
||||
* // Handle API request
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
|
||||
*/
|
||||
if (isMainModule(import.meta.url)) {
|
||||
const port = process.env['PORT'] || 4000;
|
||||
app.listen(port, () => {
|
||||
console.log(`Node Express server listening on http://localhost:${port}`);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The request handler used by the Angular CLI (dev-server and during build).
|
||||
*/
|
||||
export const reqHandler = createNodeRequestHandler(app);
|
||||
+6
-2
@@ -4,10 +4,14 @@
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
"types": [
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"src/main.ts"
|
||||
"src/main.ts",
|
||||
"src/main.server.ts",
|
||||
"src/server.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
|
||||
Reference in new issue
Block a user