mirror of
https://github.com/imfing/hextra.git
synced 2025-07-08 19:27:11 -04:00
Compare commits
3 Commits
3d2dbb70cc
...
v0.8.3
Author | SHA1 | Date | |
---|---|---|---|
2af73b3d7e | |||
d1c3c40a95 | |||
086af4d173 |
@ -2532,30 +2532,30 @@ nav .search-wrapper {
|
|||||||
.hamburger-menu svg.open > g:nth-of-type(2) path {
|
.hamburger-menu svg.open > g:nth-of-type(2) path {
|
||||||
transform: translate3d(0, -4px, 0);
|
transform: translate3d(0, -4px, 0);
|
||||||
}
|
}
|
||||||
.hextra-scrollbar {
|
.hextra-scrollbar, .hextra-scrollbar * {
|
||||||
scrollbar-width: thin; /* Firefox */
|
scrollbar-width: thin; /* Firefox */
|
||||||
scrollbar-color: oklch(55.55% 0 0 / 40%) transparent; /* Firefox */
|
scrollbar-color: oklch(55.55% 0 0 / 40%) transparent; /* Firefox */
|
||||||
|
|
||||||
scrollbar-gutter: stable;
|
scrollbar-gutter: stable;
|
||||||
}
|
}
|
||||||
.hextra-scrollbar::-webkit-scrollbar {
|
.hextra-scrollbar::-webkit-scrollbar, .hextra-scrollbar *::-webkit-scrollbar {
|
||||||
height: 0.75rem;
|
height: 0.75rem;
|
||||||
width: 0.75rem;
|
width: 0.75rem;
|
||||||
}
|
}
|
||||||
.hextra-scrollbar::-webkit-scrollbar-track {
|
.hextra-scrollbar::-webkit-scrollbar-track, .hextra-scrollbar *::-webkit-scrollbar-track {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
.hextra-scrollbar::-webkit-scrollbar-thumb {
|
.hextra-scrollbar::-webkit-scrollbar-thumb, .hextra-scrollbar *::-webkit-scrollbar-thumb {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
.hextra-scrollbar:hover::-webkit-scrollbar-thumb {
|
.hextra-scrollbar:hover::-webkit-scrollbar-thumb, .hextra-scrollbar *:hover::-webkit-scrollbar-thumb {
|
||||||
border: 3px solid transparent;
|
border: 3px solid transparent;
|
||||||
background-color: var(--tw-shadow-color);
|
background-color: var(--tw-shadow-color);
|
||||||
background-clip: content-box;
|
background-clip: content-box;
|
||||||
--tw-shadow-color: rgb(115 115 115 / 0.2);
|
--tw-shadow-color: rgb(115 115 115 / 0.2);
|
||||||
--tw-shadow: var(--tw-shadow-colored);
|
--tw-shadow: var(--tw-shadow-colored);
|
||||||
}
|
}
|
||||||
.hextra-scrollbar:hover::-webkit-scrollbar-thumb:hover {
|
.hextra-scrollbar:hover::-webkit-scrollbar-thumb:hover, .hextra-scrollbar *:hover::-webkit-scrollbar-thumb:hover {
|
||||||
--tw-shadow-color: rgb(115 115 115 / 0.4);
|
--tw-shadow-color: rgb(115 115 115 / 0.4);
|
||||||
--tw-shadow: var(--tw-shadow-colored);
|
--tw-shadow: var(--tw-shadow-colored);
|
||||||
}
|
}
|
||||||
|
29
assets/css/components/jupyter.css
Normal file
29
assets/css/components/jupyter.css
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
.hextra-jupyter-code-cell {
|
||||||
|
scrollbar-gutter: auto;
|
||||||
|
|
||||||
|
@apply hx-mt-6;
|
||||||
|
|
||||||
|
.hextra-jupyter-code-cell-source {
|
||||||
|
@apply hx-text-sm;
|
||||||
|
.chroma,
|
||||||
|
pre {
|
||||||
|
@apply hx-m-0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hextra-jupyter-code-cell-outputs-container {
|
||||||
|
@apply hx-text-xs hx-overflow-hidden hx-border hx-border-t-0 hx-rounded-b-xl dark:hx-border-neutral-800;
|
||||||
|
|
||||||
|
.hextra-jupyter-code-cell-outputs {
|
||||||
|
@apply hx-overflow-auto hx-max-h-[50vh];
|
||||||
|
|
||||||
|
pre {
|
||||||
|
@apply hx-p-4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hextra-jupyter-code-cell:has(.hextra-jupyter-code-cell-outputs) .hextra-jupyter-code-cell-source .chroma {
|
||||||
|
@apply hx-rounded-b-none;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
.hextra-scrollbar {
|
.hextra-scrollbar, .hextra-scrollbar * {
|
||||||
scrollbar-width: thin; /* Firefox */
|
scrollbar-width: thin; /* Firefox */
|
||||||
scrollbar-color: oklch(55.55% 0 0 / 40%) transparent; /* Firefox */
|
scrollbar-color: oklch(55.55% 0 0 / 40%) transparent; /* Firefox */
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
.hextra-sidebar-container {
|
.sidebar-container {
|
||||||
@apply hx-fixed hx-pt-[calc(var(--navbar-height))] hx-top-0 hx-w-full hx-bottom-0 hx-z-[15] hx-overscroll-contain hx-bg-white dark:hx-bg-dark;
|
@apply hx-fixed hx-pt-[calc(var(--navbar-height))] hx-top-0 hx-w-full hx-bottom-0 hx-z-[15] hx-overscroll-contain hx-bg-white dark:hx-bg-dark;
|
||||||
transition: transform 0.8s cubic-bezier(0.52, 0.16, 0.04, 1);
|
transition: transform 0.8s cubic-bezier(0.52, 0.16, 0.04, 1);
|
||||||
will-change: transform, opacity;
|
will-change: transform, opacity;
|
||||||
@ -8,7 +8,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.hextra-sidebar-container {
|
.sidebar-container {
|
||||||
li > div {
|
li > div {
|
||||||
@apply hx-h-0;
|
@apply hx-h-0;
|
||||||
}
|
}
|
||||||
@ -18,19 +18,4 @@
|
|||||||
li.open > a > span > svg > path {
|
li.open > a > span > svg > path {
|
||||||
@apply hx-rotate-90;
|
@apply hx-rotate-90;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hextra-sidebar-item-list {
|
|
||||||
@apply hx-relative hx-flex hx-flex-col hx-gap-1 before:hx-absolute before:hx-inset-y-1 before:hx-w-px before:hx-bg-gray-200 ltr:hx-ml-3 ltr:hx-pl-3 ltr:before:hx-left-0 rtl:hx-mr-3 rtl:hx-pr-3 rtl:before:hx-right-0 dark:before:hx-bg-neutral-800;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hextra-sidebar-item-link {
|
|
||||||
@apply hx-flex hx-items-center hx-justify-between hx-gap-2 hx-cursor-pointer hx-rounded hx-px-2 hx-py-1.5 hx-text-sm hx-transition-colors;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
@apply hx-bg-primary-100 hx-font-semibold hx-text-primary-800 contrast-more:hx-border contrast-more:hx-border-primary-500 dark:hx-bg-primary-400/10 dark:hx-text-primary-600 contrast-more:dark:hx-border-primary-500;
|
|
||||||
}
|
|
||||||
&.inactive {
|
|
||||||
@apply hx-text-gray-500 hover:hx-bg-gray-100 hover:hx-text-gray-900 contrast-more:hx-border contrast-more:hx-border-transparent contrast-more:hx-text-gray-900 contrast-more:hover:hx-border-gray-900 dark:hx-text-neutral-400 dark:hover:hx-bg-primary-100/5 dark:hover:hx-text-gray-50 contrast-more:dark:hx-text-gray-50 contrast-more:dark:hover:hx-border-gray-50;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const menu = document.querySelector('.hamburger-menu');
|
const menu = document.querySelector('.hamburger-menu');
|
||||||
const overlay = document.querySelector('.mobile-menu-overlay');
|
const overlay = document.querySelector('.mobile-menu-overlay');
|
||||||
const sidebarContainer = document.querySelector('.hextra-sidebar-container');
|
const sidebarContainer = document.querySelector('.sidebar-container');
|
||||||
|
|
||||||
// Initialize the overlay
|
// Initialize the overlay
|
||||||
const overlayClasses = ['hx-fixed', 'hx-inset-0', 'hx-z-10', 'hx-bg-black/80', 'dark:hx-bg-black/60'];
|
const overlayClasses = ['hx-fixed', 'hx-inset-0', 'hx-z-10', 'hx-bg-black/80', 'dark:hx-bg-black/60'];
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
/**
|
|
||||||
* Check if the element is visible.
|
|
||||||
* @param {Element} element Dom element
|
|
||||||
* @returns boolean
|
|
||||||
*/
|
|
||||||
function isVisible(element) {
|
|
||||||
return element.offsetWidth > 0 || element.offsetHeight > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
const buttons = document.querySelectorAll(".hextra-sidebar-collapsible-button");
|
const buttons = document.querySelectorAll(".hextra-sidebar-collapsible-button");
|
||||||
buttons.forEach(function (button) {
|
buttons.forEach(function (button) {
|
||||||
@ -14,41 +5,8 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const list = button.parentElement.parentElement;
|
const list = button.parentElement.parentElement;
|
||||||
if (list) {
|
if (list) {
|
||||||
list.classList.toggle("open");
|
list.classList.toggle("open")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const isCached = "{{- site.Params.page.sidebar.cache | default false -}}" === "true";
|
|
||||||
const currentPagePath = window.location.href;
|
|
||||||
|
|
||||||
if (isCached) {
|
|
||||||
// find the current page in the sidebar and open the parent lists
|
|
||||||
const sidebar = document.querySelector(".hextra-sidebar-container");
|
|
||||||
if (sidebar) {
|
|
||||||
// find a tags and compare href with current page path
|
|
||||||
const links = sidebar.querySelectorAll("a");
|
|
||||||
links.forEach(function (link) {
|
|
||||||
const linkPath = link.href;
|
|
||||||
|
|
||||||
if (currentPagePath === linkPath) {
|
|
||||||
// add active class to the link
|
|
||||||
link.classList.add("active");
|
|
||||||
link.classList.remove("inactive");
|
|
||||||
|
|
||||||
if (!isVisible(link)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// recursively open parent lists
|
|
||||||
let parent = link.parentElement;
|
|
||||||
while (parent && !parent.classList.contains("hextra-sidebar-container")) {
|
|
||||||
if (parent.tagName === "LI" && parent.classList.contains("hextra-sidebar-item")) {
|
|
||||||
parent.classList.add("open");
|
|
||||||
}
|
|
||||||
parent = parent.parentElement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
@ -36,6 +36,8 @@ hugo-full: >
|
|||||||
<path fill="#fff" d="M1320.72 89.15c58.79 0 106.52 47.73 106.52 106.51 0 58.8-47.73 106.52-106.52 106.52-58.78 0-106.52-47.73-106.52-106.52 0-58.78 47.74-106.51 106.52-106.51zm0 39.57c36.95 0 66.94 30 66.94 66.94a66.97 66.97 0 0 1-66.94 66.94c-36.95 0-66.94-29.99-66.94-66.94a66.97 66.97 0 0 1 66.93-66.94h.01zm-283.8 65.31c0 47.18-8.94 60.93-26.81 80.58-17.87 19.65-41.57 27.57-71.1 27.57-27 0-48.75-9.58-67.61-26.23-20.88-18.45-36.08-47.04-36.08-78.95 0-31.37 11.72-58.48 32.49-78.67 18.22-17.67 45.34-29.18 73.3-29.18 33.77 0 68.83 15.98 90.44 47.53l-31.73 26.82c-13.45-25.03-32.94-33.46-60.82-34.26-30.83-.88-64.77 28.53-62.25 67.75 1.4 21.94 11.65 59.65 60.96 66.57 25.9 3.63 55.36-24.02 55.36-39.04H944.4v-37.5h92.5V194l.02.03zm-562.6-94.65h42.29v112.17c0 17.8.49 29.33 1.47 34.61 1.69 8.48 4.81 14.37 11.17 19.5 6.37 5.13 13.8 6.59 24.84 6.59 11.2 0 14.96-1.74 20.66-6.6 5.69-4.85 9.12-9.46 10.28-16.53 1.15-7.07 3.07-18.8 3.07-35.18V99.38h42.28v108.78c0 24.86-1.07 42.43-3.21 52.69-2.14 10.27-6.08 18.93-11.82 26-5.74 7.06-13.42 12.69-23.03 16.88-9.62 4.19-22.16 6.28-37.65 6.28-18.7 0-32.87-2.28-42.52-6.85-9.66-4.57-17.3-10.5-22.9-17.8-5.61-7.3-9.3-14.95-11.08-22.96-2.58-11.86-3.88-29.38-3.88-52.55V99.38h.03zM93.91 299.92V92.7h43.35v75.48h71.92V92.7h43.48v207.22h-43.48v-90.61h-71.92v90.61z"/>
|
<path fill="#fff" d="M1320.72 89.15c58.79 0 106.52 47.73 106.52 106.51 0 58.8-47.73 106.52-106.52 106.52-58.78 0-106.52-47.73-106.52-106.52 0-58.78 47.74-106.51 106.52-106.51zm0 39.57c36.95 0 66.94 30 66.94 66.94a66.97 66.97 0 0 1-66.94 66.94c-36.95 0-66.94-29.99-66.94-66.94a66.97 66.97 0 0 1 66.93-66.94h.01zm-283.8 65.31c0 47.18-8.94 60.93-26.81 80.58-17.87 19.65-41.57 27.57-71.1 27.57-27 0-48.75-9.58-67.61-26.23-20.88-18.45-36.08-47.04-36.08-78.95 0-31.37 11.72-58.48 32.49-78.67 18.22-17.67 45.34-29.18 73.3-29.18 33.77 0 68.83 15.98 90.44 47.53l-31.73 26.82c-13.45-25.03-32.94-33.46-60.82-34.26-30.83-.88-64.77 28.53-62.25 67.75 1.4 21.94 11.65 59.65 60.96 66.57 25.9 3.63 55.36-24.02 55.36-39.04H944.4v-37.5h92.5V194l.02.03zm-562.6-94.65h42.29v112.17c0 17.8.49 29.33 1.47 34.61 1.69 8.48 4.81 14.37 11.17 19.5 6.37 5.13 13.8 6.59 24.84 6.59 11.2 0 14.96-1.74 20.66-6.6 5.69-4.85 9.12-9.46 10.28-16.53 1.15-7.07 3.07-18.8 3.07-35.18V99.38h42.28v108.78c0 24.86-1.07 42.43-3.21 52.69-2.14 10.27-6.08 18.93-11.82 26-5.74 7.06-13.42 12.69-23.03 16.88-9.62 4.19-22.16 6.28-37.65 6.28-18.7 0-32.87-2.28-42.52-6.85-9.66-4.57-17.3-10.5-22.9-17.8-5.61-7.3-9.3-14.95-11.08-22.96-2.58-11.86-3.88-29.38-3.88-52.55V99.38h.03zM93.91 299.92V92.7h43.35v75.48h71.92V92.7h43.48v207.22h-43.48v-90.61h-71.92v90.61z"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
|
jupyter: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M7.157 22.201A1.784 1.799 0 0 1 5.374 24a1.784 1.799 0 0 1-1.784-1.799a1.784 1.799 0 0 1 1.784-1.799a1.784 1.799 0 0 1 1.783 1.799M20.582 1.427a1.415 1.427 0 0 1-1.415 1.428a1.415 1.427 0 0 1-1.416-1.428A1.415 1.427 0 0 1 19.167 0a1.415 1.427 0 0 1 1.415 1.427M4.992 3.336A1.047 1.056 0 0 1 3.946 4.39a1.047 1.056 0 0 1-1.047-1.055A1.047 1.056 0 0 1 3.946 2.28a1.047 1.056 0 0 1 1.046 1.056m7.336 1.517c3.769 0 7.06 1.38 8.768 3.424a9.36 9.36 0 0 0-3.393-4.547a9.24 9.24 0 0 0-5.377-1.728A9.24 9.24 0 0 0 6.95 3.73a9.36 9.36 0 0 0-3.394 4.547c1.713-2.04 5.004-3.424 8.772-3.424m.001 13.295c-3.768 0-7.06-1.381-8.768-3.425a9.36 9.36 0 0 0 3.394 4.547A9.24 9.24 0 0 0 12.33 21a9.24 9.24 0 0 0 5.377-1.729a9.36 9.36 0 0 0 3.393-4.547c-1.712 2.044-5.003 3.425-8.772 3.425Z" /></svg>
|
||||||
|
|
||||||
warning: <svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"></path></svg>
|
warning: <svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"></path></svg>
|
||||||
one: <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="-1 0 19 19"><path d="M16.417 9.6A7.917 7.917 0 1 1 8.5 1.683 7.917 7.917 0 0 1 16.417 9.6zM9.666 6.508H8.248L6.09 8.09l.806 1.103 1.222-.945v4.816h1.547z"></path></svg>
|
one: <svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="-1 0 19 19"><path d="M16.417 9.6A7.917 7.917 0 1 1 8.5 1.683 7.917 7.917 0 0 1 16.417 9.6zM9.666 6.508H8.248L6.09 8.09l.806 1.103 1.222-.945v4.816h1.547z"></path></svg>
|
||||||
cards: <svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M6 6.878V6a2.25 2.25 0 0 1 2.25-2.25h7.5A2.25 2.25 0 0 1 18 6v.878m-12 0c.235-.083.487-.128.75-.128h10.5c.263 0 .515.045.75.128m-12 0A2.25 2.25 0 0 0 4.5 9v.878m13.5-3A2.25 2.25 0 0 1 19.5 9v.878m0 0a2.246 2.246 0 0 0-.75-.128H5.25c-.263 0-.515.045-.75.128m15 0A2.25 2.25 0 0 1 21 12v6a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 18v-6c0-.98.626-1.813 1.5-2.122"></path></svg>
|
cards: <svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M6 6.878V6a2.25 2.25 0 0 1 2.25-2.25h7.5A2.25 2.25 0 0 1 18 6v.878m-12 0c.235-.083.487-.128.75-.128h10.5c.263 0 .515.045.75.128m-12 0A2.25 2.25 0 0 0 4.5 9v.878m13.5-3A2.25 2.25 0 0 1 19.5 9v.878m0 0a2.246 2.246 0 0 0-.75-.128H5.25c-.263 0-.515.045-.75.128m15 0A2.25 2.25 0 0 1 21 12v6a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 18v-6c0-.98.626-1.813 1.5-2.122"></path></svg>
|
||||||
|
224
exampleSite/assets/example.ipynb
Normal file
224
exampleSite/assets/example.ipynb
Normal file
File diff suppressed because one or more lines are too long
@ -24,5 +24,6 @@ Hextra provides a collection of beautiful shortcodes to enhance your content.
|
|||||||
Additional shortcodes provided by Hugo and Hextra:
|
Additional shortcodes provided by Hugo and Hextra:
|
||||||
|
|
||||||
{{< cards >}}
|
{{< cards >}}
|
||||||
|
{{< card link="jupyter" title="Jupyter Notebook" icon="jupyter" tag="alpha" >}}
|
||||||
{{< card link="others" title="Others" icon="view-grid" >}}
|
{{< card link="others" title="Others" icon="view-grid" >}}
|
||||||
{{< /cards >}}
|
{{< /cards >}}
|
||||||
|
79
exampleSite/content/docs/guide/shortcodes/jupyter.md
Normal file
79
exampleSite/content/docs/guide/shortcodes/jupyter.md
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
---
|
||||||
|
title: "Jupyter Notebook Component"
|
||||||
|
linktitle: "Jupyter Notebook"
|
||||||
|
math: true
|
||||||
|
sidebar:
|
||||||
|
exclude: true
|
||||||
|
---
|
||||||
|
|
||||||
|
{{< callout >}}Experimental feature to include Jupyter Notebooks via a shortcode. Note that not all cell types are supported.{{< /callout >}}
|
||||||
|
|
||||||
|
[Jupyter Notebook](https://jupyter.org/) is a language-agnostic HTML notebook application for [Project Jupyter](https://jupyter.org/). It allows you to create and share documents that contain live code, equations, visualizations, and narrative text.
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
### Using a local notebook
|
||||||
|
|
||||||
|
To use the Jupyter Notebook shortcode, you need to have a Jupyter Notebook file in your project. Similar to how you would [add images](../../organize-files#add-images) to the project, you can add Jupyter Notebooks to the `assets` folder.
|
||||||
|
|
||||||
|
{{< filetree/container >}}
|
||||||
|
{{< filetree/folder name="assets" >}}
|
||||||
|
{{< filetree/file name="notebook.ipynb" >}}
|
||||||
|
{{< /filetree/folder >}}
|
||||||
|
{{< filetree/folder name="content" >}}
|
||||||
|
{{< filetree/folder name="docs" >}}
|
||||||
|
{{< filetree/file name="my-page.md" >}}
|
||||||
|
{{< /filetree/folder >}}
|
||||||
|
{{< /filetree/folder >}}
|
||||||
|
{{< /filetree/container >}}
|
||||||
|
|
||||||
|
Include the Jupyter Notebook in the page using the `jupyter` shortcode:
|
||||||
|
|
||||||
|
```markdown {filename="content/docs/my-page.md"}
|
||||||
|
---
|
||||||
|
title: My Page
|
||||||
|
math: true
|
||||||
|
---
|
||||||
|
|
||||||
|
{{%/* jupyter "notebook.ipynb" */%}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, you can utilize the [page bundles][page-bundles] feature of Hugo to organize the Jupyter Notebooks together with the Markdown file.
|
||||||
|
|
||||||
|
{{< filetree/container >}}
|
||||||
|
{{< filetree/folder name="content" >}}
|
||||||
|
{{< filetree/folder name="docs" >}}
|
||||||
|
{{< filetree/folder name="my-page" >}}
|
||||||
|
{{< filetree/file name="index.md" >}}
|
||||||
|
{{< filetree/file name="notebook.ipynb" >}}
|
||||||
|
{{< /filetree/folder >}}
|
||||||
|
{{< /filetree/folder >}}
|
||||||
|
{{< /filetree/folder >}}
|
||||||
|
{{< /filetree/container >}}
|
||||||
|
|
||||||
|
```markdown {filename="content/docs/my-page/index.md"}
|
||||||
|
---
|
||||||
|
title: My Page
|
||||||
|
math: true
|
||||||
|
---
|
||||||
|
|
||||||
|
{{%/* jupyter "notebook.ipynb" */%}}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using a remote notebook
|
||||||
|
|
||||||
|
You can also use a remote notebook by providing the URL to the notebook file. For example, to include [What is the Jupyter Notebook](https://github.com/jupyter/notebook/blob/main/docs/source/examples/Notebook/What%20is%20the%20Jupyter%20Notebook.ipynb) notebook in the page, you can use the following shortcode:
|
||||||
|
|
||||||
|
```
|
||||||
|
{{%/* jupyter "https://raw.githubusercontent.com/jupyter/notebook/main/docs/source/examples/Notebook/What%20is%20the%20Jupyter%20Notebook.ipynb" */%}}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example Notebook
|
||||||
|
|
||||||
|
{{< callout type="info" >}}The following is an example of a notebook file that is included in the project assets folder.{{< /callout >}}
|
||||||
|
|
||||||
|
{{% jupyter "example.ipynb" %}}
|
||||||
|
|
||||||
|
[page-bundles]: https://gohugo.io/content-management/page-bundles/#leaf-bundles
|
@ -191,6 +191,7 @@
|
|||||||
"data-[state=selected]:hx-block",
|
"data-[state=selected]:hx-block",
|
||||||
"data-[state=selected]:hx-border-primary-500",
|
"data-[state=selected]:hx-border-primary-500",
|
||||||
"data-[state=selected]:hx-text-primary-600",
|
"data-[state=selected]:hx-text-primary-600",
|
||||||
|
"dataframe",
|
||||||
"filename",
|
"filename",
|
||||||
"first:hx-mt-0",
|
"first:hx-mt-0",
|
||||||
"focus:hx-bg-white",
|
"focus:hx-bg-white",
|
||||||
@ -222,6 +223,9 @@
|
|||||||
"hextra-filetree",
|
"hextra-filetree",
|
||||||
"hextra-filetree-folder",
|
"hextra-filetree-folder",
|
||||||
"hextra-footer",
|
"hextra-footer",
|
||||||
|
"hextra-jupyter-code-cell",
|
||||||
|
"hextra-jupyter-code-cell-outputs",
|
||||||
|
"hextra-jupyter-code-cell-outputs-container",
|
||||||
"hextra-pdf",
|
"hextra-pdf",
|
||||||
"hextra-scrollbar",
|
"hextra-scrollbar",
|
||||||
"hextra-sidebar-collapsible-button",
|
"hextra-sidebar-collapsible-button",
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>{{ .Title }}</h1>
|
{{ if .Title }}<h1>{{ .Title }}</h1>{{ end }}
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
<div class="hx-mt-16"></div>
|
<div class="hx-mt-16"></div>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
||||||
<br class="hx-mt-1.5 hx-text-sm" />
|
<br class="hx-mt-1.5 hx-text-sm" />
|
||||||
<h1 class="hx-text-center hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>
|
{{ if .Title }}<h1 class="hx-text-center hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>{{ end }}
|
||||||
<div class="hx-mb-16"></div>
|
<div class="hx-mb-16"></div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" false) }}
|
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" false) }}
|
||||||
<article class="hx-w-full hx-break-words hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-pt-4 hx-pb-8 hx-pl-[max(env(safe-area-inset-left),1.5rem)] hx-pr-[max(env(safe-area-inset-left),1.5rem)]">
|
<article class="hx-w-full hx-break-words hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-pt-4 hx-pb-8 hx-pl-[max(env(safe-area-inset-left),1.5rem)] hx-pr-[max(env(safe-area-inset-left),1.5rem)]">
|
||||||
<br class="hx-mt-1.5 hx-text-sm" />
|
<br class="hx-mt-1.5 hx-text-sm" />
|
||||||
<h1 class="hx-text-center hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>
|
{{ if .Title }}<h1 class="hx-text-center hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>{{ end }}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
||||||
<br class="hx-mt-1.5 hx-text-sm" />
|
<br class="hx-mt-1.5 hx-text-sm" />
|
||||||
<h1 class="hx-text-center hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>
|
{{ if .Title }}<h1 class="hx-text-center hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>{{ end }}
|
||||||
<div class="content">{{ .Content }}</div>
|
<div class="content">{{ .Content }}</div>
|
||||||
{{- $pages := partial "utils/sort-pages" (dict "page" . "by" site.Params.blog.list.sortBy "order" site.Params.blog.list.sortOrder) -}}
|
{{- $pages := partial "utils/sort-pages" (dict "page" . "by" site.Params.blog.list.sortBy "order" site.Params.blog.list.sortOrder) -}}
|
||||||
{{- range $pages }}
|
{{- range $pages }}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
||||||
{{ partial "breadcrumb.html" . }}
|
{{ partial "breadcrumb.html" . }}
|
||||||
<h1 class="hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>
|
{{ if .Title }}<h1 class="hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>{{ end }}
|
||||||
<div class="hx-mt-4 hx-mb-16 hx-text-gray-500 hx-text-sm hx-flex hx-items-center hx-flex-wrap hx-gap-y-2">
|
<div class="hx-mt-4 hx-mb-16 hx-text-gray-500 hx-text-sm hx-flex hx-items-center hx-flex-wrap hx-gap-y-2">
|
||||||
{{- with $date := .Date }}<span class="hx-mr-1">{{ partial "utils/format-date" $date }}</span>{{ end -}}
|
{{- with $date := .Date }}<span class="hx-mr-1">{{ partial "utils/format-date" $date }}</span>{{ end -}}
|
||||||
{{- $lazyLoading := site.Params.enableImageLazyLoading | default true -}}
|
{{- $lazyLoading := site.Params.enableImageLazyLoading | default true -}}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
||||||
{{ partial "breadcrumb.html" . }}
|
{{ partial "breadcrumb.html" . }}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>{{ .Title }}</h1>
|
{{ if .Title }}<h1>{{ .Title }}</h1>{{ end }}
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
{{ partial "components/last-updated.html" . }}
|
{{ partial "components/last-updated.html" . }}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
||||||
{{ partial "breadcrumb.html" . }}
|
{{ partial "breadcrumb.html" . }}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>{{ .Title }}</h1>
|
{{ if .Title }}<h1>{{ .Title }}</h1>{{ end }}
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
{{ partial "components/last-updated.html" . }}
|
{{ partial "components/last-updated.html" . }}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{ partial "toc.html" . }}
|
{{ partial "toc.html" . }}
|
||||||
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
<article class="hx-w-full hx-break-words hx-flex hx-min-h-[calc(100vh-var(--navbar-height))] hx-min-w-0 hx-justify-center hx-pb-8 hx-pr-[calc(env(safe-area-inset-right)-1.5rem)]">
|
||||||
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
<main class="hx-w-full hx-min-w-0 hx-max-w-6xl hx-px-6 hx-pt-4 md:hx-px-12">
|
||||||
<h1 class="hx-text-center hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>
|
{{ if .Title }}<h1 class="hx-text-center hx-mt-2 hx-text-4xl hx-font-bold hx-tracking-tight hx-text-slate-900 dark:hx-text-slate-100">{{ .Title }}</h1>{{ end }}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
{{- range site.Menus.sidebar }}
|
|
||||||
{{- $name := or (T .Identifier) .Name }}
|
|
||||||
{{- if eq .Params.type "separator" }}
|
|
||||||
<li class="[word-break:break-word] hx-mt-5 hx-mb-2 hx-px-2 hx-py-1.5 hx-text-sm hx-font-semibold hx-text-gray-900 first:hx-mt-0 dark:hx-text-gray-100">
|
|
||||||
<span class="hx-cursor-default">{{ $name }}</span>
|
|
||||||
</li>
|
|
||||||
{{- else }}
|
|
||||||
<li>
|
|
||||||
{{- partial "components/sidebar/item-link" (dict "active" false "title" $name "link" (.URL | relLangURL)) -}}
|
|
||||||
</li>
|
|
||||||
{{- end }}
|
|
||||||
{{- end -}}
|
|
@ -1,5 +0,0 @@
|
|||||||
<span class="hextra-sidebar-collapsible-button">
|
|
||||||
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" class="hx-h-[18px] hx-min-w-[18px] hx-rounded-sm hx-p-0.5 hover:hx-bg-gray-800/5 dark:hover:hx-bg-gray-100/5">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" class="hx-origin-center hx-transition-transform rtl:-hx-rotate-180"></path>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
@ -1,51 +0,0 @@
|
|||||||
{{- $context := . -}}
|
|
||||||
|
|
||||||
{{- $pages := union .RegularPages .Sections -}}
|
|
||||||
{{- $pages = where $pages "Params.sidebar.exclude" "!=" true -}}
|
|
||||||
|
|
||||||
{{- $data := slice -}}
|
|
||||||
|
|
||||||
{{- range $pages.ByWeight -}}
|
|
||||||
{{ $structure := (partial "sidebar/section-walk" .) | unmarshal -}}
|
|
||||||
{{ $data = $data | append $structure -}}
|
|
||||||
{{ end -}}
|
|
||||||
|
|
||||||
{{- define "partials/sidebar/section-walk" -}}
|
|
||||||
{{- with . -}}
|
|
||||||
{
|
|
||||||
"title": "{{ partial "utils/title" . }}",
|
|
||||||
"link": "{{ .RelPermalink }}",
|
|
||||||
"toc": {{ partial "sidebar/section-page-toc" . }},
|
|
||||||
"open": {{ .Params.sidebar.open | default false }}
|
|
||||||
{{- if .IsSection }},
|
|
||||||
"items": [
|
|
||||||
{{ $pages := union .RegularPages .Sections -}}
|
|
||||||
{{ $pages = where $pages "Params.sidebar.exclude" "!=" true -}}
|
|
||||||
{{ range $index, $page := $pages.ByWeight -}}
|
|
||||||
{{ partial "sidebar/section-walk" . }}{{ if not (ge $index (sub (len $pages) 1)) }},{{ end -}}
|
|
||||||
{{ end -}}
|
|
||||||
]
|
|
||||||
{{ end -}}
|
|
||||||
}
|
|
||||||
{{- end }}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- define "partials/sidebar/section-page-toc" -}}
|
|
||||||
{{/* Get level 2 headings list used mainly for mobile navigation */}}
|
|
||||||
[
|
|
||||||
{{- with .Fragments.Headings -}}
|
|
||||||
{{/* Loop over level 1 headings */}}
|
|
||||||
{{- range . }}
|
|
||||||
{{- with .Headings }}
|
|
||||||
{{ $headings := . }}
|
|
||||||
{{- range $index, $heading := $headings }}
|
|
||||||
{{ $heading.Title | jsonify (dict "noHTMLEscape" true) }}
|
|
||||||
{{- if not (ge $index (sub (len $headings) 1)) }},{{ end -}}
|
|
||||||
{{ end -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{ end -}}
|
|
||||||
{{- end -}}
|
|
||||||
]
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{ return ($data | jsonify (dict "noHTMLEscape" true)) }}
|
|
@ -1,20 +0,0 @@
|
|||||||
{{/* Get section sidebar config from Hugo `data` directory
|
|
||||||
|
|
||||||
If the site is multilingual, the sidebar data is stored in a language-specific
|
|
||||||
directory. For example, the English sidebar data is stored in `data/en/sidebar.yaml`.
|
|
||||||
*/}}
|
|
||||||
{{ $data := "" }}
|
|
||||||
{{ $section := .Section | default "index" }}
|
|
||||||
{{ $filename := "sidebar" }}
|
|
||||||
|
|
||||||
{{ if hugo.IsMultilingual }}
|
|
||||||
{{ with (index site.Data site.Language.Lang $filename $section) }}
|
|
||||||
{{ $data = . }}
|
|
||||||
{{ end }}
|
|
||||||
{{ else }}
|
|
||||||
{{ with (index site.Data $filename $section) }}
|
|
||||||
{{ $data = . }}
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ return $data }}
|
|
@ -1,18 +0,0 @@
|
|||||||
{{- $external := strings.HasPrefix .link "http" -}}
|
|
||||||
|
|
||||||
{{- $activeClass := cond (.active) "active" "inactive" -}}
|
|
||||||
|
|
||||||
|
|
||||||
<a
|
|
||||||
class="hextra-sidebar-item-link {{ $activeClass }} [-webkit-tap-highlight-color:transparent] [-webkit-touch-callout:none] [word-break:break-word]"
|
|
||||||
href="{{ .link }}"
|
|
||||||
{{ if $external }}target="_blank" rel="noreferer"{{ end }}
|
|
||||||
>
|
|
||||||
{{- .title -}}
|
|
||||||
{{- with .context }}
|
|
||||||
{{- if or .RegularPages .Sections }}
|
|
||||||
{{- partialCached "components/sidebar/collapsible-button" . }}
|
|
||||||
{{- end }}
|
|
||||||
{{ end -}}
|
|
||||||
{{- with .items }}{{- partialCached "components/sidebar/collapsible-button" site.Home }}{{ end -}}
|
|
||||||
</a>
|
|
@ -1,16 +0,0 @@
|
|||||||
{{- $page := .page -}}
|
|
||||||
{{- $pageLink := $page.RelPermalink -}}
|
|
||||||
{{- $cached := .cached | default false }}
|
|
||||||
|
|
||||||
{{- range .data -}}
|
|
||||||
{{- $active := and (not $cached) (or (eq $pageLink .link) (eq (strings.TrimSuffix "/" $pageLink) .link)) -}}
|
|
||||||
{{- $containsPage := hasPrefix $pageLink .link -}}
|
|
||||||
{{- $shouldOpen := or (.open) $containsPage $active | default false -}}
|
|
||||||
|
|
||||||
<li class="hextra-sidebar-item {{ if $shouldOpen }}open{{ end }}">
|
|
||||||
{{- partial "components/sidebar/item-link" (dict "active" $active "title" .title "link" .link "items" .items) -}}
|
|
||||||
{{- if .items -}}
|
|
||||||
{{- partial "components/sidebar/render-items" (dict "items" .items "link" $pageLink "cached" $cached) -}}
|
|
||||||
{{- end -}}
|
|
||||||
</li>
|
|
||||||
{{ end }}
|
|
@ -1,21 +0,0 @@
|
|||||||
{{- $items := .items -}}
|
|
||||||
{{- $pageLink := .link -}}
|
|
||||||
{{- $cached := .cached | default false }}
|
|
||||||
|
|
||||||
|
|
||||||
<div class="ltr:hx-pr-0 hx-overflow-hidden">
|
|
||||||
<ul class="hextra-sidebar-item-list">
|
|
||||||
{{- range $items }}
|
|
||||||
{{- $active := and (not $cached) (or (eq $pageLink .link) (eq (strings.TrimSuffix "/" $pageLink) .link)) -}}
|
|
||||||
{{- $containsPage := hasPrefix $pageLink .link -}}
|
|
||||||
{{- $shouldOpen := or (.open) $containsPage $active | default false -}}
|
|
||||||
|
|
||||||
<li class="hextra-sidebar-item hx-flex hx-flex-col {{ if $shouldOpen }}open{{ end }}">
|
|
||||||
{{- partial "components/sidebar/item-link" (dict "active" $active "title" .title "link" .link "items" .items) -}}
|
|
||||||
{{- if .items -}}
|
|
||||||
{{- partial "components/sidebar/render-items" (dict "items" .items "link" $pageLink "cached" $cached) -}}
|
|
||||||
{{- end -}}
|
|
||||||
</li>
|
|
||||||
{{- end -}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
@ -4,7 +4,7 @@
|
|||||||
{{- $jsLang := resources.Get "js/lang.js" -}}
|
{{- $jsLang := resources.Get "js/lang.js" -}}
|
||||||
{{- $jsCodeCopy := resources.Get "js/code-copy.js" -}}
|
{{- $jsCodeCopy := resources.Get "js/code-copy.js" -}}
|
||||||
{{- $jsFileTree := resources.Get "js/filetree.js" -}}
|
{{- $jsFileTree := resources.Get "js/filetree.js" -}}
|
||||||
{{- $jsSidebar := resources.Get "js/sidebar.js" | resources.ExecuteAsTemplate "sidebar.js" . -}}
|
{{- $jsSidebar := resources.Get "js/sidebar.js" -}}
|
||||||
{{- $jsBackToTop := resources.Get "js/back-to-top.js" -}}
|
{{- $jsBackToTop := resources.Get "js/back-to-top.js" -}}
|
||||||
|
|
||||||
{{- $scripts := slice $jsTheme $jsMenu $jsCodeCopy $jsTabs $jsLang $jsFileTree $jsSidebar $jsBackToTop | resources.Concat "js/main.js" -}}
|
{{- $scripts := slice $jsTheme $jsMenu $jsCodeCopy $jsTabs $jsLang $jsFileTree $jsSidebar $jsBackToTop | resources.Concat "js/main.js" -}}
|
||||||
@ -60,12 +60,18 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
<script>
|
<script>
|
||||||
// TODO: make render options configurable
|
// TODO: make render options configurable
|
||||||
|
// Reference: https://katex.org/docs/autorender#api
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
renderMathInElement(document.body, {
|
renderMathInElement(document.body, {
|
||||||
delimiters: [
|
delimiters: [
|
||||||
{ left: "$$", right: "$$", display: true },
|
{ left: "$$", right: "$$", display: true },
|
||||||
{ left: "$", right: "$", display: false },
|
{ left: "$", right: "$", display: false },
|
||||||
{ left: "\\(", right: "\\)", display: false },
|
{ left: "\\(", right: "\\)", display: false },
|
||||||
|
{ left: "\\begin{equation}", right: "\\end{equation}", display: true },
|
||||||
|
{left: "\\begin{align}", right: "\\end{align}", display: true},
|
||||||
|
{left: "\\begin{alignat}", right: "\\end{alignat}", display: true},
|
||||||
|
{left: "\\begin{gather}", right: "\\end{gather}", display: true},
|
||||||
|
{left: "\\begin{CD}", right: "\\end{CD}", display: true},
|
||||||
{ left: "\\[", right: "\\]", display: true },
|
{ left: "\\[", right: "\\]", display: true },
|
||||||
],
|
],
|
||||||
throwOnError: false,
|
throwOnError: false,
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
{{- $context := .context -}}
|
|
||||||
|
|
||||||
{{- $disableSidebar := .disableSidebar | default false -}}
|
|
||||||
{{- $displayPlaceholder := .displayPlaceholder | default false -}}
|
|
||||||
|
|
||||||
{{- $sidebarClass := cond $disableSidebar (cond $displayPlaceholder "md:hx-hidden xl:hx-block" "md:hx-hidden") "md:hx-sticky" -}}
|
|
||||||
|
|
||||||
{{- $navRoot := cond (eq site.Home.Type "docs") site.Home $context.FirstSection -}}
|
|
||||||
{{- $pageURL := $context.RelPermalink -}}
|
|
||||||
|
|
||||||
{{- $data := slice -}}
|
|
||||||
{{- $dataMobile := slice -}}
|
|
||||||
|
|
||||||
{{- if (eq site.Params.page.sidebar.source "data") -}}
|
|
||||||
{{ $data = partialCached "components/sidebar/get-section-data" $context $context.Section }}
|
|
||||||
{{- $dataMobile = $data -}}
|
|
||||||
{{- else -}}
|
|
||||||
{{- $data = (partialCached "components/sidebar/generate-section-data" $navRoot $navRoot) | unmarshal -}}
|
|
||||||
{{- $dataMobile = (partialCached "components/sidebar/generate-section-data" site.Home site.Home) | unmarshal -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- $shouldCache := site.Params.page.sidebar.cache | default false -}}
|
|
||||||
|
|
||||||
{{/* EXPERIMENTAL */}}
|
|
||||||
{{- if .context.Params.sidebar.hide -}}
|
|
||||||
{{- $disableSidebar = true -}}
|
|
||||||
{{- $displayPlaceholder = true -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
<div class="mobile-menu-overlay [transition:background-color_1.5s_ease] hx-fixed hx-inset-0 hx-z-10 hx-bg-black/80 dark:hx-bg-black/60 hx-hidden"></div>
|
|
||||||
|
|
||||||
<aside class="hextra-sidebar-container hx-flex hx-flex-col print:hx-hidden md:hx-top-16 md:hx-shrink-0 md:hx-w-64 md:hx-self-start max-md:[transform:translate3d(0,-100%,0)] {{ $sidebarClass }}">
|
|
||||||
{{/* Search bar on small screen */}}
|
|
||||||
{{- partialCached "components/sidebar/mobile-search" . -}}
|
|
||||||
|
|
||||||
|
|
||||||
<div class="hextra-scrollbar hx-overflow-y-auto hx-overflow-x-hidden hx-p-4 hx-grow md:hx-h-[calc(100vh-var(--navbar-height)-var(--menu-height))]">
|
|
||||||
{{/* Mobile Navigation */}}
|
|
||||||
<ul class="hx-flex hx-flex-col hx-gap-1 md:hx-hidden">
|
|
||||||
{{- with $dataMobile -}}
|
|
||||||
{{- partial "components/sidebar/render-data" (dict "data" . "page" $context) -}}
|
|
||||||
{{- end -}}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{{/* Sidebar on large screen */}}
|
|
||||||
{{- if $disableSidebar -}}
|
|
||||||
{{- if $displayPlaceholder }}<div class="max-xl:hx-hidden hx-h-0 hx-w-64 hx-shrink-0"></div>{{ end -}}
|
|
||||||
{{ .context.Scratch.Set "enableFooterSwitches" true }}
|
|
||||||
{{- else -}}
|
|
||||||
<ul class="hx-flex hx-flex-col hx-gap-1 max-md:hx-hidden">
|
|
||||||
{{- with $data -}}
|
|
||||||
{{- if $shouldCache -}}
|
|
||||||
{{- partialCached "components/sidebar/render-data" (dict "data" . "page" $context "cached" $shouldCache) $navRoot -}}
|
|
||||||
{{- else -}}
|
|
||||||
{{- partial "components/sidebar/render-data" (dict "data" . "page" $context "cached" $shouldCache) -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- partialCached "components/sidebar/bottom" $context site.Home -}}
|
|
||||||
</ul>
|
|
||||||
{{ end -}}
|
|
||||||
</div>
|
|
||||||
{{- partial "components/sidebar/switches" (dict "context" $context "disableSidebar" $disableSidebar) -}}
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
{{- define "partials/components/sidebar/mobile-search" -}}
|
|
||||||
<div class="hx-px-4 hx-pt-4 md:hx-hidden">
|
|
||||||
{{- partialCached "search.html" . -}}
|
|
||||||
</div>
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- define "partials/components/sidebar/switches" -}}
|
|
||||||
{{- $context := .context -}}
|
|
||||||
{{- $disableSidebar := .disableSidebar -}}
|
|
||||||
{{/* Hide theme switch when sidebar is disabled */}}
|
|
||||||
{{ $switchesClass := cond $disableSidebar "md:hx-hidden" "" -}}
|
|
||||||
{{ $displayThemeToggle := (site.Params.theme.displayToggle | default true) -}}
|
|
||||||
|
|
||||||
{{ if or site.IsMultiLingual $displayThemeToggle }}
|
|
||||||
<div
|
|
||||||
class="{{ $switchesClass }} {{ with site.IsMultiLingual }}
|
|
||||||
hx-justify-end
|
|
||||||
{{ end }} hx-sticky hx-bottom-0 hx-bg-white dark:hx-bg-dark hx-mx-4 hx-py-4 hx-shadow-[0_-12px_16px_#fff] hx-flex hx-items-center hx-gap-2 dark:hx-border-neutral-800 dark:hx-shadow-[0_-12px_16px_#111] contrast-more:hx-border-neutral-400 contrast-more:hx-shadow-none contrast-more:dark:hx-shadow-none hx-border-t"
|
|
||||||
data-toggle-animation="show"
|
|
||||||
>
|
|
||||||
{{- with site.IsMultiLingual -}}
|
|
||||||
{{- partial "language-switch" (dict "context" $context "grow" true) -}}
|
|
||||||
{{- with $displayThemeToggle }}{{ partial "theme-toggle" (dict "hideLabel" true) }}{{ end -}}
|
|
||||||
{{- else -}}
|
|
||||||
{{- with $displayThemeToggle -}}
|
|
||||||
<div class="hx-flex hx-grow hx-flex-col">{{ partial "theme-toggle" }}</div>
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
</div>
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
81
layouts/shortcodes/jupyter.html
Normal file
81
layouts/shortcodes/jupyter.html
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
{{/* Render Jupyter Notebook */}}
|
||||||
|
{{- $path := .Get 0 -}}
|
||||||
|
{{- $data := "" -}}
|
||||||
|
{{- $page := .Page -}}
|
||||||
|
|
||||||
|
{{- $isLocal := not (urls.Parse $path).Scheme -}}
|
||||||
|
{{- $isPage := and (eq .Page.Kind "page") (not .Page.BundleType) -}}
|
||||||
|
|
||||||
|
{{/* https://gohugo.io/functions/transform/unmarshal/ */}}
|
||||||
|
{{- if (not $isLocal) -}}
|
||||||
|
{{- with resources.GetRemote $path -}}
|
||||||
|
{{- with unmarshal .Content -}}{{- $data = . -}}{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- errorf "Remote resource not found: %s" $path -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else if (not $isPage) -}}
|
||||||
|
{{- with .Page.Resources.Get $path -}}
|
||||||
|
{{- with unmarshal .Content -}}{{- $data = . -}}{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- errorf "Local resource not found: %s" $path -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- with resources.Get $path -}}
|
||||||
|
{{- with unmarshal .Content -}}{{- $data = . -}}{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- errorf "Local resource not found: %s" $path -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- $language := index $data "metadata" "language_info" "name" | default "python" -}}
|
||||||
|
|
||||||
|
{{- with index $data "cells" -}}
|
||||||
|
{{- range $cell := . -}}
|
||||||
|
{{- if eq (index $cell "cell_type") "code" -}}
|
||||||
|
{{- $source := index $cell "source" -}}
|
||||||
|
{{- $sourceContent := (cond (reflect.IsSlice $source) (delimit $source "") $source) -}}
|
||||||
|
{{- with ($sourceContent | strings.Chomp) -}}
|
||||||
|
{{ (printf "\n\n```%s\n%s\n```\n" $language .) | safeHTML -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
<div class="hextra-jupyter-code-cell hextra-scrollbar">
|
||||||
|
{{- $outputs := index $cell "outputs" -}}
|
||||||
|
{{- with $outputs -}}
|
||||||
|
<div class="hextra-jupyter-code-cell-outputs-container">
|
||||||
|
<div class="hextra-jupyter-code-cell-outputs">
|
||||||
|
{{- range $output := . -}}
|
||||||
|
{{- if eq (index $output "output_type") "display_data" -}}
|
||||||
|
{{- $data := index $output "data" -}}
|
||||||
|
{{- $image := index $data "image/png" -}}
|
||||||
|
{{- if $image -}}
|
||||||
|
<img src="data:image/png;base64,{{- $image -}}" alt="image" />
|
||||||
|
{{- end -}}
|
||||||
|
{{- else if eq (index $output "output_type") "stream" -}}
|
||||||
|
{{- $text := index $output "text" -}}
|
||||||
|
{{- $textContent := (cond (reflect.IsSlice $text) (delimit $text "") $text) -}}
|
||||||
|
<pre class="not-prose hx-text-sm">{{- $textContent -}}</pre>
|
||||||
|
{{- else if eq (index $output "output_type") "execute_result" -}}
|
||||||
|
{{- $data := index $output "data" -}}
|
||||||
|
{{- $text := index $data "text/plain" -}}
|
||||||
|
{{- $textContent := (cond (reflect.IsSlice $text) (delimit $text "") $text) -}}
|
||||||
|
<pre class="not-prose hx-text-sm">{{- $textContent -}}</pre>
|
||||||
|
{{- $html := index $data "text/html" -}}
|
||||||
|
{{- if $html -}}
|
||||||
|
{{- $htmlText := delimit $html "" -}}
|
||||||
|
<div>
|
||||||
|
{{- $htmlText | safeHTML -}}
|
||||||
|
</div>
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{- end -}}
|
||||||
|
</div>
|
||||||
|
{{- else if eq (index $cell "cell_type") "markdown" -}}
|
||||||
|
{{- $source := index $cell "source" }}
|
||||||
|
{{- $sourceContent := (cond (reflect.IsSlice $source) (delimit $source "") $source) }}
|
||||||
|
{{ (printf "\n%s\n" $sourceContent) | safeHTML }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
7
package-lock.json
generated
7
package-lock.json
generated
@ -980,11 +980,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/micromatch": {
|
"node_modules/micromatch": {
|
||||||
"version": "4.0.7",
|
"version": "4.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||||
"integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==",
|
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"braces": "^3.0.3",
|
"braces": "^3.0.3",
|
||||||
"picomatch": "^2.3.1"
|
"picomatch": "^2.3.1"
|
||||||
|
Reference in New Issue
Block a user