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