diff --git a/docs/src/.gitignore b/docs/src/.gitignore index 73f9798..e584a77 100644 --- a/docs/src/.gitignore +++ b/docs/src/.gitignore @@ -1,2 +1,3 @@ .quarto -*.quarto_ipynb \ No newline at end of file +*.quarto_ipynb +/.quarto/ diff --git a/docs/src/_quarto.yml b/docs/src/_quarto.yml index 156fae4..8f3fc3f 100644 --- a/docs/src/_quarto.yml +++ b/docs/src/_quarto.yml @@ -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: "joey@loopy.codes" - 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 \ No newline at end of file diff --git a/docs/src/_static/theme.scss b/docs/src/_static/theme.scss new file mode 100644 index 0000000..5a2bbcd --- /dev/null +++ b/docs/src/_static/theme.scss @@ -0,0 +1,3 @@ +/*-- scss:defaults --*/ + +$primary: darken(#8d5bad, 10%); \ No newline at end of file diff --git a/docs/src/_static/versions.js b/docs/src/_static/versions.js new file mode 100644 index 0000000..b5de482 --- /dev/null +++ b/docs/src/_static/versions.js @@ -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); +};