Fix SandpackWithHTMLOutput to use src dir (#6613)

This commit is contained in:
Matt Carroll
2024-02-06 09:36:18 -08:00
committed by GitHub
parent 47c818c479
commit c118938237
6 changed files with 13 additions and 13 deletions

View File

@@ -20,7 +20,7 @@ export default function ShowRenderedHTML({children}) {
{formatHTML(markup)}
</pre>
</>
);
);
}`;
const formatHTML = `
@@ -77,8 +77,8 @@ export default memo(function SandpackWithHTMLOutput(
) {
const children = [
...Children.toArray(props.children),
createFile('ShowRenderedHTML.js', ShowRenderedHTML),
createFile('formatHTML.js hidden', formatHTML),
createFile('src/ShowRenderedHTML.js', ShowRenderedHTML),
createFile('src/formatHTML.js hidden', formatHTML),
createFile('package.json hidden', packageJSON),
];
return <Sandpack {...props}>{children}</Sandpack>;

View File

@@ -96,7 +96,7 @@ In addition, if the `<link>` is to a stylesheet (namely, it has `rel="stylesheet
There are two exception to this special behavior:
* If the link doesn't have a `precedence` prop, there is no special behavior, because the order of stylesheets within the document is significant, so React needs to know how to order this stylesheet relative to others, which you specify using the `precedence` prop.
* If the link doesn't have a `precedence` prop, there is no special behavior, because the order of stylesheets within the document is significant, so React needs to know how to order this stylesheet relative to others, which you specify using the `precedence` prop.
* If you supply any of the `onLoad`, `onError`, or `disabled` props, there is no special behavior, because these props indicate that you are managing the loading of the stylesheet manually within your component.
This special treatment comes with two caveats:
@@ -114,7 +114,7 @@ You can annotate the document with links to related resources such as an icon, c
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
export default function BlogPage() {
@@ -141,7 +141,7 @@ When you want to use a stylesheet, it can be beneficial to call the [preinit](/r
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
export default function SiteMapPage() {
@@ -164,7 +164,7 @@ Stylesheets can conflict with each other, and when they do, the browser goes wit
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
export default function HomePage() {
@@ -195,7 +195,7 @@ If you render the same stylesheet from multiple components, React will place onl
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
export default function HomePage() {

View File

@@ -72,7 +72,7 @@ You can render the `<meta>` component from any component. React will put a `<met
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
export default function SiteMapPage() {

View File

@@ -91,7 +91,7 @@ If you supply an `src` and `async` prop, your component will suspend while the s
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
function Map({lat, long}) {
@@ -124,7 +124,7 @@ To include an inline script, render the `<script>` component with the script sou
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
function Tracking() {

View File

@@ -73,7 +73,7 @@ If you supply an `href` and `precedence` prop, your component will suspend while
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
import { useId } from 'react';

View File

@@ -66,7 +66,7 @@ Render the `<title>` component from any component with text as its children. Rea
<SandpackWithHTMLOutput>
```js App.js active
```js src/App.js active
import ShowRenderedHTML from './ShowRenderedHTML.js';
export default function ContactUsPage() {