Add id to posts
This commit is contained in:
@ -31,7 +31,7 @@ export const findPostsByIds = async (ids) => {
|
|||||||
|
|
||||||
return ids.reduce(function (r, id) {
|
return ids.reduce(function (r, id) {
|
||||||
posts.some(function (post) {
|
posts.some(function (post) {
|
||||||
return id === post.ID && r.push(post);
|
return id === post.id && r.push(post);
|
||||||
});
|
});
|
||||||
return r;
|
return r;
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -2,13 +2,16 @@ import getReadingTime from "reading-time";
|
|||||||
|
|
||||||
export const getNormalizedPost = async (post) => {
|
export const getNormalizedPost = async (post) => {
|
||||||
const { frontmatter, compiledContent, rawContent, file } = post;
|
const { frontmatter, compiledContent, rawContent, file } = post;
|
||||||
|
const ID = file.split("/").pop().split(".").shift();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
id: ID,
|
||||||
|
|
||||||
pubDate: frontmatter.pubDate,
|
pubDate: frontmatter.pubDate,
|
||||||
draft: frontmatter.draft,
|
draft: frontmatter.draft,
|
||||||
|
|
||||||
canonical: frontmatter.canonical,
|
canonical: frontmatter.canonical,
|
||||||
slug: file.split("/").pop().split(".").shift(),
|
slug: frontmatter.slug || ID,
|
||||||
|
|
||||||
title: frontmatter.title,
|
title: frontmatter.title,
|
||||||
description: frontmatter.description,
|
description: frontmatter.description,
|
||||||
|
Reference in New Issue
Block a user