Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions src/jio-navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,83 @@ export class Navbar extends LitElement {
handleDocumentClick() {
this.visibleMenu = -1;
}
private isDocsSite = window.location.hostname === 'docs.jenkins.io';
private docsVersion = '2.504.x';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a list/array in the near future. Should be make provisions to prepare for that eventuality?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! Great point for future
How about we update docsVersion to docsVersions and convert it to an array type. I will make sure the implementation defaults to the current version but remains scalable to support multiple versions in the future.

Copy link
Contributor Author

@biru-codeastromer biru-codeastromer Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can do this in the property defintion -

@property({type: Array})
docsVersions = ['2.504.x'];

and then modify the getDocsUrl method to :

private getDocsUrl(originalPath: string): string {
  const currentVersion = this.docsVersions[0] || '2.504.x';
  
  // ... rest of our logic.....
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it wont have that version selection ability , so maybe I will see now how i can modify the code to have that ability , maybe this PR we should like keep the review on hold for sometime and come back to this when we successfully complete our new side navbar implementation in antora .
What you think about it?

Copy link
Contributor Author

@biru-codeastromer biru-codeastromer Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make provisions to prepare for that eventuality?

Yes the best time for it will be for me to continue finding currently the best way to achieve version selection logic and get it done so you all can review after as i mentioned that new side bar implementation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, take sufficient time on thinking about this before deciding on a solution!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@biru-codeastromer any update on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could automate the updating of this part too. What would you recommend us do here @gounthar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krisstern Hey , as discussed in our weekly meet, this is one of this week's task . After I complete the pages migration I will finish this part + some small changes in antora for tomorrow radar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By tomorrow, I believe Bruno reply will also finalise our changes needed + I will inform before I start how I want to update this PR in slack


private getDocsUrl(originalPath: string): string {

const cleanPath = originalPath.replace(/^https?:\/\/[^/]+/, '').split(/[#?]/)[0];
const docMappings: Record<string, {path: string, versioned: boolean}> = {
// User Guide sections (versioned)
'/doc/book': {path: '/user-docs', versioned: true},
'/doc/book/installing': {path: '/user-docs/installing-jenkins', versioned: true},
'/doc/book/pipeline': {path: '/user-docs/pipeline', versioned: true},
'/doc/book/managing': {path: '/user-docs/managing', versioned: true},
'/doc/book/security': {path: '/user-docs/security', versioned: true},
'/doc/book/system-administration': {path: '/user-docs/system-administration', versioned: true},
'/doc/book/troubleshooting': {path: '/user-docs/troubleshooting', versioned: true},
'/doc/book/glossary': {path: '/user-docs/glossary', versioned: true},

// Solutions (versioned)
'/solutions': {path: '/solutions', versioned: true},

// Tutorials (versioned)
'/doc/tutorials': {path: '/tutorials', versioned: true},

// Developer Guide (not versioned)
'/doc/developer': {path: '/dev-docs', versioned: false},

// Community sections
'/participate': {path: '/community', versioned: false},
'/chat': {path: '/community/chat', versioned: false},
'/projects/jam': {path: '/community/meet', versioned: false},
'/events': {path: '/events', versioned: false},
'/mailing-lists': {path: '/community/mailing-lists', versioned: false},

// Subprojects
'/sigs/docs/gsod/2020/projects/document-jenkins-on-kubernetes': {
path: '/sigs/docs/gsod/2020/projects/document-jenkins-on-kubernetes',
versioned: false
},

// Security
'/security/reporting': {path: '/security/reporting', versioned: false},

// About sections
'/project/roadmap': {path: '/about', versioned: false},
'/project/conduct': {path: '/project/conduct', versioned: false},
'/artwork': {path: '/images', versioned: false}
};

const mappingEntry = Object.entries(docMappings).find(([original]) =>
cleanPath.startsWith(original)
);

if (mappingEntry && this.isDocsSite) {
const [original, {path: replacement, versioned}] = mappingEntry;
let newPath = cleanPath.replace(original, replacement);

if (versioned) {
const pathParts = newPath.split('/').filter(part => part !== '');
if (pathParts.length >= 1) {
pathParts.splice(1, 0, this.docsVersion);
newPath = '/' + pathParts.join('/');
} else {
newPath = `/${this.docsVersion}`;
}
}

if (!newPath.endsWith('index.html')) {
newPath = newPath.replace(/(\/)?$/, '/') + 'index.html';
}

return `https://docs.jenkins.io${newPath}`;
}

return this.isDocsSite
? `https://docs.jenkins.io${cleanPath}`
: `https://www.jenkins.io${cleanPath}`;
}

override render() {
const cdfMenuItems = [
Expand Down