mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-23 11:55:12 +00:00
refactor(website): convert to ES modules with TypeScript
- Replace all inline scripts with TypeScript modules - Create page-specific modules for agents, prompts, instructions, skills, collections, index - Create core modules: utils.ts, search.ts, modal.ts, choices.ts, jszip.ts, theme.ts - Remove window global exports, use proper ES module imports - Add type interfaces for all data structures - Use data-base-path attribute on body for base URL handling - Bundle Choices.js and JSZip via npm instead of CDN - Astro pages now just have single script import each
This commit is contained in:
24
website-astro/dist/assets/agents.astro_astro_type_script_index_0_lang.j8PeQ7-7.js
vendored
Normal file
24
website-astro/dist/assets/agents.astro_astro_type_script_index_0_lang.j8PeQ7-7.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import{c as m,g}from"./choices.CFbCQwHQ.js";import{f as v,F as y,d as E,s as I,e as c,g as $,o as H}from"./modal.5jZNQ_ZW.js";const b="agent";let u=[],h=new y,i,f,s={models:[],tools:[],hasHandoffs:!1};function r(){const a=document.getElementById("search-input"),o=document.getElementById("results-count"),l=a?.value||"";let e=l?h.search(l):[...u];s.models.length>0&&(e=e.filter(d=>s.models.includes("(none)")&&!d.model?!0:d.model&&s.models.includes(d.model))),s.tools.length>0&&(e=e.filter(d=>d.tools?.some(p=>s.tools.includes(p)))),s.hasHandoffs&&(e=e.filter(d=>d.hasHandoffs)),L(e,l);const t=[];s.models.length>0&&t.push(`models: ${s.models.length}`),s.tools.length>0&&t.push(`tools: ${s.tools.length}`),s.hasHandoffs&&t.push("has handoffs");let n=`${e.length} of ${u.length} agents`;t.length>0&&(n+=` (filtered by ${t.join(", ")})`),o&&(o.textContent=n)}function L(a,o=""){const l=document.getElementById("resource-list");if(l){if(a.length===0){l.innerHTML=`
|
||||
<div class="empty-state">
|
||||
<h3>No agents found</h3>
|
||||
<p>Try a different search term or adjust filters</p>
|
||||
</div>
|
||||
`;return}l.innerHTML=a.map(e=>`
|
||||
<div class="resource-item" data-path="${c(e.path)}">
|
||||
<div class="resource-info">
|
||||
<div class="resource-title">${o?h.highlight(e.title,o):c(e.title)}</div>
|
||||
<div class="resource-description">${c(e.description||"No description")}</div>
|
||||
<div class="resource-meta">
|
||||
${e.model?`<span class="resource-tag tag-model">${c(e.model)}</span>`:""}
|
||||
${e.tools?.slice(0,3).map(t=>`<span class="resource-tag">${c(t)}</span>`).join("")||""}
|
||||
${e.tools&&e.tools.length>3?`<span class="resource-tag">+${e.tools.length-3} more</span>`:""}
|
||||
${e.hasHandoffs?'<span class="resource-tag tag-handoffs">handoffs</span>':""}
|
||||
</div>
|
||||
</div>
|
||||
<div class="resource-actions">
|
||||
<a href="${$(e.path)}" class="btn btn-secondary" target="_blank" onclick="event.stopPropagation()">
|
||||
View on GitHub
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
`).join(""),l.querySelectorAll(".resource-item").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.path;t&&H(t,b)})})}}async function B(){const a=document.getElementById("resource-list"),o=document.getElementById("search-input"),l=document.getElementById("filter-handoffs"),e=document.getElementById("clear-filters"),t=await v("agents.json");if(!t||!t.items){a&&(a.innerHTML='<div class="empty-state"><h3>Failed to load data</h3></div>');return}u=t.items,h.setItems(u),i=m("#filter-model",{placeholderValue:"All Models"}),i.setChoices(t.filters.models.map(n=>({value:n,label:n})),"value","label",!0),document.getElementById("filter-model")?.addEventListener("change",()=>{s.models=g(i),r()}),f=m("#filter-tool",{placeholderValue:"All Tools"}),f.setChoices(t.filters.tools.map(n=>({value:n,label:n})),"value","label",!0),document.getElementById("filter-tool")?.addEventListener("change",()=>{s.tools=g(f),r()}),r(),o?.addEventListener("input",E(()=>r(),200)),l?.addEventListener("change",()=>{s.hasHandoffs=l.checked,r()}),e?.addEventListener("click",()=>{s={models:[],tools:[],hasHandoffs:!1},i.removeActiveItems(),f.removeActiveItems(),l&&(l.checked=!1),o&&(o.value=""),r()}),I()}document.addEventListener("DOMContentLoaded",B);
|
||||
1
website-astro/dist/assets/choices.Bblnwawv.css
vendored
Normal file
1
website-astro/dist/assets/choices.Bblnwawv.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
website-astro/dist/assets/choices.CFbCQwHQ.js
vendored
Normal file
1
website-astro/dist/assets/choices.CFbCQwHQ.js
vendored
Normal file
File diff suppressed because one or more lines are too long
16
website-astro/dist/assets/collections.astro_astro_type_script_index_0_lang.RqMV88cF.js
vendored
Normal file
16
website-astro/dist/assets/collections.astro_astro_type_script_index_0_lang.RqMV88cF.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import{c as h,g as p}from"./choices.CFbCQwHQ.js";import{f as m,F as v,d as y,s as $,e as i,g as E,o as I}from"./modal.5jZNQ_ZW.js";const L="collection";let u=[],g=new v,d,n={tags:[],featured:!1};function l(){const r=document.getElementById("search-input"),c=document.getElementById("results-count"),s=r?.value||"";let e=s?g.search(s):[...u];n.tags.length>0&&(e=e.filter(a=>a.tags?.some(f=>n.tags.includes(f)))),n.featured&&(e=e.filter(a=>a.featured)),b(e,s);const t=[];n.tags.length>0&&t.push(`${n.tags.length} tag${n.tags.length>1?"s":""}`),n.featured&&t.push("featured");let o=`${e.length} of ${u.length} collections`;t.length>0&&(o+=` (filtered by ${t.join(", ")})`),c&&(c.textContent=o)}function b(r,c=""){const s=document.getElementById("resource-list");if(s){if(r.length===0){s.innerHTML='<div class="empty-state"><h3>No collections found</h3><p>Try a different search term or adjust filters</p></div>';return}s.innerHTML=r.map(e=>`
|
||||
<div class="resource-item" data-path="${i(e.path)}">
|
||||
<div class="resource-info">
|
||||
<div class="resource-title">${e.featured?"⭐ ":""}${c?g.highlight(e.name,c):i(e.name)}</div>
|
||||
<div class="resource-description">${i(e.description||"No description")}</div>
|
||||
<div class="resource-meta">
|
||||
<span class="resource-tag">${e.itemCount} items</span>
|
||||
${e.tags?.slice(0,4).map(t=>`<span class="resource-tag">${i(t)}</span>`).join("")||""}
|
||||
${e.tags&&e.tags.length>4?`<span class="resource-tag">+${e.tags.length-4} more</span>`:""}
|
||||
</div>
|
||||
</div>
|
||||
<div class="resource-actions">
|
||||
<a href="${E(e.path)}" class="btn btn-secondary" target="_blank" onclick="event.stopPropagation()">View on GitHub</a>
|
||||
</div>
|
||||
</div>
|
||||
`).join(""),s.querySelectorAll(".resource-item").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.path;t&&I(t,L)})})}}async function B(){const r=document.getElementById("resource-list"),c=document.getElementById("search-input"),s=document.getElementById("filter-featured"),e=document.getElementById("clear-filters"),t=await m("collections.json");if(!t||!t.items){r&&(r.innerHTML='<div class="empty-state"><h3>Failed to load data</h3></div>');return}u=t.items;const o=u.map(a=>({...a,title:a.name,searchText:`${a.name} ${a.description} ${a.tags?.join(" ")||""}`.toLowerCase()}));g.setItems(o),d=h("#filter-tag",{placeholderValue:"All Tags"}),d.setChoices(t.filters.tags.map(a=>({value:a,label:a})),"value","label",!0),document.getElementById("filter-tag")?.addEventListener("change",()=>{n.tags=p(d),l()}),l(),c?.addEventListener("input",y(()=>l(),200)),s?.addEventListener("change",()=>{n.featured=s.checked,l()}),e?.addEventListener("click",()=>{n={tags:[],featured:!1},d.removeActiveItems(),s&&(s.checked=!1),c&&(c.value=""),l()}),$()}document.addEventListener("DOMContentLoaded",B);
|
||||
24
website-astro/dist/assets/index.astro_astro_type_script_index_0_lang.BrFo17Ab.js
vendored
Normal file
24
website-astro/dist/assets/index.astro_astro_type_script_index_0_lang.BrFo17Ab.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import{f as o,F as m,d as f,e as l,b as g,t as v,o as h,s as y}from"./modal.5jZNQ_ZW.js";async function $(){const c=await o("manifest.json");if(c&&c.counts){const a=document.getElementById("stats");a&&(a.innerHTML=`
|
||||
<div class="stat"><span class="stat-value">${c.counts.agents}</span><span class="stat-label">Agents</span></div>
|
||||
<div class="stat"><span class="stat-value">${c.counts.prompts}</span><span class="stat-label">Prompts</span></div>
|
||||
<div class="stat"><span class="stat-value">${c.counts.instructions}</span><span class="stat-label">Instructions</span></div>
|
||||
<div class="stat"><span class="stat-value">${c.counts.skills}</span><span class="stat-label">Skills</span></div>
|
||||
<div class="stat"><span class="stat-value">${c.counts.collections}</span><span class="stat-label">Collections</span></div>
|
||||
`)}const d=await o("search-index.json");if(d){const a=new m;a.setItems(d);const e=document.getElementById("global-search"),s=document.getElementById("search-results");e&&s&&(e.addEventListener("input",f(()=>{const t=e.value.trim();if(t.length<2){s.classList.add("hidden");return}const r=a.search(t).slice(0,10);r.length===0?s.innerHTML='<div class="search-result-empty">No results found</div>':(s.innerHTML=r.map(n=>`
|
||||
<div class="search-result" data-path="${l(n.path)}" data-type="${l(n.type)}">
|
||||
<span class="search-result-type">${g(n.type)}</span>
|
||||
<div>
|
||||
<div class="search-result-title">${a.highlight(n.title,t)}</div>
|
||||
<div class="search-result-description">${v(n.description,60)}</div>
|
||||
</div>
|
||||
</div>
|
||||
`).join(""),s.querySelectorAll(".search-result").forEach(n=>{n.addEventListener("click",()=>{const p=n.dataset.path,u=n.dataset.type;p&&u&&h(p,u)})})),s.classList.remove("hidden")},200)),document.addEventListener("click",t=>{!e.contains(t.target)&&!s.contains(t.target)&&s.classList.add("hidden")}))}const i=await o("collections.json");if(i&&i.items){const a=i.items.filter(s=>s.featured).slice(0,6),e=document.getElementById("featured-collections");e&&(a.length>0?(e.innerHTML=a.map(s=>`
|
||||
<div class="card" data-path="${l(s.path)}">
|
||||
<h3>${l(s.name)}</h3>
|
||||
<p>${l(v(s.description,80))}</p>
|
||||
<div class="resource-meta">
|
||||
<span class="resource-tag">${s.itemCount} items</span>
|
||||
${s.tags?.slice(0,3).map(t=>`<span class="resource-tag">${l(t)}</span>`).join("")||""}
|
||||
</div>
|
||||
</div>
|
||||
`).join(""),e.querySelectorAll(".card").forEach(s=>{s.addEventListener("click",()=>{const t=s.dataset.path;t&&h(t,"collection")})})):e.innerHTML='<p style="text-align: center; color: var(--color-text-muted);">No featured collections yet</p>')}y()}document.addEventListener("DOMContentLoaded",$);
|
||||
16
website-astro/dist/assets/instructions.astro_astro_type_script_index_0_lang.Bh7HO3GO.js
vendored
Normal file
16
website-astro/dist/assets/instructions.astro_astro_type_script_index_0_lang.Bh7HO3GO.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import{c as h,g as f}from"./choices.CFbCQwHQ.js";import{f as g,F as v,d as m,s as x,e as a,g as y,o as E}from"./modal.5jZNQ_ZW.js";const I="instruction";let c=[],u=new v,r,i={extensions:[]};function l(){const o=document.getElementById("search-input"),n=document.getElementById("results-count"),t=o?.value||"";let e=t?u.search(t):[...c];i.extensions.length>0&&(e=e.filter(d=>i.extensions.includes("(none)")&&(!d.extensions||d.extensions.length===0)?!0:d.extensions?.some(p=>i.extensions.includes(p)))),$(e,t);let s=`${e.length} of ${c.length} instructions`;i.extensions.length>0&&(s+=` (filtered by ${i.extensions.length} extension${i.extensions.length>1?"s":""})`),n&&(n.textContent=s)}function $(o,n=""){const t=document.getElementById("resource-list");if(t){if(o.length===0){t.innerHTML='<div class="empty-state"><h3>No instructions found</h3><p>Try a different search term or adjust filters</p></div>';return}t.innerHTML=o.map(e=>`
|
||||
<div class="resource-item" data-path="${a(e.path)}">
|
||||
<div class="resource-info">
|
||||
<div class="resource-title">${n?u.highlight(e.title,n):a(e.title)}</div>
|
||||
<div class="resource-description">${a(e.description||"No description")}</div>
|
||||
<div class="resource-meta">
|
||||
${e.applyTo?`<span class="resource-tag">applies to: ${a(e.applyTo)}</span>`:""}
|
||||
${e.extensions?.slice(0,4).map(s=>`<span class="resource-tag tag-extension">${a(s)}</span>`).join("")||""}
|
||||
${e.extensions&&e.extensions.length>4?`<span class="resource-tag">+${e.extensions.length-4} more</span>`:""}
|
||||
</div>
|
||||
</div>
|
||||
<div class="resource-actions">
|
||||
<a href="${y(e.path)}" class="btn btn-secondary" target="_blank" onclick="event.stopPropagation()">View on GitHub</a>
|
||||
</div>
|
||||
</div>
|
||||
`).join(""),t.querySelectorAll(".resource-item").forEach(e=>{e.addEventListener("click",()=>{const s=e.dataset.path;s&&E(s,I)})})}}async function b(){const o=document.getElementById("resource-list"),n=document.getElementById("search-input"),t=document.getElementById("clear-filters"),e=await g("instructions.json");if(!e||!e.items){o&&(o.innerHTML='<div class="empty-state"><h3>Failed to load data</h3></div>');return}c=e.items,u.setItems(c),r=h("#filter-extension",{placeholderValue:"All Extensions"}),r.setChoices(e.filters.extensions.map(s=>({value:s,label:s})),"value","label",!0),document.getElementById("filter-extension")?.addEventListener("change",()=>{i.extensions=f(r),l()}),l(),n?.addEventListener("input",m(()=>l(),200)),t?.addEventListener("click",()=>{i={extensions:[]},r.removeActiveItems(),n&&(n.value=""),l()}),x()}document.addEventListener("DOMContentLoaded",b);
|
||||
1
website-astro/dist/assets/modal.5jZNQ_ZW.js
vendored
Normal file
1
website-astro/dist/assets/modal.5jZNQ_ZW.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const f="https://raw.githubusercontent.com/github/awesome-copilot/main",p="https://github.com/github/awesome-copilot/blob/main",y={instructions:"https://aka.ms/awesome-copilot/install/instructions",prompt:"https://aka.ms/awesome-copilot/install/prompt",agent:"https://aka.ms/awesome-copilot/install/agent"};function g(){return typeof document<"u"&&document.body.dataset.basePath||"/"}async function $(e){try{const t=g(),n=await fetch(`${t}data/${e}`);if(!n.ok)throw new Error(`Failed to fetch ${e}`);return await n.json()}catch(t){return console.error(`Error fetching ${e}:`,t),null}}async function w(e){try{const t=await fetch(`${f}/${e}`);if(!t.ok)throw new Error(`Failed to fetch ${e}`);return await t.text()}catch(t){return console.error("Error fetching file content:",t),null}}async function E(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}}function b(e,t){const n=y[e];return n?`${n}?url=${encodeURIComponent(`${f}/${t}`)}`:null}function v(e){return`${p}/${e}`}function x(e){return`${f}/${e}`}function C(e,t="success"){const n=document.querySelector(".toast");n&&n.remove();const o=document.createElement("div");o.className=`toast ${t}`,o.textContent=e,document.body.appendChild(o),setTimeout(()=>{o.remove()},3e3)}function L(e,t){let n;return function(...c){const i=()=>{clearTimeout(n),e(...c)};clearTimeout(n),n=setTimeout(i,t)}}function h(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}function S(e,t){return!e||e.length<=t?e||"":e.slice(0,t).trim()+"..."}function k(e){return{agent:"🤖",prompt:"🎯",instruction:"📋",skill:"⚡",collection:"📦"}[e]||"📄"}class B{constructor(t=[]){this.items=[],this.items=t}setItems(t){this.items=t}search(t,n={}){const{fields:o=["title","description","searchText"],limit:c=50,minScore:i=0}=n;if(!t||t.trim().length===0)return this.items.slice(0,c);const s=t.toLowerCase().trim().split(/\s+/),l=[];for(const u of this.items){const a=this.calculateScore(u,s,o);a>i&&l.push({item:u,score:a})}return l.sort((u,a)=>a.score-u.score),l.slice(0,c).map(u=>u.item)}calculateScore(t,n,o){let c=0;for(const r of n){let s=0;for(const l of o){const u=t[l];if(!u)continue;const a=String(u).toLowerCase();l==="title"&&a===r?s=Math.max(s,100):l==="title"&&a.startsWith(r)?s=Math.max(s,80):l==="title"&&a.includes(r)?s=Math.max(s,60):l==="description"&&a.includes(r)?s=Math.max(s,30):l==="searchText"&&a.includes(r)&&(s=Math.max(s,20))}c+=s}return n.every(r=>o.some(s=>{const l=t[s];return l&&String(l).toLowerCase().includes(r)}))&&n.length>1&&(c*=1.5),c}highlight(t,n){if(!n||!t)return h(t||"");const c=n.toLowerCase().trim().split(/\s+/);let i=h(t);for(const r of c){if(r.length<2)continue;const s=new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");i=i.replace(s,"<mark>$1</mark>")}return i}}let d=null;function I(){const e=document.getElementById("file-modal"),t=document.getElementById("close-modal"),n=document.getElementById("copy-btn");e&&(t?.addEventListener("click",m),e.addEventListener("click",o=>{o.target===e&&m()}),document.addEventListener("keydown",o=>{o.key==="Escape"&&!e.classList.contains("hidden")&&m()}),n?.addEventListener("click",async()=>{if(d){const o=await E(d);C(o?"Copied to clipboard!":"Failed to copy",o?"success":"error")}}))}async function T(e,t){const n=document.getElementById("file-modal"),o=document.getElementById("modal-title"),c=document.getElementById("modal-content")?.querySelector("code"),i=document.getElementById("install-vscode-btn");if(!n||!o||!c)return;o.textContent=e.split("/").pop()||e,c.textContent="Loading...",n.classList.remove("hidden");const r=b(t,e);r&&i?(i.href=r,i.style.display="inline-flex"):i&&(i.style.display="none");const s=await w(e);d=s,s?c.textContent=s:c.textContent="Failed to load file content. Click the button below to view on GitHub."}function m(){const e=document.getElementById("file-modal");e&&e.classList.add("hidden"),d=null}export{B as F,x as a,k as b,L as d,h as e,$ as f,v as g,T as o,I as s,S as t};
|
||||
15
website-astro/dist/assets/prompts.astro_astro_type_script_index_0_lang.C2dpYm2a.js
vendored
Normal file
15
website-astro/dist/assets/prompts.astro_astro_type_script_index_0_lang.C2dpYm2a.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import{c as h,g as m}from"./choices.CFbCQwHQ.js";import{f,F as g,d as v,s as y,e as a,g as E,o as I}from"./modal.5jZNQ_ZW.js";const $="prompt";let i=[],d=new g,r,n={tools:[]};function c(){const l=document.getElementById("search-input"),o=document.getElementById("results-count"),t=l?.value||"";let e=t?d.search(t):[...i];n.tools.length>0&&(e=e.filter(u=>u.tools?.some(p=>n.tools.includes(p)))),b(e,t);let s=`${e.length} of ${i.length} prompts`;n.tools.length>0&&(s+=` (filtered by ${n.tools.length} tool${n.tools.length>1?"s":""})`),o&&(o.textContent=s)}function b(l,o=""){const t=document.getElementById("resource-list");if(t){if(l.length===0){t.innerHTML='<div class="empty-state"><h3>No prompts found</h3><p>Try a different search term or adjust filters</p></div>';return}t.innerHTML=l.map(e=>`
|
||||
<div class="resource-item" data-path="${a(e.path)}">
|
||||
<div class="resource-info">
|
||||
<div class="resource-title">${o?d.highlight(e.title,o):a(e.title)}</div>
|
||||
<div class="resource-description">${a(e.description||"No description")}</div>
|
||||
<div class="resource-meta">
|
||||
${e.tools?.slice(0,4).map(s=>`<span class="resource-tag">${a(s)}</span>`).join("")||""}
|
||||
${e.tools&&e.tools.length>4?`<span class="resource-tag">+${e.tools.length-4} more</span>`:""}
|
||||
</div>
|
||||
</div>
|
||||
<div class="resource-actions">
|
||||
<a href="${E(e.path)}" class="btn btn-secondary" target="_blank" onclick="event.stopPropagation()">View on GitHub</a>
|
||||
</div>
|
||||
</div>
|
||||
`).join(""),t.querySelectorAll(".resource-item").forEach(e=>{e.addEventListener("click",()=>{const s=e.dataset.path;s&&I(s,$)})})}}async function L(){const l=document.getElementById("resource-list"),o=document.getElementById("search-input"),t=document.getElementById("clear-filters"),e=await f("prompts.json");if(!e||!e.items){l&&(l.innerHTML='<div class="empty-state"><h3>Failed to load data</h3></div>');return}i=e.items,d.setItems(i),r=h("#filter-tool",{placeholderValue:"All Tools"}),r.setChoices(e.filters.tools.map(s=>({value:s,label:s})),"value","label",!0),document.getElementById("filter-tool")?.addEventListener("change",()=>{n.tools=m(r),c()}),c(),o?.addEventListener("input",v(()=>c(),200)),t?.addEventListener("click",()=>{n={tools:[]},r.removeActiveItems(),o&&(o.value=""),c()}),y()}document.addEventListener("DOMContentLoaded",L);
|
||||
34
website-astro/dist/assets/skills.astro_astro_type_script_index_0_lang.CQVGf5fQ.js
vendored
Normal file
34
website-astro/dist/assets/skills.astro_astro_type_script_index_0_lang.CQVGf5fQ.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user