feat: changelog style category and badge
This commit is contained in:
+18
-8
@@ -75,17 +75,27 @@ function truncate(text, maxLength = 80) {
|
||||
function extractCommits(events) {
|
||||
if (!Array.isArray(events)) return [];
|
||||
|
||||
// Style commit keywords
|
||||
const styleKeywords = [
|
||||
"style", "css", "tailwind", "design", "layout", "responsive", "dark mode", "typography", "color", "palette", "theme"
|
||||
];
|
||||
return events
|
||||
.filter((event) => event.type === "PushEvent")
|
||||
.flatMap((event) =>
|
||||
(event.payload?.commits || []).map((commit) => ({
|
||||
sha: commit.sha.slice(0, 7),
|
||||
message: truncate(commit.message.split("\n")[0]),
|
||||
url: `https://github.com/${event.repo.name}/commit/${commit.sha}`,
|
||||
repo: event.repo.name,
|
||||
repoUrl: `https://github.com/${event.repo.name}`,
|
||||
date: event.created_at,
|
||||
}))
|
||||
(event.payload?.commits || []).map((commit) => {
|
||||
const msg = commit.message.split("\n")[0];
|
||||
const lowerMsg = msg.toLowerCase();
|
||||
const isStyle = styleKeywords.some((kw) => lowerMsg.includes(kw));
|
||||
return {
|
||||
sha: commit.sha.slice(0, 7),
|
||||
message: truncate(msg),
|
||||
url: `https://github.com/${event.repo.name}/commit/${commit.sha}`,
|
||||
repo: event.repo.name,
|
||||
repoUrl: `https://github.com/${event.repo.name}`,
|
||||
date: event.created_at,
|
||||
category: isStyle ? "style" : undefined,
|
||||
};
|
||||
})
|
||||
)
|
||||
.slice(0, 10);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ function changelogApp() {
|
||||
{ key: 'performance', label: 'Performance' },
|
||||
{ key: 'accessibility', label: 'Accessibility' },
|
||||
{ key: 'documentation', label: 'Docs' },
|
||||
{ key: 'style', label: 'Style' },
|
||||
{ key: 'other', label: 'Other' },
|
||||
],
|
||||
|
||||
@@ -132,6 +133,7 @@ function changelogApp() {
|
||||
performance: 'Performance',
|
||||
accessibility: 'Accessibility',
|
||||
documentation: 'Docs',
|
||||
style: 'Style',
|
||||
other: 'Other',
|
||||
},
|
||||
|
||||
@@ -141,6 +143,7 @@ function changelogApp() {
|
||||
performance: 'bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300',
|
||||
accessibility: 'bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300',
|
||||
documentation: 'bg-yellow-100 dark:bg-yellow-900 text-yellow-700 dark:text-yellow-300',
|
||||
style: 'bg-pink-100 dark:bg-pink-900 text-pink-700 dark:text-pink-300',
|
||||
other: 'bg-surface-100 dark:bg-surface-800 text-surface-700 dark:text-surface-300',
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user