Skip to content

Commit

Permalink
feat(blog): expose unique identifier (#983)
Browse files Browse the repository at this point in the history
* feat(blog): expose unique identifier

* feat(blog): define id prop to optional
  • Loading branch information
luanargolodev authored Jan 6, 2025
1 parent c1754b7 commit 6a28504
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions blog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export interface BlogPost {
* @title Extra Props
*/
extraProps?: ExtraProps[];
/** @hide true */
id?: string;
}

export interface ExtraProps {
Expand Down
8 changes: 7 additions & 1 deletion blog/utils/records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ export async function getRecordsByPath<T>(
const current = Object.entries(resolvables).flatMap(([key, value]) => {
return key.startsWith(path) ? value : [];
});
return (current as Record<string, T>[]).map((item) => item[accessor]);
return (current as Record<string, T>[]).map((item) => {
const id = (item.name as string).split(path)[1]?.replace("/", "");
return {
...item[accessor],
id,
};
});
}

0 comments on commit 6a28504

Please sign in to comment.