Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Commit

Permalink
Add "snippets" to listing names
Browse files Browse the repository at this point in the history
Decouple short and long name for SEO.
Resolves #243
  • Loading branch information
Chalarangelo committed Dec 31, 2020
1 parent d42844a commit bb0ca2b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
29 changes: 28 additions & 1 deletion src/blocks/entities/snippetCollection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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, {
Expand Down
6 changes: 4 additions & 2 deletions src/lang/en/listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bb0ca2b

Please sign in to comment.