Replace the Four Pillars page with the Guide to CommunityRule on the Content page Template.
This commit is contained in:
1 parent
bf9ee79c9f
commit
453139c783
17 files changed
+1005
-32
No files matched your search
@@ -122,6 +122,11 @@ export function featurePanelPath(key: FeaturePanelKey): string {
|
||||
return `assets/marketing/feature-${key}.svg`;
|
||||
}
|
||||
|
||||
/** Flow-screen figures on `/how-it-works`. */
|
||||
export function howItWorksFigureAssetPath(slug: string): string {
|
||||
return `assets/marketing/how-it-works/${slug}.png`;
|
||||
}
|
||||
|
||||
/** Feature-grid card glyphs in `public/assets/icons/` (Figma **18632:10668**). */
|
||||
export type FeatureIconKey =
|
||||
| "git-branch"
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import type howItWorksPage from "../messages/en/pages/howItWorks.json";
|
||||
|
||||
const HOW_IT_WORKS_WORDS_PER_MINUTE = 200;
|
||||
|
||||
type HowItWorksMessages = typeof howItWorksPage;
|
||||
|
||||
export type HowItWorksGuideBlock =
|
||||
| { type: "p"; lead?: string; text: string }
|
||||
| { type: "figure"; src: string; caption: string }
|
||||
| { type: "ruleFigure" }
|
||||
| { type: "shareRow" };
|
||||
|
||||
const MARKDOWN_LINK = /\[([^\]]+)\]\(([^)]+)\)/g;
|
||||
|
||||
export function asHowItWorksGuideBlock(
|
||||
block: HowItWorksMessages["sections"][number]["blocks"][number],
|
||||
): HowItWorksGuideBlock {
|
||||
return block as HowItWorksGuideBlock;
|
||||
}
|
||||
|
||||
export function stripGuideMarkup(text: string): string {
|
||||
return text.replace(MARKDOWN_LINK, "$1");
|
||||
}
|
||||
|
||||
function blockPlainText(
|
||||
block: HowItWorksGuideBlock,
|
||||
caption: string,
|
||||
): string {
|
||||
if (block.type === "p") {
|
||||
return [block.lead, block.text].filter(Boolean).join(" ");
|
||||
}
|
||||
if (block.type === "figure") {
|
||||
return block.caption;
|
||||
}
|
||||
if (block.type === "ruleFigure") {
|
||||
return caption;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/** Visible guide copy used to set the byline read time. */
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
return stripGuideMarkup(parts.filter(Boolean).join(" "));
|
||||
}
|
||||
|
||||
export function howItWorksReadMinutes(page: HowItWorksMessages): number {
|
||||
const words = collectHowItWorksGuideText(page)
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.filter(Boolean).length;
|
||||
return Math.max(1, Math.round(words / HOW_IT_WORKS_WORDS_PER_MINUTE));
|
||||
}
|
||||
|
||||
export function formatHowItWorksDate(isoDate: string): string {
|
||||
const date = new Date(`${isoDate}T00:00:00Z`);
|
||||
return new Intl.DateTimeFormat("en-GB", {
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
timeZone: "UTC",
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
export function formatHowItWorksByline(
|
||||
page: HowItWorksMessages,
|
||||
minutes: number,
|
||||
): string {
|
||||
return page.byline.template
|
||||
.replace("{author}", page.banner.author)
|
||||
.replace("{date}", formatHowItWorksDate(page.banner.date))
|
||||
.replace("{minutes}", String(minutes));
|
||||
}
|
||||
|
||||
export function howItWorksWikiMarkdown(
|
||||
title: string,
|
||||
description: string,
|
||||
url: string,
|
||||
): string {
|
||||
return `[${title}](${url})\n\n${description}`;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { BlogPost } from "./content";
|
||||
import { markdownToHtml } from "./content";
|
||||
import type howItWorksPage from "../messages/en/pages/howItWorks.json";
|
||||
|
||||
export const HOW_IT_WORKS_SENTINEL_SLUG = "__how-it-works__";
|
||||
@@ -8,12 +7,12 @@ type HowItWorksMessages = typeof howItWorksPage;
|
||||
|
||||
/**
|
||||
* Builds a {@link BlogPost}-shaped object for static marketing pages that reuse
|
||||
* blog article chrome (`ContentBanner`, `.post-body`) without a markdown file.
|
||||
* blog article chrome (`ContentBanner`) without a markdown file.
|
||||
*/
|
||||
export function buildHowItWorksSyntheticPost(
|
||||
page: HowItWorksMessages,
|
||||
): BlogPost {
|
||||
const { banner, bodyMarkdown } = page;
|
||||
const { banner } = page;
|
||||
|
||||
return {
|
||||
slug: HOW_IT_WORKS_SENTINEL_SLUG,
|
||||
@@ -23,8 +22,8 @@ export function buildHowItWorksSyntheticPost(
|
||||
author: banner.author,
|
||||
date: banner.date,
|
||||
},
|
||||
content: bodyMarkdown,
|
||||
htmlContent: markdownToHtml(bodyMarkdown),
|
||||
content: "",
|
||||
htmlContent: "",
|
||||
filePath: "messages/en/pages/howItWorks.json",
|
||||
lastModified: new Date(banner.date),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user