From bb0ca2b9d7d7b08ce538260d9d8ce9a18e816470 Mon Sep 17 00:00:00 2001 From: Chalarangelo Date: Fri, 1 Jan 2021 01:23:40 +0200 Subject: [PATCH] Add "snippets" to listing names Decouple short and long name for SEO. Resolves #243 --- .../entities/snippetCollection/index.js | 29 ++++++++++++++++++- src/lang/en/listing/index.js | 6 ++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/blocks/entities/snippetCollection/index.js b/src/blocks/entities/snippetCollection/index.js index e2494b728..1e5642b6c 100644 --- a/src/blocks/entities/snippetCollection/index.js +++ b/src/blocks/entities/snippetCollection/index.js @@ -108,7 +108,7 @@ export class SnippetCollection { get meta() { return { - name: this.name, + name: this.shortName, tags: this.tags, url: this.url, slugPrefix: this.slugPrefix, @@ -143,6 +143,33 @@ export class SnippetCollection { return this._name; } + get shortName() { + if (!this._shortName) { + switch (this.type) { + case 'main': + this._shortName = literals.listing.snippetList; + break; + case 'blog': + this._shortName = literals.listing.blog; + break; + case 'language': + this._shortName = literals.listing.shortCodelang( + this.config.language.long + ); + break; + case 'tag': + this._shortName = literals.listing.shortCodelangTag( + this.config.language.long, + this.tag + ); + break; + default: + break; + } + } + return this._shortName; + } + get seoDescription() { if (!this._seoDescription) { this._seoDescription = literals.listing.pageDescription(this.type, { diff --git a/src/lang/en/listing/index.js b/src/lang/en/listing/index.js index a53e97e8b..da9590d5c 100644 --- a/src/lang/en/listing/index.js +++ b/src/lang/en/listing/index.js @@ -11,8 +11,10 @@ const literals = { snippetList: 'Snippet List', blog: 'Blog', tag: t => `${capitalize(t)}`, - codelang: l => l, - codelangTag: (l, t) => `${l} ${capitalize(t)}`, + shortCodelang: l => `${l}`, + shortCodelangTag: (l, t) => `${l} ${capitalize(t)}`, + codelang: l => `${l} Snippets`, + codelangTag: (l, t) => `${l} ${capitalize(t)} Snippets`, snippetCount: c => `${c} snippets`, pageDescription: (t, p) => { switch (t) {