Skip to content

Commit

Permalink
fix: category and tag slugs
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalikmay committed Jan 16, 2025
1 parent 6160c9c commit da8aa71
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 9 deletions.
183 changes: 180 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seobot",
"version": "1.1.0",
"version": "1.2.0",
"description": "Client library for the SEObot API",
"main": "dist/index.js",
"files": [
Expand All @@ -20,6 +20,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"slugify": "^1.6.6"
"slugify": "^1.6.6",
"transliteration": "^2.3.5"
}
}
5 changes: 3 additions & 2 deletions src/blog/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Blog } from '../types';
import slugify from 'slugify';
import transliteration from 'transliteration';

export class BlogClient {
private _key: string;
Expand All @@ -22,12 +23,12 @@ export class BlogClient {
category: short.c
? {
title: short.c.t,
slug: slugify(short.c.t, { lower: true, strict: true }),
slug: short.c.s || slugify(transliteration.transliterate(short.c.t), { lower: true, strict: true }),
}
: null,
tags: (short.tg || []).map(i => ({
title: i.t,
slug: slugify(i.t, { lower: true, strict: true }),
slug: i.s || slugify(transliteration.transliterate(i.t), { lower: true, strict: true }),
})),
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/types/blog/articleIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export interface IArticleIndexCompressed {
rt: number; // readingTime
cr: string; // createdAt
up: string; // updatedAt
c?: { t: string; }; // category
tg?: { t: string; }[]; // tags
c?: { t: string; s: string; }; // category
tg?: { t: string; s: string; }[]; // tags
}

export interface IArticleIndex {
Expand Down

0 comments on commit da8aa71

Please sign in to comment.