mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-27 03:08:06 +00:00
Update team pages (#5329)
* [wip] update team page * Update old site and alumni * Add more team members * Update old page too * Shrink images * Add remaining people on updated team pages (#5327) * updates * remove active members from acknowledgements * mobile styles for social/links * update jason image * clarify Jasons role * image alt text * Move all content into <TeamMember> incl headers * icon for personal site links * update TOC to extract beyond top-level elements * cleanup * github link should...point to github. oops * this can no longer be described as a small team * Update beta/src/content/learn/meet-the-team.md * Update content/community/team.md Co-authored-by: Sathya Gunasekaran <gsathya.ceg@gmail.com> Co-authored-by: Rick Hanlon <rickhanlonii@fb.com> Co-authored-by: lauren <poteto@users.noreply.github.com> Co-authored-by: Sathya Gunasekaran <gsathya.ceg@gmail.com>
This commit is contained in:
@@ -12,7 +12,7 @@ export const PREPARE_MDX_CACHE_BREAKER = 2;
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export function prepareMDX(rawChildren) {
|
||||
const toc = getTableOfContents(rawChildren);
|
||||
const toc = getTableOfContents(rawChildren, /* depth */ 10);
|
||||
const children = wrapChildrenInMaxWidthContainers(rawChildren);
|
||||
return {toc, children};
|
||||
}
|
||||
@@ -59,35 +59,9 @@ function wrapChildrenInMaxWidthContainers(children) {
|
||||
return finalChildren;
|
||||
}
|
||||
|
||||
function getTableOfContents(children) {
|
||||
const anchors = Children.toArray(children)
|
||||
.filter((child) => {
|
||||
if (child.type) {
|
||||
return ['h1', 'h2', 'h3', 'Challenges', 'Recap'].includes(child.type);
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.map((child) => {
|
||||
if (child.type === 'Challenges') {
|
||||
return {
|
||||
url: '#challenges',
|
||||
depth: 2,
|
||||
text: 'Challenges',
|
||||
};
|
||||
}
|
||||
if (child.type === 'Recap') {
|
||||
return {
|
||||
url: '#recap',
|
||||
depth: 2,
|
||||
text: 'Recap',
|
||||
};
|
||||
}
|
||||
return {
|
||||
url: '#' + child.props.id,
|
||||
depth: (child.type && parseInt(child.type.replace('h', ''), 0)) ?? 0,
|
||||
text: child.props.children,
|
||||
};
|
||||
});
|
||||
function getTableOfContents(children, depth) {
|
||||
const anchors = [];
|
||||
extractHeaders(children, depth, anchors);
|
||||
if (anchors.length > 0) {
|
||||
anchors.unshift({
|
||||
url: '#',
|
||||
@@ -97,3 +71,47 @@ function getTableOfContents(children) {
|
||||
}
|
||||
return anchors;
|
||||
}
|
||||
|
||||
const headerTypes = new Set([
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'Challenges',
|
||||
'Recap',
|
||||
'TeamMember',
|
||||
]);
|
||||
function extractHeaders(children, depth, out) {
|
||||
for (const child of Children.toArray(children)) {
|
||||
if (child.type && headerTypes.has(child.type)) {
|
||||
let header;
|
||||
if (child.type === 'Challenges') {
|
||||
header = {
|
||||
url: '#challenges',
|
||||
depth: 2,
|
||||
text: 'Challenges',
|
||||
};
|
||||
} else if (child.type === 'Recap') {
|
||||
header = {
|
||||
url: '#recap',
|
||||
depth: 2,
|
||||
text: 'Recap',
|
||||
};
|
||||
} else if (child.type === 'TeamMember') {
|
||||
header = {
|
||||
url: '#' + child.props.permalink,
|
||||
depth: 3,
|
||||
text: child.props.name,
|
||||
};
|
||||
} else {
|
||||
header = {
|
||||
url: '#' + child.props.id,
|
||||
depth: (child.type && parseInt(child.type.replace('h', ''), 0)) ?? 0,
|
||||
text: child.props.children,
|
||||
};
|
||||
}
|
||||
out.push(header);
|
||||
} else if (child.children && depth > 0) {
|
||||
extractHeaders(child.children, depth - 1, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user