edit_and_feedback.js 1.76 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
 * edit_and_feedback.js
 *
 * Enhances MkDocs Material docs pages by:
 *
 * 1. Adding a "Question? Give us feedback" link
 *    below the "Edit" button.
 *
 *    - The link opens a GitHub issue with a template,
 *      auto-filled with the current page URL and path.
 *
 * 2. Ensuring the edit button opens in a new tab
 *    with target="_blank" and rel="noopener".
 */
document.addEventListener("DOMContentLoaded", function () {
    const url = window.location.href;
    const page = document.body.dataset.mdUrl || location.pathname;

    const feedbackLink = document.createElement("a");
    feedbackLink.href = `https://github.com/vllm-project/vllm-omni/issues/new?template=100-documentation.yml&title=${encodeURIComponent(
      `[Docs] Feedback for \`${page}\``
    )}&body=${encodeURIComponent(`📄 **Reference:**\n${url}\n\n📝 **Feedback:**\n_Your response_`)}`;
    feedbackLink.target = "_blank";
    feedbackLink.rel = "noopener";
    feedbackLink.title = "Provide feedback";
    feedbackLink.className = "md-content__button";
    feedbackLink.innerHTML = `
    <svg
      xmlns="http://www.w3.org/2000/svg"
      height="24px"
      viewBox="0 -960 960 960"
      width="24px"
      fill="currentColor"
    >
      <path d="M280-280h280v-80H280v80Zm0-160h400v-80H280v80Zm0-160h400v-80H280v80Zm-80 480q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z"/>
    </svg>
  `;

    const editButton = document.querySelector('.md-content__button[href*="edit"]');

    if (editButton && editButton.parentNode) {
      editButton.insertAdjacentElement("beforebegin", feedbackLink);

      editButton.setAttribute("target", "_blank");
      editButton.setAttribute("rel", "noopener");
    }
  });