MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / concatHtml

Function concatHtml

packages/challenge-builder/src/builders.ts:10–36  ·  view source on GitHub ↗
({
  required = [],
  template,
  contents
}: ConcatHTMLOptions)

Source from the content-addressed store, hash-verified

8}
9
10export function concatHtml({
11 required = [],
12 template,
13 contents
14}: ConcatHTMLOptions): string {
15 const embedSource = template
16 ? _template(template)
17 : ({ source }: { source: ConcatHTMLOptions['contents'] }) => source;
18 const head = required
19 .map(({ link, src }) => {
20 if (link && src) {
21 throw new Error(`
22A required file can not have both a src and a link: src = ${src}, link = ${link}
23`);
24 }
25 if (src) {
26 return `<script src='${src}' type='text/javascript'></script>`;
27 }
28 if (link) {
29 return `<link href='${link}' rel='stylesheet' />`;
30 }
31 return '';
32 })
33 .join('\n');
34
35 return `<head>${head}</head>${embedSource({ source: contents }) || ''}`;
36}
37
38export function createPythonTerminal(pythonRunnerSrc: string): string {
39 const head =

Callers 1

buildDOMChallengeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected