Skip to content

Commit

Permalink
Updates documentation theme
Browse files Browse the repository at this point in the history
  • Loading branch information
cadojo committed Jan 4, 2025
1 parent 351a1ae commit 02be919
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 19 deletions.
3 changes: 2 additions & 1 deletion docs/src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.quarto
*.quarto_ipynb
*.quarto_ipynb
/.quarto/
80 changes: 62 additions & 18 deletions docs/src/_quarto.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,73 @@
project:
type: book
output-dir: ../build
type: book
output-dir: "../build"

# Wflow.jl License
# MIT License
#
# Copyright (c) 2020 Deltares and contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

book:
title: "DocumenterQuarto"
author:
name: "Joey Carpinelli"
email: "[email protected]"
date: "2025-01-02"
chapters:
- index.md
- api/index.qmd
title: "DocumenterQuarto.jl"
author: "Joseph Carpinelli"
date: today
chapters:
- index.md
- api/index.qmd

navbar:
background: primary
right:
- text: Version
menu:
- text: EMPTY

search:
location: sidebar
type: textbox

twitter-card: true
open-graph: true
repo-url: https://github.com/cadojo/DocumenterQuarto.jl
repo-actions: [issue]


toc-title: "Table of Contents"

execute:
echo: false
output: true
freeze: false
daemon: 300
echo: false
output: true
cache: false
freeze: false

bibliography: references.bib

format:
html:
theme:
light: flatly
dark: darkly
html:
code-link: true
number-sections: false
theme:
light:
- _static/theme.scss
- default
dark:
- _static/theme.scss
- darkly
3 changes: 3 additions & 0 deletions docs/src/_static/theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*-- scss:defaults --*/

$primary: darken(#8d5bad, 10%);
145 changes: 145 additions & 0 deletions docs/src/_static/versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// MIT License for Wflow.jl
//
// Copyright (c) 2020 Deltares and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

function checkPathExists(url) {
return new Promise((resolve, reject) => {
var xhr = new XMLHttpRequest();
xhr.open('HEAD', url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
resolve(true);
} else if (xhr.status === 404) {
resolve(false);
} else {
reject(new Error(xhr.statusText));
}
}
};
xhr.onerror = function () {
reject(new Error('Network Error'));
};
xhr.send();
});
}

window.onload = function () {
// Dynamically load the `versions.js` script
const script = document.createElement('script');
script.src = 'https://raw.githubusercontent.com/cadojo/DocumenterQuarto.jl/gh-pages/versions.js'; // Replace with your actual path
script.async = true;

// Handle the script load event
script.onload = function () {
// Ensure the DOC_VERSIONS variable exists
if (typeof DOC_VERSIONS === 'undefined') {
console.error('DOC_VERSIONS variable is not defined in the script.');
return;
}

const dropdown = document.querySelector('#nav-menu-version').nextElementSibling;
console.log('Dropdown element:', dropdown); // Log the dropdown element

// Clear all existing dropdown items
dropdown.innerHTML = '';

// Process each version in the DOC_VERSIONS array
DOC_VERSIONS.forEach(
version => {
console.log('Adding version:', version);

// Create a new li element
const li = document.createElement('li');

// Create a new a element
const a = document.createElement('a');
a.className = 'dropdown-item';
a.href = "";
a.textContent = version;

// Add the a element to the li
li.appendChild(a);

// Add the li to the dropdown
dropdown.appendChild(li);
});

console.log('Dropdown after adding items:', dropdown); // Log the dropdown after adding items

// Get all dropdown items within the specific dropdown menu
var dropdownMenu = document.querySelector('#nav-menu-version').nextElementSibling;

var dropdownItems = dropdownMenu.querySelectorAll('.dropdown-item');

// Get the current page in chunks
var currentPagePath = window.location.pathname.split('/');

for (var i = 0; i < dropdownItems.length; i++) {
// Get textcontent
var textContent = dropdownItems[i].textContent;

// Get the index of the current version
var index = currentPagePath.indexOf(textContent);

if (index !== -1) {
// Remove the active-item class from all items
for (var j = 0; j < dropdownItems.length; j++) {
dropdownItems[j].classList.remove('active-item');
}

dropdownItems[i].classList.add('active-item');
break
}
}

console.log('current page path', currentPagePath);

for (var i = 0; i < dropdownItems.length; i++) {
// Add click event listener to each item
dropdownItems[i].addEventListener('click', function (event) {
// Prevent default action
event.preventDefault();

// Get the clicked item's text
var itemText = this.textContent;
var itemHref = this.getAttribute('href')

// Loop through each dropdown item again to find a match in the current page's path
for (var j = 0; j < dropdownItems.length; j++) {
// Get the dropdown item's text
var dropdownText = dropdownItems[j].textContent;
console.log('Dropdown item:', dropdownText);

window.location.href = itemHref;
}
});
}
};

// Handle script load errors
script.onerror = function () {
console.error('Failed to load versions.js');
};

// Append the script to the document
document.head.appendChild(script);
};

2 comments on commit 02be919

@github-actions
Copy link

Choose a reason for hiding this comment

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

@JuliaRegistrator register"

This comment was generated with commit-comment and Register.yml.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request updated: JuliaRegistries/General/122330

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 02be91972e9167f0fa92c7e07524232aa7bbd9a5
git push origin v0.1.0

Please sign in to comment.