Skip to content

Commit

Permalink
[blog] Fix missing card
Browse files Browse the repository at this point in the history
See how https://twitter.com/MUI_hq/status/1688919247504957440 doesn't have a card.
It's a follow-up on #38258.

I think that we should be able to fail the build if the card is missing, but too lazy.
  • Loading branch information
oliviertassinari committed Sep 6, 2023
1 parent da750ca commit b035471
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/pages/blog/discord-announcement.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tags: ['News']
card: true
---

<a href="https://mui.com/r/discord/"><img src="/static/blog/2023-discord-announcement/discord.png" width="1280" height="640" style="margin-bottom: 16px;" alt="Discord banner with link" /></a>
<a href="https://mui.com/r/discord/"><img src="/static/blog/discord-announcement/discord.png" width="1280" height="640" style="margin-bottom: 16px;" alt="Discord banner with link" /></a>

This year, one of our highest priorities has been to create a central hub for the MUI community.
Up until now, our community has been scattered across discussions and interactions on [Twitter](https://twitter.com/MUI_hq), [LinkedIn](https://linkedin.com/company/mui), [GitHub](https://github.com/mui), and [Stack Overflow](https://stackoverflow.com/questions/tagged/material-ui).
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions packages/markdown/parseMarkdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { marked } = require('marked');
const fs = require('fs');
const path = require('path');
const kebabCase = require('lodash/kebabCase');
const textToHash = require('./textToHash');
const prism = require('./prism');
Expand Down Expand Up @@ -675,6 +677,20 @@ ${headers.hooks
};
});

if (docs.en.headers.card) {
const slug = docs.en.location.replace(/\/docs\/pages\/blog\/(.*)\.md/, '$1');
const exists = fs.existsSync(
path.resolve(__dirname, `../../docs/public/static/blog/${slug}/card.png`),
);

if (!exists) {
throw new Error([
`MUI: the card image for the blog post "${slug}" is missing.`,
`Add a docs/public/static/blog/${slug}/card.png file then restart Next.js or remove card: true from the headers.`,
].join('\n'));
}
}

return { demos, docs };
}

Expand Down

0 comments on commit b035471

Please sign in to comment.