From 3890ae7c10d162e3ad2655d324aa8099732b1e27 Mon Sep 17 00:00:00 2001 From: Luan Argolo Lemos Date: Thu, 26 Dec 2024 18:46:10 -0300 Subject: [PATCH] feat(blog): expose unique identifier --- blog/types.ts | 2 ++ blog/utils/records.ts | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/blog/types.ts b/blog/types.ts index 222b953e0..a8d89127f 100644 --- a/blog/types.ts +++ b/blog/types.ts @@ -58,6 +58,8 @@ export interface BlogPost { * @title Extra Props */ extraProps?: ExtraProps[]; + /** @hide true */ + id: string; } export interface ExtraProps { diff --git a/blog/utils/records.ts b/blog/utils/records.ts index 6e19e463b..e65890417 100644 --- a/blog/utils/records.ts +++ b/blog/utils/records.ts @@ -11,5 +11,11 @@ export async function getRecordsByPath( const current = Object.entries(resolvables).flatMap(([key, value]) => { return key.startsWith(path) ? value : []; }); - return (current as Record[]).map((item) => item[accessor]); + return (current as Record[]).map((item) => { + const id = (item.name as string).split(path)[1]?.replace("/", ""); + return { + ...item[accessor], + id, + }; + }); }