Download wp-calypso/client/lib/embed-frame-markup/index.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/embed-frame-markup/index.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/embed-frame-markup/index.jsx
-
curl -L -o index.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/embed-frame-markup/index.jsx
1.59 kB
| // Here be dragons... | |
| /* eslint-disable react/no-danger */ | |
| import { flatMap, map } from 'lodash'; | |
| import { renderToStaticMarkup } from 'react-dom/server.browser'; | |
| /** | |
| * Constants | |
| */ | |
| const JQUERY_URL = 'https://s0.wp.com/wp-includes/js/jquery/jquery.js'; | |
| export default function generateEmbedFrameMarkup( { body, scripts, styles } = {} ) { | |
| if ( ! body && ! scripts && ! styles ) { | |
| return ''; | |
| } | |
| return renderToStaticMarkup( | |
| // eslint-disable-next-line jsx-a11y/html-has-lang -- this is an embed frame, not the main document. | |
| <html> | |
| <head> | |
| { map( styles, ( { media, src }, key ) => ( | |
| <link key={ key } rel="stylesheet" media={ media } href={ src } /> | |
| ) ) } | |
| <style dangerouslySetInnerHTML={ { __html: 'a { cursor: default; }' } } /> | |
| </head> | |
| <body style={ { margin: 0 } }> | |
| <div dangerouslySetInnerHTML={ { __html: body } } /> | |
| { /* Many embed/shortcode scripts assume jQuery is already defined */ } | |
| <script src={ JQUERY_URL } /> | |
| ); | |
| } | |