Skip to content

Commit d7a5481

Browse files
authored
Fix manul install, make website install sections linkable (#230)
* Fix manual installation JSON examples to use @latest version - Updated README.md, FAQ.md, and docs/index.html - Changed '@wonderwhy-er/desktop-commander' to '@wonderwhy-er/desktop-commander@latest' - Ensures manual installations always use the latest version from npm * Fix website tab navigation and URL updating - Updated openTab() function to update URL hash when switching tabs - Enhanced handleAnchorNavigation() to handle all installation tab anchors - Now all installation links work: #npx, #bash, #smithery, #manual, #local, #docker-install - URL updates when changing tabs, making links shareable - Maintains special handling for docker-install with highlighting * Add support for general #installation anchor link - Added handling for #installation link that scrolls to section without changing tabs - Maintains default tab (NPX Install) when using general installation link - Existing tab-specific links still work (#npx, #bash, #smithery, etc.) - Navigation menu 'Installation' link now works properly * Fix URL hash not updating when clicking navigation links - Modified smooth scrolling code to update URL hash using history.pushState() - Now clicking 'Installation' in header properly updates URL to #installation - Maintains smooth scrolling behavior while enabling shareable URLs - All navigation links now update the URL hash as expected
1 parent a7e10a7 commit d7a5481

4 files changed

Lines changed: 68 additions & 26 deletions

File tree

‎FAQ.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Add the MCP server to your claude_desktop_config.json (on Mac, found at ~/Librar
141141
"command": "npx",
142142
"args": [
143143
"-y",
144-
"@wonderwhy-er/desktop-commander"
144+
"@wonderwhy-er/desktop-commander@latest"
145145
]
146146
}
147147
}

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Add this entry to your claude_desktop_config.json:
131131
"command": "npx",
132132
"args": [
133133
"-y",
134-
"@wonderwhy-er/desktop-commander"
134+
"@wonderwhy-er/desktop-commander@latest"
135135
]
136136
}
137137
}

‎docs/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ <h3>Manual Configuration</h3>
14731473
"command": "npx",
14741474
"args": [
14751475
"-y",
1476-
"@wonderwhy-er/desktop-commander"
1476+
"@wonderwhy-er/desktop-commander@latest"
14771477
]
14781478
}
14791479
}

‎docs/js/main.js‎

Lines changed: 65 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ function openTab(evt, tabName) {
6565
// Show the selected tab and add an active class to the button
6666
document.getElementById(tabName).classList.add("active");
6767
evt.currentTarget.classList.add("active");
68+
69+
// Update URL hash to match the selected tab (for shareable links)
70+
if (tabName === 'docker') {
71+
// Special case for docker - use docker-install anchor
72+
history.replaceState(null, null, '#docker-install');
73+
} else {
74+
// For other tabs, use the tab name as anchor
75+
history.replaceState(null, null, '#' + tabName);
76+
}
6877
}
6978

7079
// Make the openTab function available globally
@@ -314,12 +323,16 @@ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
314323
anchor.addEventListener('click', function (e) {
315324
e.preventDefault();
316325

317-
const target = document.querySelector(this.getAttribute('href'));
326+
const href = this.getAttribute('href');
327+
const target = document.querySelector(href);
318328
if (target) {
319329
// Extra offset for section IDs that are inside the cases section
320-
const isSubsection = this.getAttribute('href').startsWith('#cases-');
330+
const isSubsection = href.startsWith('#cases-');
321331
const offset = isSubsection ? 120 : 80;
322332

333+
// Update URL hash to match the clicked link
334+
history.pushState(null, null, href);
335+
323336
window.scrollTo({
324337
top: target.offsetTop - offset,
325338
behavior: 'smooth'
@@ -431,23 +444,43 @@ function handleAnchorNavigation() {
431444
if (window.location.hash) {
432445
const hash = window.location.hash.substring(1); // Remove the #
433446

434-
// Special handling for docker-install anchor
435-
if (hash === 'docker-install') {
436-
// Check for UTM parameters to confirm this came from Docker Gateway
437-
const urlParams = new URLSearchParams(window.location.search);
438-
const utmSource = urlParams.get('utm_source');
439-
const utmMedium = urlParams.get('utm_medium');
440-
const utmCampaign = urlParams.get('utm_campaign');
441-
447+
// Handle general installation section link (just scroll, don't change tabs)
448+
if (hash === 'installation') {
449+
const installationSection = document.getElementById('installation');
450+
if (installationSection) {
451+
setTimeout(() => {
452+
installationSection.scrollIntoView({
453+
behavior: 'smooth',
454+
block: 'start'
455+
});
456+
}, 100);
457+
}
458+
return; // Exit early, don't process as tab-specific
459+
}
460+
461+
// Define valid installation tab anchors
462+
const validTabs = {
463+
'npx': 'npx',
464+
'bash': 'bash',
465+
'smithery': 'smithery',
466+
'manual': 'manual',
467+
'local': 'local',
468+
'docker': 'docker',
469+
'docker-install': 'docker' // Special case: docker-install maps to docker tab
470+
};
471+
472+
// Check if the hash corresponds to an installation tab
473+
if (validTabs[hash]) {
474+
const targetTab = validTabs[hash];
442475

443476
// First scroll to the installation section
444477
const installationSection = document.getElementById('installation');
445478
if (installationSection) {
446-
// Open the docker tab
447-
const dockerTab = document.querySelector('[onclick*="docker"]');
448-
if (dockerTab) {
449-
// Simulate click on docker tab
450-
dockerTab.click();
479+
// Find and click the appropriate tab button
480+
const tabButton = document.querySelector(`[onclick*="${targetTab}"]`);
481+
if (tabButton) {
482+
// Simulate click on the tab
483+
tabButton.click();
451484

452485
// Wait a bit for tab to open, then scroll
453486
setTimeout(() => {
@@ -456,14 +489,23 @@ function handleAnchorNavigation() {
456489
block: 'start'
457490
});
458491

459-
// Highlight the docker section briefly
460-
const dockerSection = document.getElementById('docker');
461-
if (dockerSection) {
462-
dockerSection.style.transition = 'background-color 0.5s ease';
463-
dockerSection.style.backgroundColor = '#e3f2fd';
464-
setTimeout(() => {
465-
dockerSection.style.backgroundColor = '';
466-
}, 2000);
492+
// Special handling for docker-install anchor
493+
if (hash === 'docker-install') {
494+
// Check for UTM parameters to confirm this came from Docker Gateway
495+
const urlParams = new URLSearchParams(window.location.search);
496+
const utmSource = urlParams.get('utm_source');
497+
const utmMedium = urlParams.get('utm_medium');
498+
const utmCampaign = urlParams.get('utm_campaign');
499+
500+
// Highlight the docker section briefly
501+
const dockerSection = document.getElementById('docker');
502+
if (dockerSection) {
503+
dockerSection.style.transition = 'background-color 0.5s ease';
504+
dockerSection.style.backgroundColor = '#e3f2fd';
505+
setTimeout(() => {
506+
dockerSection.style.backgroundColor = '';
507+
}, 2000);
508+
}
467509
}
468510
}, 100);
469511
}

0 commit comments

Comments
 (0)