Initial scaffold: Expo SDK 56, expo-router, expo-sqlite, NativeWind
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import type { Incident } from "@/types/incident";
|
||||
|
||||
const DEFAULT_TEMPLATE = `# [TITRE]
|
||||
|
||||
**Date**: [DATE ISO]
|
||||
**Service**: [SERVICE]
|
||||
**Status**: [STATUS]
|
||||
**Tags**: [TAGS]
|
||||
|
||||
## Symptom
|
||||
[SYMPTOM]
|
||||
|
||||
## Root Cause
|
||||
[ROOT_CAUSE]
|
||||
|
||||
## Fix Applied
|
||||
[FIX]
|
||||
`;
|
||||
|
||||
export function renderMarkdown(
|
||||
incident: Incident,
|
||||
template: string = DEFAULT_TEMPLATE
|
||||
): string {
|
||||
const tagList =
|
||||
incident.tags.length > 0 ? incident.tags.join(", ") : "—";
|
||||
|
||||
return template
|
||||
.replace("[TITRE]", incident.title || "Untitled")
|
||||
.replace("[DATE ISO]", incident.createdAt)
|
||||
.replace("[SERVICE]", incident.service || "—")
|
||||
.replace("[STATUS]", incident.status)
|
||||
.replace("[TAGS]", tagList)
|
||||
.replace("[SYMPTOM]", incident.symptom || "—")
|
||||
.replace("[ROOT_CAUSE]", incident.rootCause || "—")
|
||||
.replace("[FIX]", incident.fix || "—");
|
||||
}
|
||||
|
||||
export function incidentToFilename(incident: Incident): string {
|
||||
const date = incident.createdAt.slice(0, 10);
|
||||
const slug = incident.title
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-|-$/g, "")
|
||||
.slice(0, 50);
|
||||
return `incidents/${date}-${slug || "incident"}.md`;
|
||||
}
|
||||
|
||||
export { DEFAULT_TEMPLATE };
|
||||
Reference in New Issue
Block a user