MCPcopy Create free account
hub / github.com/Automattic/mongoose / wrapMarkdown

Function wrapMarkdown

scripts/website.js:355–393  ·  view source on GitHub ↗
(md, baseLayout, versionedPath, markdownUrl)

Source from the content-addressed store, hash-verified

353const generateLLMsTXT = require('./generateLLMsTXT');
354
355const wrapMarkdown = (md, baseLayout, versionedPath, markdownUrl) => {
356 const newlineIdx = md.indexOf('\n');
357 const firstLine = newlineIdx === -1 ? md : md.slice(0, newlineIdx);
358 const rest = newlineIdx === -1 ? '' : md.slice(newlineIdx + 1);
359
360 return `
361extends ${baseLayout}
362
363block content
364 .article-header
365 :markdown
366 ${firstLine}
367 <div class="doc-links">
368 <a class="edit-docs-link" href="#{editLink}" target="_blank">
369 <img src="${versionedPath}/docs/images/pencil.svg" />
370 </a>
371 <button class="copy-markdown-link" data-md-url="${markdownUrl}" title="Copy page as Markdown" aria-label="Copy page as Markdown">
372 <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
373 </button>
374 </div>
375 script.
376 (function() {
377 const copyMarkdownButton = document.querySelector('.copy-markdown-link');
378 if (copyMarkdownButton == null) {
379 return;
380 }
381
382 copyMarkdownButton.addEventListener('click', async function() {
383 const response = await fetch(copyMarkdownButton.dataset.mdUrl);
384 const markdown = await response.text();
385 await navigator.clipboard.writeText(markdown);
386 copyMarkdownButton.classList.add('copied');
387 setTimeout(() => copyMarkdownButton.classList.remove('copied'), 2000);
388 });
389 })();
390 :markdown
391${rest.split('\n').map(line => ' ' + line).join('\n')}
392`;
393};
394
395const cpc = `
396<div class="sponsored-ad">

Callers 1

renderFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected