Notes on engineering leadership and software development.
#frontend
Daily Notes
November 19th:
Daily TIL note from November 19th, 2023Contentlayer supports markdown and even MDX formatting in the frontmatter fields of your documents, as long as you specify the field type as
mdxormarkdown.The tricky part is that:
markdownfields give you raw HTML code. You'd have to wrap it in__dangerouslySetHTMLor something.mdxgives you the code that you have to pass intouseMDXComponentto render.- Either way, you have to decide where to allow markdown formatting and where to strip it.
I've just implemented it for the blog here:
- Posts lists gets new
PostDescriptioncomponent that renders MDX-processed post description. - Post metadata and RSS gets raw description, implemented in a little custom field on Contentlayer that strips formatting.
July 18th:
Daily TIL note from July 18th, 2023TIL there are
beforeprintandafterprintevents onwindowin Javascript, so you can manipulate the DOM to make the print version look nicer beyond what you can do with print styles in CSS.Especially helpful to hide a 3rd-party iframe (in our case, Intercom widget) that otherwise caused the printed page to overflow horizontally.