refactored seo helper, adjusted meta tags & added a shitload more buttons to discord component embeds
This commit is contained in:
1 parent
c0b75c341a
commit
e7ed9f047f
12 files changed
+248
-89
No files matched your search
+14
-2
@@ -18,10 +18,22 @@
|
|||||||
|
|
||||||
"BLOG_SUB": "(Sehr) irreguläre updates",
|
"BLOG_SUB": "(Sehr) irreguläre updates",
|
||||||
|
|
||||||
"ARTICLE_BACK": "Zurück zur Übersicht",
|
|
||||||
"ARTICLES_NONE": "Noch keine Artikel!",
|
"ARTICLES_NONE": "Noch keine Artikel!",
|
||||||
"ARTICLE_NOTFOUND": "Artikel wurde nicht gefunden!",
|
"ARTICLE_NOTFOUND": "Artikel wurde nicht gefunden!",
|
||||||
"CREATED_AT": "Erstellt:",
|
|
||||||
|
"TIME": {
|
||||||
|
"FORMAT": "H:mm",
|
||||||
|
"PREFIX": "um ",
|
||||||
|
"SUFFIX": " Uhr"
|
||||||
|
},
|
||||||
|
|
||||||
|
"BUTTONS": {
|
||||||
|
"SHARE": "Teilen",
|
||||||
|
"BACK": "Zurück"
|
||||||
|
},
|
||||||
|
|
||||||
|
"RELEASED_AT": "Publikationsdatum",
|
||||||
|
"UPDATED_AT": "Letzte Änderung",
|
||||||
|
|
||||||
"IMP_TITLE": "Impressum",
|
"IMP_TITLE": "Impressum",
|
||||||
"IMPRINT": "Diese Website wird betrieben von Michael Reisinger in Österreich, erreichbar unter:",
|
"IMPRINT": "Diese Website wird betrieben von Michael Reisinger in Österreich, erreichbar unter:",
|
||||||
|
|||||||
+14
-2
@@ -19,10 +19,22 @@
|
|||||||
|
|
||||||
"BLOG_SUB": "Some (very) irregular updates",
|
"BLOG_SUB": "Some (very) irregular updates",
|
||||||
|
|
||||||
"ARTICLE_BACK": "Back to Overview",
|
|
||||||
"ARTICLES_NONE": "No Articles yet!",
|
"ARTICLES_NONE": "No Articles yet!",
|
||||||
"ARTICLE_NOTFOUND": "Article not found!",
|
"ARTICLE_NOTFOUND": "Article not found!",
|
||||||
"CREATED_AT": "Created At:",
|
|
||||||
|
"TIME": {
|
||||||
|
"FORMAT": "shortTime",
|
||||||
|
"PREFIX": "at ",
|
||||||
|
"SUFFIX": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
"BUTTONS": {
|
||||||
|
"SHARE": "Share",
|
||||||
|
"BACK": "Back"
|
||||||
|
},
|
||||||
|
|
||||||
|
"RELEASED_AT": "Publishing Date",
|
||||||
|
"UPDATED_AT": "Last Update",
|
||||||
|
|
||||||
"privacy": {
|
"privacy": {
|
||||||
"title": "Privacy Policy",
|
"title": "Privacy Policy",
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ export class AboutComponent implements OnInit, AfterViewInit {
|
|||||||
desc: 'Welcome to itzMiney\'s Homepage! Here you can find my portfolio and other cool stuff.',
|
desc: 'Welcome to itzMiney\'s Homepage! Here you can find my portfolio and other cool stuff.',
|
||||||
suffix: false,
|
suffix: false,
|
||||||
buttons: [
|
buttons: [
|
||||||
{ label: 'About', url: 'https://itzminey.dev/about' },
|
{ label: 'About', url: this.seo.getpath('root') },
|
||||||
{ label: 'Portfolio', url: 'https://itzminey.dev/portfolio' },
|
{ label: 'Portfolio', url: this.seo.getpath('portfolio') },
|
||||||
{ label: 'Socials', url: 'https://itzminey.dev/socials' },
|
{ label: 'Socials', url: this.seo.getpath('socials') },
|
||||||
{ label: 'Blog', url: 'https://itzminey.dev/blog' }
|
{ label: 'Blog', url: this.seo.getpath('blog') }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ export class AdminComponent implements OnInit, OnDestroy {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.seo.update({
|
this.seo.update({
|
||||||
title: 'Admin Panel',
|
title: 'Admin Panel',
|
||||||
desc: 'Management & Administration Panel'
|
desc: 'Management & Administration Panel',
|
||||||
|
buttons: [{ label: 'Log-in', url: this.seo.getpath('root')}]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
|
|||||||
@@ -111,60 +111,98 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.article-meta {
|
.article-meta {
|
||||||
font-size: 1rem;
|
display: flex;
|
||||||
color: #D6DAEFBD;
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: rgb(168 168 211);
|
||||||
text-align: left;
|
text-align: left;
|
||||||
margin: 25px 0;
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-meta strong, .article-meta .meta-left i {
|
||||||
|
color: rgb(214 217 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-meta p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-meta .meta-right strong {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-meta .meta-left, .article-meta .meta-right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article-buttons {
|
.article-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
color: white;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin: 0 0 5px 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article-buttons button {
|
.article-buttons i {
|
||||||
background-color: #444893FF;
|
|
||||||
color: #fff;
|
|
||||||
border: none;
|
|
||||||
padding: 10px 20px;
|
|
||||||
font-size: 1rem;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 25px;
|
|
||||||
transition: background-color 0.3s;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-buttons button:hover {
|
|
||||||
background-color: #707ec5;
|
|
||||||
}
|
|
||||||
|
|
||||||
#shareBtn {
|
|
||||||
background-color: transparent;
|
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-buttons .buttons-left {
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 20px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-buttons .buttons-right {
|
||||||
|
display: inline-flex;
|
||||||
|
margin-top: auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-buttons .buttons-right i {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-buttons .buttons-right p {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-buttons a {
|
||||||
|
background-color: transparent;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
transition: all ease-in-out 0.2s;
|
transition: all ease-in-out 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#shareBtn:hover {
|
.article-buttons #shareBtn:hover {
|
||||||
color: #cfd7f8;
|
color: #b9ecff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#shareBtn.copied {
|
.article-buttons #shareBtn:focus, #shareBtn.copied {
|
||||||
color: #8798dc;
|
color: #5ee0ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.back-btn {
|
.article-buttons #backBtn:hover {
|
||||||
display: flex;
|
color: #ffb2b6;
|
||||||
width: 100%;
|
}
|
||||||
margin-right: 64px;
|
|
||||||
justify-content: center;
|
.article-buttons #backBtn:focus {
|
||||||
|
color: #c62d46;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error-message h1 {
|
.error-message h1 {
|
||||||
font-size: 10rem;
|
font-size: 10rem;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: white;
|
color: #ffd0d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error-message p {
|
.error-message p {
|
||||||
|
|||||||
@@ -17,9 +17,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<img
|
<img
|
||||||
class="article-thumb"
|
class="article-thumb"
|
||||||
[src]="article.thumb_url"
|
[src]="article.thumb_url || defaultThumbUrl"
|
||||||
[alt]="article.title + ' thumbnail'"
|
[alt]="article.title + ' thumbnail'"
|
||||||
(error)="onThumbError($event)"
|
|
||||||
[ngClass]="{ 'narrow': isNarrow }"
|
[ngClass]="{ 'narrow': isNarrow }"
|
||||||
/>
|
/>
|
||||||
<h1 [ngStyle]="{'font-size': isNarrow ? '2rem' : 'font-size: 2.5rem'}">{{ article.title }}</h1>
|
<h1 [ngStyle]="{'font-size': isNarrow ? '2rem' : 'font-size: 2.5rem'}">{{ article.title }}</h1>
|
||||||
@@ -31,15 +30,31 @@
|
|||||||
(click)="onArticleContentClick($event)"
|
(click)="onArticleContentClick($event)"
|
||||||
></markdown>
|
></markdown>
|
||||||
<div class="article-buttons">
|
<div class="article-buttons">
|
||||||
<button id="shareBtn" (click)="copyLink()" [class.copied]="copied" class="fa-solid fa-share"></button>
|
<div class="buttons-left">
|
||||||
<div class="back-btn">
|
<a id="backBtn" [title]="'BUTTONS.BACK' | translate" href="/blog"><i class="fa-solid fa-turn-up fa-rotate-270"></i></a>
|
||||||
<a href="/blog"><button id="backBtn">{{ 'ARTICLE_BACK' | translate }}</button></a>
|
<a id="shareBtn" [title]="'BUTTONS.SHARE' | translate" (click)="shareArticle()" [class.copied]="copied"><i class="fa-solid fa-share-nodes"></i></a>
|
||||||
|
</div>
|
||||||
|
<div class="buttons-right">
|
||||||
|
<p><strong>{{ article.views }}</strong> Views</p>
|
||||||
|
<i class="fa-solid fa-eye"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="article-meta">
|
<div class="article-meta">
|
||||||
<p><strong>Author:</strong> {{ article.authorName}}</p>
|
<div class="meta-left">
|
||||||
<p><strong>Views:</strong> {{ article.views }}</p>
|
<p title="Author"><i class="fa-solid fa-user"></i><strong> {{ article.authorName}}</strong></p>
|
||||||
<p><strong>{{ 'CREATED_AT' | translate }}</strong> {{ article.createdAt | date:'MMM dd, yyyy, HH:mm' }}</p>
|
<p [title]="'RELEASED_AT' | translate">
|
||||||
|
{{ article.createdAt | date: 'mediumDate' }}<br>
|
||||||
|
{{ 'TIME.PREFIX' | translate}}
|
||||||
|
{{ article.createdAt | date:('TIME.FORMAT' | translate) }}
|
||||||
|
{{ 'TIME.SUFFIX' | translate }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="meta-right">
|
||||||
|
<p><strong>{{ 'UPDATED_AT' | translate }}</strong></p>
|
||||||
|
<p>{{ article.updatedAt | date:'mediumDate' }}<br>
|
||||||
|
{{ 'TIME.PREFIX' | translate}}
|
||||||
|
{{ article.updatedAt | date:('TIME.FORMAT' | translate) }}
|
||||||
|
{{ 'TIME.SUFFIX' | translate }}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -45,10 +45,8 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
loading: boolean = true;
|
loading: boolean = true;
|
||||||
|
|
||||||
renderedContent: string = '';
|
renderedContent: string = '';
|
||||||
|
|
||||||
readonly defaultThumbUrl = '/assets/ogimg.png';
|
|
||||||
|
|
||||||
isNarrow: boolean = false;
|
isNarrow: boolean = false;
|
||||||
|
defaultThumbUrl: string = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private articleService: ArticleService,
|
private articleService: ArticleService,
|
||||||
@@ -62,6 +60,8 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
this.route.params.subscribe((params) => {
|
this.route.params.subscribe((params) => {
|
||||||
const slug = params['slug'];
|
const slug = params['slug'];
|
||||||
|
|
||||||
|
this.defaultThumbUrl = this.seo.getpath('assets/ogimg.png');
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.error = false;
|
this.error = false;
|
||||||
this.article = null;
|
this.article = null;
|
||||||
@@ -93,10 +93,18 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
this.renderedContent = this.transformCustomBlocks(article.content);
|
this.renderedContent = this.transformCustomBlocks(article.content);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
|
const thumbUrl = article.thumb_url || this.defaultThumbUrl;
|
||||||
|
|
||||||
this.seo.update({
|
this.seo.update({
|
||||||
title: article.title,
|
title: article.title,
|
||||||
desc: article.content.substring(0, 150).replace(/[#*`_]/g, '') + '...', // Clean excerpt for description
|
desc: article.content.substring(0, 150).replace(/[#*`_]/g, '') + '...',
|
||||||
img: article.thumb_url || undefined
|
gallery: [{
|
||||||
|
url: thumbUrl
|
||||||
|
}],
|
||||||
|
buttons: [
|
||||||
|
{ label: 'Read Post', url: this.seo.getpath() },
|
||||||
|
{ label: 'View All', url: this.seo.getpath('blog') }
|
||||||
|
]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
@@ -117,14 +125,6 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onThumbError(event: Event): void {
|
|
||||||
const img = event.target as HTMLImageElement;
|
|
||||||
|
|
||||||
if (img.src.endsWith(this.defaultThumbUrl)) return;
|
|
||||||
|
|
||||||
img.src = this.defaultThumbUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
onArticleContentClick(event: MouseEvent) {
|
onArticleContentClick(event: MouseEvent) {
|
||||||
const target = event.target as HTMLElement;
|
const target = event.target as HTMLElement;
|
||||||
|
|
||||||
@@ -171,15 +171,33 @@ export class ArticlePageComponent implements OnInit {
|
|||||||
this.selectedImage = null;
|
this.selectedImage = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
copyLink() {
|
async shareArticle() {
|
||||||
const slug = this.route.snapshot.paramMap.get('slug') || '';
|
const shareUrl = this.seo.getpath();
|
||||||
const shareLink: string = 'https://itzminey.dev/blog/' + slug;
|
|
||||||
this.copied = true;
|
|
||||||
|
|
||||||
|
if (navigator.share) {
|
||||||
|
try {
|
||||||
|
await navigator.share({
|
||||||
|
title: document.title,
|
||||||
|
url: shareUrl
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} catch (err) {
|
||||||
|
if ((err as Error).name !== 'AbortError') {
|
||||||
|
console.error('Error sharing:', err);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(shareUrl);
|
||||||
|
this.copied = true;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.copied = false;
|
this.copied = false;
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
} catch (err) {
|
||||||
navigator.clipboard.writeText(shareLink).then()
|
console.error('Failed to copy link:', err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,8 @@ export class BlogComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.seo.update({
|
this.seo.update({
|
||||||
title: 'Blog',
|
title: 'Blog',
|
||||||
desc: 'I post updates on the stuff I do here! (sometimes)'
|
desc: 'I post updates on the stuff I do here! (sometimes)',
|
||||||
|
buttons: [{ label: 'View Posts', url: this.seo.getpath() }]
|
||||||
});
|
});
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,9 @@ export class LoginComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.seo.update({
|
this.seo.update({
|
||||||
title:'Login',
|
title: 'Admin Panel',
|
||||||
desc: 'Admin Panel Login'
|
desc: 'Management & Administration Panel',
|
||||||
|
buttons: [{ label: 'Log-in', url: this.seo.getpath() }]
|
||||||
})
|
})
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ export class NotFoundComponent implements OnInit {
|
|||||||
this.seo.update({
|
this.seo.update({
|
||||||
title: '404 | Page Not Found',
|
title: '404 | Page Not Found',
|
||||||
desc: 'How the hell did you end up here?',
|
desc: 'How the hell did you end up here?',
|
||||||
suffix: false
|
suffix: false,
|
||||||
|
buttons: [{ label: 'Visit Homepage', url: this.seo.getpath('root') }]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,8 @@ export class PortfolioComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.seo.update({
|
this.seo.update({
|
||||||
title: 'Portfolio',
|
title: 'Portfolio',
|
||||||
desc: 'This is my portfolio where you can find examples of my designs and other projects!'
|
desc: 'This is my portfolio where you can find examples of my designs and other projects!',
|
||||||
|
buttons: [{ label: 'View Projects', url: this.seo.getpath() }]
|
||||||
})
|
})
|
||||||
this.isNarrow = this.deviceService.isNarrow;
|
this.isNarrow = this.deviceService.isNarrow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Inject, Injectable} from '@angular/core';
|
import {Inject, Injectable} from '@angular/core';
|
||||||
import { Title, Meta } from '@angular/platform-browser';
|
import {Meta, Title} from '@angular/platform-browser';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {DOCUMENT} from '@angular/common';
|
import {DOCUMENT} from '@angular/common';
|
||||||
|
|
||||||
@@ -8,16 +8,28 @@ export interface DiscordButton {
|
|||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DiscordGalleryItem {
|
||||||
|
url: string;
|
||||||
|
description?: string;
|
||||||
|
spoiler?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SeoConfig {
|
||||||
|
title: string;
|
||||||
|
desc: string;
|
||||||
|
img?: string;
|
||||||
|
url?: string;
|
||||||
|
col?: string;
|
||||||
|
suffix?: boolean;
|
||||||
|
buttons?: DiscordButton[];
|
||||||
|
gallery?: DiscordGalleryItem[];
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
|
|
||||||
export class SeoService {
|
export class SeoService {
|
||||||
private readonly rootDomain = 'https://itzminey.dev';
|
|
||||||
private readonly defaultImage = 'https://itzminey.dev/assets/ogimg.png';
|
|
||||||
private readonly defaultThumb = 'https://itzminey.dev/assets/thumb.png';
|
|
||||||
private readonly siteColor = '#0095a4';
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private titleService: Title,
|
private titleService: Title,
|
||||||
private metaService: Meta,
|
private metaService: Meta,
|
||||||
@@ -25,17 +37,31 @@ export class SeoService {
|
|||||||
@Inject(DOCUMENT) private document: Document
|
@Inject(DOCUMENT) private document: Document
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
update(config: { title: string; desc: string; img?: string; suffix?: boolean; buttons?: DiscordButton[];}) {
|
private readonly defaultColor = '#0095a4';
|
||||||
|
private readonly rootDomain = 'https://itzminey.dev';
|
||||||
|
|
||||||
|
getpath(path?: string ) {
|
||||||
|
if (!path) return `${this.rootDomain}${this.router.url}`;
|
||||||
|
if (path === 'root') return this.rootDomain;
|
||||||
|
return `${this.rootDomain}/${path.replace(/^\//, '')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly defaultImage = this.getpath('assets/ogimg.png');
|
||||||
|
private readonly siteThumb = this.getpath('assets/thumb.png');
|
||||||
|
|
||||||
|
update(config: SeoConfig) {
|
||||||
const siteName = 'itzMiney';
|
const siteName = 'itzMiney';
|
||||||
const appendSuffix = config.suffix ?? true;
|
const appendSuffix = config.suffix ?? true;
|
||||||
|
|
||||||
const title = appendSuffix && !config.title.includes(siteName)
|
const title = appendSuffix && !config.title.endsWith(`| ${siteName}`)
|
||||||
? `${config.title} | ${siteName}`
|
? `${config.title} | ${siteName}`
|
||||||
: config.title;
|
: config.title;
|
||||||
|
|
||||||
const description = config.desc;
|
const description = config.desc;
|
||||||
const image = config.img || this.defaultImage;
|
const image = config.img || this.defaultImage;
|
||||||
const currentUrl = `${this.rootDomain}${this.router.url}`;
|
const currentUrl = this.getpath();
|
||||||
|
const siteColor = config.col || this.defaultColor;
|
||||||
|
const gallery = config.gallery;
|
||||||
|
|
||||||
this.titleService.setTitle(title);
|
this.titleService.setTitle(title);
|
||||||
|
|
||||||
@@ -44,20 +70,39 @@ export class SeoService {
|
|||||||
this.metaService.updateTag({ property: 'og:description', content: description });
|
this.metaService.updateTag({ property: 'og:description', content: description });
|
||||||
this.metaService.updateTag({ property: 'og:image', content: image });
|
this.metaService.updateTag({ property: 'og:image', content: image });
|
||||||
this.metaService.updateTag({ property: 'og:url', content: currentUrl });
|
this.metaService.updateTag({ property: 'og:url', content: currentUrl });
|
||||||
this.metaService.updateTag({ name: 'theme-color', content: this.siteColor });
|
this.metaService.updateTag({ name: 'theme-color', content: siteColor });
|
||||||
|
|
||||||
this.injectDiscordComponentEmbed(config.buttons, { title, description, image, currentUrl });
|
this.injectDiscordComponentEmbed(config.buttons, gallery, {
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
image,
|
||||||
|
currentUrl,
|
||||||
|
siteColor
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private injectDiscordComponentEmbed(buttons?: DiscordButton[], meta?: { title: string; description: string; image: string; currentUrl: string }) {
|
private injectDiscordComponentEmbed(
|
||||||
|
buttons?: DiscordButton[],
|
||||||
|
gallery?: DiscordGalleryItem[],
|
||||||
|
meta?: {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
image: string;
|
||||||
|
currentUrl: string;
|
||||||
|
siteColor: string
|
||||||
|
},
|
||||||
|
) {
|
||||||
const existingScript = this.document.getElementById('discord:component-embed');
|
const existingScript = this.document.getElementById('discord:component-embed');
|
||||||
if (existingScript) {
|
if (existingScript) {
|
||||||
existingScript.remove();
|
existingScript.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
const thumb = meta?.image || this.defaultThumb;
|
const thumb = this.siteThumb;
|
||||||
|
const siteColor = meta?.siteColor || this.defaultColor;
|
||||||
|
|
||||||
const sectionComponent = {
|
const containerComponents: any[] = [];
|
||||||
|
|
||||||
|
containerComponents.push({
|
||||||
type: 9,
|
type: 9,
|
||||||
components: [
|
components: [
|
||||||
{
|
{
|
||||||
@@ -71,9 +116,23 @@ export class SeoService {
|
|||||||
url: thumb
|
url: thumb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
const containerComponents: any[] = [sectionComponent];
|
if (gallery && gallery.length > 0) {
|
||||||
|
containerComponents.push({
|
||||||
|
type: 12,
|
||||||
|
items: gallery.map(item => {
|
||||||
|
const galleryItem: any = {
|
||||||
|
media: {
|
||||||
|
url: item.url
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (item.description) galleryItem.description = item.description;
|
||||||
|
if (item.spoiler !== undefined) galleryItem.spoiler = item.spoiler;
|
||||||
|
return galleryItem;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (buttons && buttons.length > 0) {
|
if (buttons && buttons.length > 0) {
|
||||||
containerComponents.push({
|
containerComponents.push({
|
||||||
@@ -91,7 +150,7 @@ export class SeoService {
|
|||||||
flags: 32768,
|
flags: 32768,
|
||||||
component: {
|
component: {
|
||||||
type: 17,
|
type: 17,
|
||||||
accent_color: parseInt(this.siteColor.replace('#', ''), 16),
|
accent_color: parseInt(siteColor.replace('#', ''), 16),
|
||||||
components: containerComponents
|
components: containerComponents
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user