Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made maturity level alises be appended to url with anchor tags #259

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions layouts/alias.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
<meta charset="utf-8">
<script>
let pathSegments = window.location.href.split('/');
let lastSegment = pathSegments[pathSegments.length - 1].toLowerCase();
let newUrl = "{{ .Permalink }}" + lastSegment;
let lastSegment = pathSegments[pathSegments.length - 1]?.toLowerCase() ?? "";
if (lastSegment === "") {
lastSegment = pathSegments[pathSegments.length - 2]?.toLowerCase() ?? "";
}
let newUrl = "{{ .Permalink }}" + "#" + lastSegment;
let pageType = "{{ with .Page }}{{ .Type }}{{ end }}";
if (pageType === "stream") {
window.location.href = newUrl;
Expand Down
9 changes: 3 additions & 6 deletions static/js/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ split_url = url_string.split('#');
maturity_param = split_url[1];

// If there's a parameter in the URL, open that maturity level
let maturityElementByUrlAlias = getMaturityLevelByUrlAlias(url_string);
let maturityElementByUrlAlias = getMaturityLevelByUrlAlias(maturity_param);
if (maturityElementByUrlAlias !== null) {
element = maturityElementByUrlAlias;
} else if (maturity_param == 'maturity2' || maturity_param == 'maturity3') {
Expand All @@ -46,9 +46,6 @@ if(typeof(element) != 'undefined' && element != null){
element.click();
}

function getMaturityLevelByUrlAlias(url) {
const pathSegments = url.split('/');

const lastSegment = pathSegments[pathSegments.length - 1];
return document.querySelector(`[maturity-url-alias$="${lastSegment}"]`);
function getMaturityLevelByUrlAlias(maturity_param) {
return document.querySelector(`[maturity-url-alias$="${maturity_param}"]`);
}