Notes on enginering leadership and software development.
#frontend
Daily Notes
November 19th:
Contentlayer supports markdown and even MDX formatting in the frontmatter fields of your documents, as long as you specify the field type as
mdx
ormarkdown
.The tricky part is that:
markdown
fields give you raw HTML code. You'd have to wrap it in__dangerouslySetHTML
or something.mdx
gives you the code that you have to pass intouseMDXComponent
to 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
PostDescription
component 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:
TIL there are
beforeprint
andafterprint
events onwindow
in 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.