Skip to content

Commit c4a927b

Browse files
authored
Merge pull request #277 from gitcoinco/feat/workflows
update parse-issue for old templates
2 parents 1494a9e + 3da3b80 commit c4a927b

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

.github/workflows/publish-content.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
await github.rest.checks.create({
111111
owner: context.repo.owner,
112112
repo: context.repo.repo,
113-
name: 'Validate content / validate',
113+
name: 'validate',
114114
head_sha: '${{ steps.create-pr.outputs.pull-request-head-sha }}',
115115
status: 'completed',
116116
conclusion,

src/app/api/preview/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async function parseContentFile(filename: string, ref: string, headers: Record<s
9898
slug: data.slug,
9999
name: data.name,
100100
shortDescription: data.shortDescription ?? "",
101-
description: description.trim(),
101+
description: description?.trim() ?? "",
102102
banner: toRawUrl(data.banner, ref),
103103
logo: toRawUrl(data.logo, ref),
104104
tags: data.tags ?? [],

src/lib/parse-issue.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ function extractField(content: string, label: string): string {
106106
if (linkMatch) {
107107
return /url/i.test(label) ? linkMatch[2].trim() : linkMatch[1].trim();
108108
}
109-
return match[1].trim();
109+
// Strip backtick code spans
110+
return match[1].trim().replace(/^`(.*)`$/, "$1");
110111
}
111112

112113
function parseLegacyMetadata(markdown: string): IssueMetadata {
@@ -198,7 +199,7 @@ export function parseList(markdown: string, sectionName: string): string[] {
198199
line
199200
.replace(/^-\s*/, "") // strip leading "- " or "-"
200201
.split(",") // handle comma-separated values
201-
.map((s) => s.replace(/^`(.*)`$/, "$1").trim())
202+
.map((s) => s.replace(/^`(.*)`$/, "$1").replace(/^"(.*)"$/, "$1").trim())
202203
.filter((s) => s && s !== "-");
203204

204205
// Legacy format: bullet points (- slug)

src/lib/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export function cn(...inputs: ClassValue[]) {
55
return twMerge(clsx(inputs))
66
}
77

8-
export function calcReadTime(text: string): number {
8+
export function calcReadTime(text: string | undefined | null): number {
9+
if (!text) return 1;
910
const wordCount = text.trim().split(/\s+/).filter(Boolean).length;
1011
return Math.max(1, Math.ceil(wordCount / 265));
1112
}

0 commit comments

Comments
 (0)