MCPcopy Index your code
hub / github.com/tinymce/tinymce / generateDemoIndex

Function generateDemoIndex

modules/tinymce/rspack.config.js:15–53  ·  view source on GitHub ↗
(app)

Source from the content-addressed store, hash-verified

13})[m]);
14
15const generateDemoIndex = (app) => {
16 const demoList = fg.sync(['src/**/demo/html/*.html', 'src/**/demo/html/**/*.html'], { cwd: __dirname });
17 const sortedDemos = demoList.reduce((acc, link) => {
18 const type = link.split('/')[1];
19
20 if (!acc[type]) {
21 acc[type] = [];
22 }
23
24 acc[type].push(link);
25
26 return acc;
27 }, {});
28
29 const lists = Object.keys(sortedDemos).map(
30 type => `
31 <h2>${type}</h2>
32 <ul>
33 ${sortedDemos[type].map(link => `<li>${type !== 'core' ? `<strong>${escapeHtml(link.split('/')[2])}</strong> - ` : ''}<a href="${escapeHtml(link)}">${escapeHtml(path.basename(link))}</a></li>`).join('')
34 }
35 </ul>`
36 ).join('');
37 const html = `
38 <!DOCTYPE html>
39 <html lang="en">
40 <head>
41 <meta charset="UTF-8">
42 <meta name="viewport" content="width=device-width, initial-scale=1.0">
43 <meta http-equiv="X-UA-Compatible" content="ie=edge">
44 <title>Demos</title>
45 </head>
46 <body>
47 ${lists}
48 </body>
49 </html>
50 `;
51
52 app.get('/', (_, res) => res.send(html))
53};
54
55function create(entries, tsConfig, outDir = ".") {
56 const resolvedEntries = Object.fromEntries(Object.entries(entries).map(([k, v]) => [k, path.resolve(__dirname, v)]));

Callers 1

rspack.config.jsFile · 0.70

Calls 3

escapeHtmlFunction · 0.85
mapMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…