Skip to content

Commit

Permalink
refactor(contentlayer): use our own topics index
Browse files Browse the repository at this point in the history
- start using our own topics index instead of optech's
- add different display option for misc topics in categories
  • Loading branch information
kouloumos committed Nov 29, 2024
1 parent e88a353 commit b03cd26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,23 @@ function generateCategorizedList(processedTopics: Map<string, ProcessedTopic>):
if (!categorizedTopics[category]) {
categorizedTopics[category] = [];
}
categorizedTopics[category].push({ name, slug, count });

// Check if topic name contains category name and ends with "(Miscellaneous)"
const modifiedName = name.includes(category) && name.endsWith("(Miscellaneous)")
? "Miscellaneous"
: name;

categorizedTopics[category].push({ name: modifiedName, slug, count });
});
});

// Sort topics within each category
Object.values(categorizedTopics).forEach(topics => {
topics.sort((a, b) => a.name.localeCompare(b.name));
topics.sort((a, b) => {
if (a.name == "Miscellaneous") return 1;
if (b.name == "Miscellaneous") return -1;
return a.name.localeCompare(b.name)
});
});

return categorizedTopics;
Expand Down
2 changes: 1 addition & 1 deletion scripts/fetchTopics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require("fs");
const path = require("path");
const https = require("https");

const url = "https://bitcoinops.org/topics.json";
const url = "https://raw.githubusercontent.com/bitcoinsearch/topics-index/refs/heads/main/topics.json";
const outputPath = path.join(__dirname, "..", "public", "topics.json");

https
Expand Down

0 comments on commit b03cd26

Please sign in to comment.