forked from teles/awesome-seo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-readme.js
More file actions
48 lines (39 loc) · 1.49 KB
/
Copy pathparse-readme.js
File metadata and controls
48 lines (39 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const fs = require('fs');
// Read README.md
const readmeContent = fs.readFileSync('README.md', 'utf8');
// Parse the README content
const tools = [];
const lines = readmeContent.split('\n');
let currentCategory = '';
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
// Check for category headers (## **Category Name**)
if (line.startsWith('## **') && line.endsWith('**')) {
currentCategory = line.replace(/^## \*\*/, '').replace(/\*\*$/, '');
continue;
}
// Check for tool entries (- [Tool Name](url) - Description)
const toolMatch = line.match(/^- \[([^\]]+)\]\(([^)]+)\) - (.+)$/);
if (toolMatch && currentCategory && !currentCategory.includes('Articles')) {
const [, name, url, description] = toolMatch;
tools.push({
name: name.trim(),
url: url.trim(),
description: description.trim(),
category: currentCategory.trim()
});
}
}
// Create the JSON structure
const awesomeData = {
title: 'Awesome SEO',
description: 'A curated list of SEO tools',
lastUpdated: new Date().toISOString(),
totalTools: tools.length,
categories: [...new Set(tools.map(tool => tool.category))].sort(),
tools: tools.sort((a, b) => a.name.localeCompare(b.name))
};
// Write to docs/awesome.json
fs.writeFileSync('docs/awesome.json', JSON.stringify(awesomeData, null, 2));
console.log(`Generated awesome.json with ${tools.length} tools in ${awesomeData.categories.length} categories`);
console.log('Categories found:', awesomeData.categories);