Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions skillmap/src/lib/skillMapParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ function buildMapFromSections(header: MarkdownSection, sections: MarkdownSection
function inflateSkillMap(section: MarkdownSection): Partial<SkillMap> {
const result: Partial<SkillMap> = {
mapId: section.header.toLowerCase(),
displayName: section.attributes["name"] || section.header,
description: section.attributes["description"],
displayName: section.attributes["name"] || getCodeBlock(section, "name") || section.header,
description: section.attributes["description"] || getCodeBlock(section, "description"),
completionUrl: section.attributes["completionurl"],
prerequisites: [],
activities: {},
Expand Down Expand Up @@ -135,7 +135,7 @@ function inflateMapNode(section: MarkdownSection): MapNode {
activityId: section.header.toLowerCase(),
imageUrl: section.attributes["imageurl"],
next: [],
displayName: section.attributes["name"] || section.header,
displayName: section.attributes["name"] || getCodeBlock(section, "name") || section.header,
nextIds: parseList(section.attributes["next"])
}

Expand Down Expand Up @@ -309,7 +309,7 @@ function inflateActivity(section: MarkdownSection, base: Partial<MapActivity>):
const result: Partial<MapActivity> = {
...base,
kind: "activity",
description: section.attributes["description"],
description: section.attributes["description"] || getCodeBlock(section, "description"),
url: section.attributes["url"],
tags: parseList(section.attributes["tags"]),
// defaults to true
Expand Down Expand Up @@ -384,11 +384,11 @@ function inflateMetadata(section: MarkdownSection): PageMetadata {
const lockedNodeColor = section.attributes["lockednodecolor"];
const completedNodeColor = section.attributes["completednodecolor"];

const introductoryModal = section.codeBlocks?.find(b => b.languageCode === "intro");
const introductoryModal = getCodeBlock(section, "intro");

return {
title: section.attributes["name"] || section.header,
description: section.attributes["description"],
title: section.attributes["name"] || getCodeBlock(section, "name") || section.header,
description: section.attributes["description"] || getCodeBlock(section, "description"),
infoUrl: cleanInfoUrl(section.attributes["infourl"]),
backgroundImageUrl: section.attributes["backgroundurl"],
pixelatedBackground: isTrue(section.attributes["pixelatedbackground"]),
Expand All @@ -411,10 +411,14 @@ function inflateMetadata(section: MarkdownSection): PageMetadata {
selectedStrokeColor: highlight || "var(--pxt-primary-background)",
pathOpacity: 0.5,
},
introductoryModal: introductoryModal?.content
introductoryModal
}
}

function getCodeBlock(section: MarkdownSection, languageCode: string): string | undefined {
return section.codeBlocks?.find(b => b.languageCode === languageCode)?.content?.trim();
}

function getContrastingColor(color: string) {
color = color.replace("#", "");
const r = Number.parseInt(color.slice(0, 2), 16);
Expand Down
Loading