Remove unnecessary props and data structure

This commit is contained in:
adilallo
2025-09-05 08:09:44 -06:00
parent fc096129dd
commit 93182e6c2d
8 changed files with 21 additions and 279 deletions
-36
View File
@@ -24,8 +24,6 @@ export function processMarkdown(markdown) {
return {
content: "",
htmlContent: "",
wordCount: 0,
readingTime: 0,
headings: [],
links: [],
images: [],
@@ -41,18 +39,12 @@ export function processMarkdown(markdown) {
// Extract images
const images = extractImages(markdown);
// Calculate word count and reading time
const wordCount = calculateWordCount(markdown);
const readingTime = calculateReadingTime(wordCount);
// Convert markdown to HTML
const htmlContent = markdownToHtml(markdown);
return {
content: markdown,
htmlContent,
wordCount,
readingTime,
headings,
links,
images,
@@ -141,31 +133,6 @@ function generateHeadingId(text) {
.trim();
}
/**
* Calculate word count from markdown content
* @param {string} markdown - Raw markdown content
* @returns {number} Word count
*/
function calculateWordCount(markdown) {
// Remove markdown syntax and count words
const cleanText = markdown
.replace(/[#*`~\[\]()]/g, "") // Remove markdown characters
.replace(/\n+/g, " ") // Replace newlines with spaces
.trim();
return cleanText.split(/\s+/).filter((word) => word.length > 0).length;
}
/**
* Calculate estimated reading time
* @param {number} wordCount - Number of words
* @returns {number} Reading time in minutes
*/
function calculateReadingTime(wordCount) {
const wordsPerMinute = 200; // Average reading speed
return Math.ceil(wordCount / wordsPerMinute);
}
/**
* Convert markdown to HTML with enhanced formatting
* @param {string} markdown - Raw markdown content
@@ -255,9 +222,6 @@ export function processFrontmatter(frontmatter) {
month: new Date(frontmatter.date).getMonth() + 1,
day: new Date(frontmatter.date).getDate(),
isRecent: isRecentPost(frontmatter.date),
readingTime: frontmatter.content
? calculateReadingTime(calculateWordCount(frontmatter.content))
: 0,
};
return processed;