mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-21 02:45:12 +00:00
feat: add VS Code and VS Code Insiders install buttons
- Fix VS Code install URL format to match README links - Add separate buttons for VS Code and VS Code Insiders - Support install links for agents, prompts, and instructions - Add VS Code icon SVG to buttons
This commit is contained in:
@@ -46,7 +46,8 @@ export async function openFileModal(filePath: string, type: string): Promise<voi
|
||||
const modal = document.getElementById('file-modal');
|
||||
const title = document.getElementById('modal-title');
|
||||
const contentEl = document.getElementById('modal-content')?.querySelector('code');
|
||||
const installBtn = document.getElementById('install-vscode-btn') as HTMLAnchorElement | null;
|
||||
const installBtn = document.getElementById('install-btn') as HTMLAnchorElement | null;
|
||||
const installInsidersBtn = document.getElementById('install-insiders-btn') as HTMLAnchorElement | null;
|
||||
|
||||
if (!modal || !title || !contentEl) return;
|
||||
|
||||
@@ -58,14 +59,23 @@ export async function openFileModal(filePath: string, type: string): Promise<voi
|
||||
contentEl.textContent = 'Loading...';
|
||||
modal.classList.remove('hidden');
|
||||
|
||||
// Setup install button
|
||||
const installUrl = getVSCodeInstallUrl(type, filePath);
|
||||
// Setup install buttons (VS Code and VS Code Insiders)
|
||||
const installUrl = getVSCodeInstallUrl(type, filePath, false);
|
||||
const installInsidersUrl = getVSCodeInstallUrl(type, filePath, true);
|
||||
|
||||
if (installUrl && installBtn) {
|
||||
installBtn.href = installUrl;
|
||||
installBtn.style.display = 'inline-flex';
|
||||
} else if (installBtn) {
|
||||
installBtn.style.display = 'none';
|
||||
}
|
||||
|
||||
if (installInsidersUrl && installInsidersBtn) {
|
||||
installInsidersBtn.href = installInsidersUrl;
|
||||
installInsidersBtn.style.display = 'inline-flex';
|
||||
} else if (installInsidersBtn) {
|
||||
installInsidersBtn.style.display = 'none';
|
||||
}
|
||||
|
||||
// Fetch and display content
|
||||
const fileContent = await fetchFileContent(filePath);
|
||||
|
||||
@@ -5,11 +5,20 @@
|
||||
const REPO_BASE_URL = 'https://raw.githubusercontent.com/github/awesome-copilot/main';
|
||||
const REPO_GITHUB_URL = 'https://github.com/github/awesome-copilot/blob/main';
|
||||
|
||||
// VS Code install URL template
|
||||
const VSCODE_INSTALL_URLS: Record<string, string> = {
|
||||
instructions: 'https://aka.ms/awesome-copilot/install/instructions',
|
||||
prompt: 'https://aka.ms/awesome-copilot/install/prompt',
|
||||
agent: 'https://aka.ms/awesome-copilot/install/agent',
|
||||
// VS Code install URL configurations
|
||||
const VSCODE_INSTALL_CONFIG: Record<string, { baseUrl: string; scheme: string }> = {
|
||||
instructions: {
|
||||
baseUrl: 'https://aka.ms/awesome-copilot/install/instructions',
|
||||
scheme: 'chat-instructions'
|
||||
},
|
||||
prompt: {
|
||||
baseUrl: 'https://aka.ms/awesome-copilot/install/prompt',
|
||||
scheme: 'chat-prompt'
|
||||
},
|
||||
agent: {
|
||||
baseUrl: 'https://aka.ms/awesome-copilot/install/agent',
|
||||
scheme: 'chat-agent'
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -76,11 +85,19 @@ export async function copyToClipboard(text: string): Promise<boolean> {
|
||||
|
||||
/**
|
||||
* Generate VS Code install URL
|
||||
* @param type - Resource type (agent, prompt, instructions)
|
||||
* @param filePath - Path to the file
|
||||
* @param insiders - Whether to use VS Code Insiders
|
||||
*/
|
||||
export function getVSCodeInstallUrl(type: string, filePath: string): string | null {
|
||||
const baseUrl = VSCODE_INSTALL_URLS[type];
|
||||
if (!baseUrl) return null;
|
||||
return `${baseUrl}?url=${encodeURIComponent(`${REPO_BASE_URL}/${filePath}`)}`;
|
||||
export function getVSCodeInstallUrl(type: string, filePath: string, insiders = false): string | null {
|
||||
const config = VSCODE_INSTALL_CONFIG[type];
|
||||
if (!config) return null;
|
||||
|
||||
const rawUrl = `${REPO_BASE_URL}/${filePath}`;
|
||||
const vscodeScheme = insiders ? 'vscode-insiders' : 'vscode';
|
||||
const innerUrl = `${vscodeScheme}:${config.scheme}/install?url=${encodeURIComponent(rawUrl)}`;
|
||||
|
||||
return `${config.baseUrl}?url=${encodeURIComponent(innerUrl)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user