` : "";
- let live = "";
- if (ex.run) {
- const target = ex.target != null ? `
${ex.target}
` : "";
- const mount = ex.noMount ? "" : ``;
- live = `
${target}${mount}
`;
- } else if (ex.html) {
- live = `
${ex.html}
`;
- }
-
let code = "";
if (ex.run) code = codeBlock(highlightJS(extractBody(ex.run)), "js");
else if (ex.html) code = codeBlock(highlightHTML(dedent(ex.html).trim()), "html");
@@ -167,10 +158,27 @@ function renderExample(ex, ids, captioned) {
}
// A fold is a toggle and a separate body (not one ), so a layout can set the toggle
- // in one place and open the code in another; site.js wires the button to the body.
+ // in one place and open the code in another; site.js wires the button to the body. In a run
+ // example the toggle sits inside the stage, between the demo and the panel, so the page's
+ // order (and so Tab's) matches a layout that shows it under the demo; the body follows the
+ // stage. hidden="until-found": closed, but find-in-page still reaches the code and opens it.
if (ex.foldCode && !ex.id) throw new Error(`example "${ex.title || "?"}": foldCode needs an id (the toggle points at its body by it)`);
- // hidden="until-found": closed, but find-in-page still reaches the code and opens it.
- if (code && ex.foldCode) code = `
${code}
`;
+ let toggle = "";
+ if (code && ex.foldCode) {
+ toggle = ``;
+ code = `
${code}
`;
+ }
+
+ let live = "";
+ if (ex.run) {
+ const target = ex.target != null ? `
${ex.target}
` : "";
+ const mount = ex.noMount ? "" : ``;
+ live = `
${target}${toggle}${mount}
`;
+ toggle = "";
+ } else if (ex.html) {
+ live = `
mount is the panel's slot inside the stage${ex.target != null ? "; target is the demo surface it controls" : ""}. In your own page you'd just document.body.append(panel.el).