Keep draft notes off the How it works guide, link the conflict article, and print only the rule card.
This commit is contained in:
1 parent
453139c783
commit
95f7291c45
7 files changed
+136
-61
No files matched your search
+19
-7
@@ -2,6 +2,8 @@ import type howItWorksPage from "../messages/en/pages/howItWorks.json";
|
||||
|
||||
const HOW_IT_WORKS_WORDS_PER_MINUTE = 200;
|
||||
|
||||
export const HOW_IT_WORKS_RULE_CARD_ID = "how-it-works-rule-card";
|
||||
|
||||
type HowItWorksMessages = typeof howItWorksPage;
|
||||
|
||||
export type HowItWorksGuideBlock =
|
||||
@@ -14,8 +16,16 @@ const MARKDOWN_LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
|
||||
|
||||
export function asHowItWorksGuideBlock(
|
||||
block: HowItWorksMessages["sections"][number]["blocks"][number],
|
||||
): HowItWorksGuideBlock {
|
||||
return block as HowItWorksGuideBlock;
|
||||
): HowItWorksGuideBlock | null {
|
||||
switch (block.type) {
|
||||
case "p":
|
||||
case "figure":
|
||||
case "ruleFigure":
|
||||
case "shareRow":
|
||||
return block as HowItWorksGuideBlock;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function stripGuideMarkup(text: string): string {
|
||||
@@ -43,10 +53,10 @@ export function collectHowItWorksGuideText(page: HowItWorksMessages): string {
|
||||
const parts: string[] = [];
|
||||
for (const section of page.sections) {
|
||||
parts.push(section.heading);
|
||||
for (const block of section.blocks) {
|
||||
parts.push(
|
||||
blockPlainText(asHowItWorksGuideBlock(block), page.teamRule.caption),
|
||||
);
|
||||
for (const rawBlock of section.blocks) {
|
||||
const block = asHowItWorksGuideBlock(rawBlock);
|
||||
if (!block) continue;
|
||||
parts.push(blockPlainText(block, page.teamRule.caption));
|
||||
}
|
||||
}
|
||||
return stripGuideMarkup(parts.filter(Boolean).join(" "));
|
||||
@@ -74,10 +84,12 @@ export function formatHowItWorksByline(
|
||||
page: HowItWorksMessages,
|
||||
minutes: number,
|
||||
): string {
|
||||
const unit = minutes === 1 ? page.byline.minute : page.byline.minutes;
|
||||
return page.byline.template
|
||||
.replace("{author}", page.banner.author)
|
||||
.replace("{date}", formatHowItWorksDate(page.banner.date))
|
||||
.replace("{minutes}", String(minutes));
|
||||
.replace("{minutes}", String(minutes))
|
||||
.replace("{unit}", unit);
|
||||
}
|
||||
|
||||
export function howItWorksWikiMarkdown(
|
||||
|
||||
Reference in new issue
Block a user