Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nx-dev): allow custom media images #20561

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions scripts/documentation/map-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"type": "string",
"description": "Description for the item"
},
"mediaImage": {
"type": "string",
"description": "Path to an alternate open graph image, relative to /docs"
},
"file": {
"type": "string",
"description": "Path to the markdown file"
Expand Down
18 changes: 14 additions & 4 deletions scripts/documentation/open-graph/generate-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ const targetFolder: string = resolve(
`./nx-dev/nx-dev/public/images/open-graph`
);

const data: { title: string; content: string; filename: string }[] = [];
const data: {
title: string;
content: string;
mediaImage?: string;
filename: string;
}[] = [];
documents.forEach((category) => {
data.push({
title: category.name,
Expand All @@ -46,6 +51,7 @@ documents.forEach((category) => {
data.push({
title: item.name,
content: item.description || category.name,
mediaImage: item.mediaImage,
filename: [category.sidebarId, category.id, item.id]
.filter(Boolean)
.join('-'),
Expand All @@ -54,6 +60,7 @@ documents.forEach((category) => {
data.push({
title: subItem.name,
content: subItem.description || category.name,
mediaImage: item.mediaImage,
filename: [category.sidebarId, category.id, item.id, subItem.id]
.filter(Boolean)
.join('-'),
Expand Down Expand Up @@ -181,10 +188,13 @@ console.log(
ensureDir(targetFolder).then(() =>
data.map((item) =>
createOpenGraphImage(
resolve(__dirname, './media.jpg'),
resolve(
__dirname,
item.mediaImage ? '../../../docs/' + item.mediaImage : './media.jpg'
),
targetFolder,
item.title,
item.content,
item.mediaImage ? '' : item.title,
isaacplmann marked this conversation as resolved.
Show resolved Hide resolved
item.mediaImage ? '' : item.content,
item.filename
)
)
Expand Down