Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bd9b48

Browse files
authored
add redirect by path for segment switch (#1305)
* add redirect by path for segment switch* remove ?ent from redirect* removed window relatance from functions* removed comment
1 parentaf325ab commit2bd9b48

File tree

4 files changed

+33
-5468
lines changed

4 files changed

+33
-5468
lines changed

‎_includes/scripts.html‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@
8383
</script>
8484

8585
<script>
86-
window.toggleSegmentDropdown=function(){
86+
toggleSegmentDropdown=function(){
8787
constselect=document.querySelector('.custom-select');
8888
select.classList.toggle('open');
8989
};
9090

91-
window.handleDropdownKeydown=function(event){
91+
handleDropdownKeydown=function(event){
9292
constselect=document.querySelector('.custom-select');
9393
constoptions=select.querySelectorAll('.option');
9494
constisOpen=select.classList.contains('open');
@@ -110,7 +110,7 @@
110110
}
111111
};
112112

113-
window.handleOptionKeydown=function(event,option,selectedValue){
113+
handleOptionKeydown=function(event,option,selectedValue){
114114
constselect=document.querySelector('.custom-select');
115115
constoptions=select.querySelectorAll('.option');
116116
constcurrentIndex=Array.from(options).indexOf(option);
@@ -140,22 +140,39 @@
140140
}
141141
};
142142

143-
window.selectSegmentOption=function(option,selectedValue){
143+
selectSegmentOption=asyncfunction(option,selectedValue){
144144
constselectDisplay=document.querySelector('.select-display');
145-
constoptions=document.querySelectorAll('.option');
146145

147-
// Update the display text
148146
selectDisplay.textContent=option.textContent;
149147

148+
constredirectMap=awaitfetchRedirectMap();
149+
150+
constcurrentPath=window.location.pathname;
151+
150152
if(selectedValue==='enterprise'){
151153
localStorage.setItem(enterpriseDocTypeLockKey,'true');
152-
location.href=`${SITE_BASE_URL}/?ent`;
154+
155+
constenterprisePath=Object.keys(redirectMap).find(
156+
key=>redirectMap[key]===currentPath
157+
);
158+
159+
if(enterprisePath){
160+
window.location.href=`${SITE_BASE_URL}${enterprisePath}`;
161+
}else{
162+
window.location.href=`${SITE_BASE_URL}/`;
163+
}
153164
}elseif(selectedValue==='gitops'){
154165
localStorage.setItem(enterpriseDocTypeLockKey,'false');
155-
location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`;
166+
167+
constgitOpsPath=redirectMap[currentPath];
168+
169+
if(gitOpsPath){
170+
window.location.href=`${SITE_BASE_URL}${gitOpsPath}`;
171+
}else{
172+
window.location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`;
173+
}
156174
}
157175
};
158-
159176
// Close dropdown when clicking outside
160177
document.addEventListener('click',(e)=>{
161178
constselect=document.querySelector('.custom-select');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp