Switched to using Server Side Rendering
This commit is contained in:
1 parent
199b19459b
commit
06ab3b06bd
14 files changed
+574
-340
No files matched your search
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user