diff --git a/assets/js/theme/body.js b/assets/js/theme/body.js index e6d95ba15de290f1d37cfbdcacc5f821bbae15dc..ed5395dd8d303a3f351686ee46d0b180a7c2e4d2 100644 --- a/assets/js/theme/body.js +++ b/assets/js/theme/body.js @@ -1,3 +1,3 @@ window.addEventListener('load', () => { document.body.classList.add('is-loaded'); -}); +}); \ No newline at end of file diff --git a/assets/js/theme/design-system/dropdowns.js b/assets/js/theme/design-system/dropdowns.js index ec37cfdcd8368e670cc7687d73ba3682cb1a9fe7..7c62c3af337ffce34a1e8b716bfcdc040461d8f0 100644 --- a/assets/js/theme/design-system/dropdowns.js +++ b/assets/js/theme/design-system/dropdowns.js @@ -29,7 +29,7 @@ class Dropdown { } // Selectors -['.diplomas-select', '.dropdown-share'].map(selector => { +['.diplomas-select', '.dropdown-share', '.footer-i18n'].map(selector => { if (document.querySelector(selector)) { new Dropdown(selector); } diff --git a/assets/js/theme/design-system/search.js b/assets/js/theme/design-system/search.js new file mode 100644 index 0000000000000000000000000000000000000000..41252196d0e6d95fa22534b39642c065930e601a --- /dev/null +++ b/assets/js/theme/design-system/search.js @@ -0,0 +1,118 @@ +class Search { + constructor(button, pageFind) { + this.state = { + isOpened: false + }; + this.button = button; + this.element = document.querySelector('.search__modal'); + this.closeButton = this.element.querySelector('.search__close'); + this.searchInstance = pageFind; + + if (!this.element) { + return; + } + + this.input = this.element.querySelector('input'); + + this.listen(); + } + + listen() { + if (document.body.querySelector(".toc-cta")) { + this.button.classList.add('in-page-with-toc'); + } + this.button.addEventListener('click', () => { + this.toggle(true); + this.removedItems = this.element.querySelector('.pagefind-ui__suppressed', '.pagefind-ui__search-clear'); + if (this.removedItems) { + this.removedItems.remove(); + } + }); + this.closeButton.addEventListener('click', () => { + this.clearSearch(); + this.toggle(false); + }); + + window.addEventListener('keydown', (event) => { + if (event.keyCode === 27 || event.key === 'Escape') { + this.toggle(false); + this.button.focus(); + } else if (event.key === "Tab" && this.state.isOpened) { + this.innerFocus(event); + } + }); + } + + clearSearch() { + const button = this.element.querySelector('.pagefind-ui__button'); + const message = this.element.querySelector('.pagefind-ui__message'); + const results = this.element.querySelector('.pagefind-ui__results') + + this.input.value = ""; + this.searchInstance.triggerSearch(false); + + if (message) { + message.innerText = ""; + } + if (results) { + results.innerHTML = ""; + } + if (button) { + button.parentElement.removeChild(button); + } + } + innerFocus(event) { + const focusables = 'a, button, input, textarea, select, details, [tabindex], [contenteditable="true"]'; + const elements = this.element.querySelectorAll(focusables); + + const focusableInDialog = Array.from(elements).filter(element => element.tabIndex >= 0); + const firstFocusable = focusableInDialog[0]; + const lastFocusable = focusableInDialog.at(-1); + + if (!this.state.isOpened) { + return; + } + if (!this.element.contains(event.target) && event.shiftKey) { + lastFocusable.focus(); + event.preventDefault(); + } + else if (!this.element.contains(event.target)) { + firstFocusable.focus(); + event.preventDefault(); + } + } + + toggle(open = !this.state.isOpened) { + this.state.isOpened = open; + this.element.setAttribute('aria-hidden', !this.state.isOpened); + this.button.setAttribute('aria-expanded', this.state.isOpened); + + if (open) { + this.input = this.element.querySelector('input'); + this.input.focus(); + + document.body.style.overflow = 'hidden'; + } else { + document.body.style.overflow = 'unset'; + } + } +} + +// Selectors +window.addEventListener('DOMContentLoaded', () => { + const pageFindSearch = document.querySelector("#search"); + + if (typeof PagefindUI == "undefined") return; + + if (pageFindSearch) { + let pageFind = new PagefindUI({ + element: pageFindSearch, + showSubResults: true + }); + (function () { + const searchButton = document.querySelector(".pagefind-ui__toggle"); + new Search(searchButton, pageFind); + })(); + } + +}); diff --git a/assets/js/theme/index.js b/assets/js/theme/index.js index fb45ea691fb50f80b315fdef0e644c8327d1458b..f35a048561ffdd656eaf9f86902397e3645d645d 100644 --- a/assets/js/theme/index.js +++ b/assets/js/theme/index.js @@ -4,6 +4,7 @@ import './design-system/dropdowns'; import './design-system/font'; import './design-system/mainMenu'; import './design-system/modal'; +import './design-system/search'; import './design-system/toc'; import './blocks/keyFigures'; import './blocks/organizations'; diff --git a/assets/sass/_theme/_utils.sass b/assets/sass/_theme/_utils.sass index a19eb3280bafdca565a32abed40f011e10dbf7a0..85ea8182905a117bb64f96de16091358705694e6 100644 --- a/assets/sass/_theme/_utils.sass +++ b/assets/sass/_theme/_utils.sass @@ -267,7 +267,7 @@ appearance: none background: transparent border: none - border-radius: none + border-radius: 0 cursor: pointer user-select: none &:active, @@ -389,6 +389,28 @@ figcaption .credit-content display: block +@mixin dropdown-i18n + position: relative + .dropdown-menu + margin-top: $header-nav-padding-y + padding-left: $spacing1 + padding-bottom: $spacing0 + padding-top: $spacing0 + padding-right: $spacing1 + right: 0 + li a + padding-bottom: half($spacing0) + padding-top: half($spacing0) + display: block + &.is-checked + display: flex + justify-content: space-between + align-items: center + gap: $spacing2 + text-decoration: none !important + @include icon(caret, after) + transform: rotate(-14deg) skewX(-30deg) + // https://gist.github.com/jonathantneal/d0460e5c2d5d7f9bc5e6 @function str-replace($string, $search, $replace: "") $index: str-index($string, $search) diff --git a/assets/sass/_theme/design-system/footer.sass b/assets/sass/_theme/design-system/footer.sass index 198e86f965b145eece9227630fd3ec06c75fff76..423f071bdd29efc96159ae91e4d2844ffd462a93 100644 --- a/assets/sass/_theme/design-system/footer.sass +++ b/assets/sass/_theme/design-system/footer.sass @@ -31,6 +31,51 @@ footer#document-footer &-credit display: block margin-top: $spacing0 + &-search + padding-top: $spacing0 !important + &-i18n + @include dropdown-i18n + button + @include button-reset + @include icon(caret-bottom, after) + @include meta + align-items: center + cursor: pointer + display: flex + justify-content: start + padding-left: 0 + text-align: left + &:focus, + &:focus-visible + box-shadow: none + &[aria-expanded="true"] + background: $color-background + justify-content: space-between + width: 100% + + .dropdown-menu + animation-duration: unset + &::after + transform: rotate(-180deg) + &::before + margin-right: $spacing0 + &::after + margin-left: $spacing0 + button[aria-expanded="true"], + .dropdown-menu + outline: px2rem(10) solid $color-background + min-width: $spacing4 + .dropdown-menu + @include meta + background: $color-background + @include media-breakpoint-up(desktop) + left: 0 + margin-top: px2rem(17) + max-height: calc(100vh - var(--header-height)) + overflow: auto + padding: 0 + position: absolute + width: fit-content + @if $footer-icons-enabled &-social .nav-social + .site-links diff --git a/assets/sass/_theme/design-system/header.sass b/assets/sass/_theme/design-system/header.sass index 67a35ae766bbc985d0c54ee3774c46a766c9478c..1b26ef828d98ca8ff5bf7cb466e6c86b8510eb59 100644 --- a/assets/sass/_theme/design-system/header.sass +++ b/assets/sass/_theme/design-system/header.sass @@ -96,7 +96,7 @@ header#document-header display: flex flex-wrap: wrap justify-content: space-between - button[type="button"] + button[type="button"]:not(.pagefind-ui__button) @include button-reset display: none border: 0 @@ -105,9 +105,6 @@ header#document-header position: relative text-transform: uppercase line-height: 1 - @include media-breakpoint-down(desktop) - display: flex - align-items: center &:focus box-shadow: none &:focus-visible @@ -115,6 +112,9 @@ header#document-header outline-offset: 5px outline-style: dashed outline-width: 1px + @include media-breakpoint-down(desktop) + display: flex + align-items: center span:first-of-type @include meta font-size: 14px diff --git a/assets/sass/_theme/design-system/nav.sass b/assets/sass/_theme/design-system/nav.sass index f3b22f7eb456fca60e8bfd1a7cf11f95a21e65dc..58c3952c392128820300e631e573549b29860a8f 100644 --- a/assets/sass/_theme/design-system/nav.sass +++ b/assets/sass/_theme/design-system/nav.sass @@ -131,31 +131,12 @@ margin-top: $spacing1 .header-i18n - position: relative - [role="button"] + @include dropdown-i18n + [role="button"], @include icon(globe, after) &[aria-expanded][aria-expanded="true"] &::after transform: none - .dropdown-menu - margin-top: $header-nav-padding-y - padding-left: $spacing1 - padding-bottom: $spacing0 - padding-top: $spacing0 - padding-right: $spacing1 - right: 0 - li a - padding-bottom: half($spacing0) - padding-top: half($spacing0) - display: block - &.is-checked - display: flex - justify-content: space-between - align-items: center - gap: $spacing2 - text-decoration: none !important - @include icon(caret, after) - transform: rotate(-14deg) skewX(-30deg) @include media-breakpoint-down(desktop) &.is-opened diff --git a/assets/sass/_theme/design-system/search.sass b/assets/sass/_theme/design-system/search.sass new file mode 100644 index 0000000000000000000000000000000000000000..c5e2b145c9f7ff796c737b5f29103d90558fcbce --- /dev/null +++ b/assets/sass/_theme/design-system/search.sass @@ -0,0 +1,181 @@ +.pagefind-ui__toggle, +.pagefind-ui__button, +.search__close + @include button-reset + @include meta + &:focus + box-shadow: none +.pagefind-ui__toggle + @include icon-block(search, after) + cursor: pointer + padding: half($spacing0) $spacing0 + text-align: left + box-shadow: none + span, + &::after + display: inline + &::after + font-size: $body-size-desktop + line-height: inherit + margin-left: px2rem(8) + @include media-breakpoint-down(desktop) + &.pagefind-menu + border-bottom: 1px solid #adb5bd + padding: $spacing1 0 + width: 100% + @include media-breakpoint-up(desktop) + &.without-text + span + display: none + &::after + margin-left: 0 +.search__close + @include icon-block(close, after) + position: fixed + right: $spacing3 + padding: 0 + z-index: 9 + &::after + display: inline-flex + justify-content: center + margin-left: $spacing0 + width: px2rem(15) + @include media-breakpoint-down(desktop) + right: $spacing1 + top: half($spacing0) +#search + background: $color-background + height: 100vh + left: 0 + padding-bottom: $spacing3 + padding-left: $spacing1 + padding-right: $spacing1 + padding-top: $spacing4 + position: fixed + overflow: auto + top: 0 + width: 100vw + z-index: 80 + @include media-breakpoint-up(desktop) + padding-right: $spacing3 + padding-left: $spacing3 + padding-top: calc(#{half($spacing3)} - #{half($spacing0)} + #{px2rem(2)}) + &[aria-hidden=true] + display: none + .pagefind-ui + &::before + content: "" + background: $color-background + height: calc(#{$spacing3} + #{$spacing1} + #{$spacing1}) + left: 0 + position: fixed + top: 0 + width: 100% + z-index: 5 + @include media-breakpoint-down(desktop) + height: calc(#{$spacing3} + #{half($spacing0)} + #{$spacing4}) + &__form + @include icon(search, after) + &::after + padding-right: px2rem(2) + position: fixed + pointer-events: none + transform: translate(0,20%) + z-index: 9 + @include media-breakpoint-down(desktop) + right: $spacing1 + top: calc(#{$spacing4} + #{half($spacing0)}) + &__search-input + border-left: 0 + border-right: 0 + border-radius: 0 + border-top: 0 + padding-left: 0 + padding-right: half($spacing1) !important + position: fixed + z-index: 6 + @include media-breakpoint-down(desktop) + margin-bottom: $spacing1 + &__button[type="button"] + @include button-reset + @include link($color-text) + margin-top: $spacing2 + padding: 0 + &__message + @include meta + color: $color-text-alt + text-align: right + z-index: 11 + position: fixed + top: calc(#{half($spacing4)} + #{half($spacing1)}) + &__search-clear, + &__suppressed + display: none + pointer-events: none + &__drawer + position: relative + &__result + list-style: none + position: relative + &-thumb + grid-column: 1/4 + > * + aspect-ratio: 3/2 + object-fit: cover + @include media-breakpoint-down(desktop) + display: none + + li + margin-top: half($spacing3) + @include media-breakpoint-up(desktop) + @include grid + &-inner + grid-column: 4/13 + &__result-excerpt mark + background-color: $color-accent + color: $color-background + &__result-title a + @include h4 + @include stretched-link + @include media-breakpoint-up(desktop) + &__form + position: relative + width: col(8) + &::after + left: calc(#{col(8)} - #{$spacing2} + #{$spacing0}) + top: calc(#{$spacing2} - #{$spacing0}) + &__search-input, + &__message + width: calc(#{col(8,12)} - #{$spacing3} - #{$spacing1}) + &__results-area + padding-top: calc(#{$spacing4} - #{$spacing1}) + @include media-breakpoint-down(desktop) + &__search-input, + &__message + width: calc(100% - #{$spacing2}) + &__message + top: calc(#{$spacing4} + #{$spacing2}) + &__results-area + padding-top: calc(#{$spacing3} + #{half($spacing0)}) + +.pagefind-fixed + background: $color-background-alt + bottom: 0 + left: $spacing3 + min-width: calc(#{$spacing3} * 3) + position: fixed + z-index: 10 + &::after + position: absolute + right: $spacing0 + @include media-breakpoint-down(desktop) + left: 0 + width: 100vw + &.in-page-with-toc + background: $color-background + border-top: 1px solid #eee + bottom: px2rem(44) +footer#document-footer .footer-search + .pagefind-footer + padding: 0 + #search + margin-top: 0 \ No newline at end of file diff --git a/assets/sass/_theme/hugo-osuny.sass b/assets/sass/_theme/hugo-osuny.sass index 72e93d1eb2b30c2bcb446ef869c4db17ed389647..da127cc095b9451da9e961ad2f4818e8d04d4561 100644 --- a/assets/sass/_theme/hugo-osuny.sass +++ b/assets/sass/_theme/hugo-osuny.sass @@ -26,6 +26,7 @@ @import "design-system/image" @import "design-system/pagination" @import "design-system/nav" +@import "design-system/search" @import "design-system/table" @import "design-system/table_of_contents" @import "design-system/top" diff --git a/bin/osuny.js b/bin/osuny.js new file mode 100644 index 0000000000000000000000000000000000000000..d79b4ab65fc54268931e5ba86745da72bb50591d --- /dev/null +++ b/bin/osuny.js @@ -0,0 +1,69 @@ +#! /usr/bin/env node + +const shell = require("shelljs"); + +console.log(` + \n .=*#%%#*= -*#%%#*=. =+- ++. .+ .+#%%#+. :++ -+- + \n :@@=:..:+@@. #@#:..:+@@. *@* @@: -@#@+:..-@@- -@@ *@* + \n +@* %@= .@@. %@= *@* @@: -@@. *@* -@@ *@* + \n +@* %@= %@* *%= *@* @@: -@@ *@* -@@ *@* + \n +@* %@= +@@= *@* @@: -@@ *@* -@@ *@* + \n +@* %@= .+@@+. *@* @@: -@@ *@* -@@ *@* + \n +@* %@= .+@@+. *@* @@: -@@ *@* .@@=. :@@= + \n +@* %@= == +@@: *@* @@: -@@ *@* .+%@@@@%*- + \n +@* %@= .@@. +@# *@* .@@: -@@ *@* @@- + \n =@% .@@- @@- #@# +@# :#@@: -@@ *@* @@- + \n =%@%##%@%= :#@%##%@@* *@@##@%=:@: :@@ *@+ %@- + \n .:.. ..:. ... + \n `); + +const command = process.argv[2]; + +if (command === "watch") { + console.log("watch"); + shell.exec("hugo server") +} + +if (command === "dev") { + console.log("dev"); + shell.exec("hugo"); + shell.exec("npx pagefind --site public --output-subdir ../static/pagefind") + shell.exec("hugo server") +} + +if (command === "build") { + console.log("build"); + shell.exec("hugo"); + shell.exec("npm_config_yes=true npx pagefind --site public"); +} + +if (command === "update") { + console.log("update"); + shell.exec("git pull --recurse-submodules --depth 1"); + shell.exec("git submodule update --remote"); +} + +if (command === "setup-example") { + console.log("setup-example"); + shell.exec("git submodule add https://github.com/noesya/osuny-example"); +} + +if (command === "server-example") { + console.log("server-example"); + shell.exec("hugo server --config osuny-example/config/example/config.yaml"); +} + +if (command === "example") { + console.log("example"); + shell.exec("yarn setup-example > /dev/null || yarn update"); + shell.exec("yarn server-example"); +} + +if (command === "update-theme") { + console.log("update-theme"); + shell.exec("cd themes/osuny-hugo-theme-aaa"); + shell.exec("git checkout main"); + shell.exec("git pull"); + shell.exec("cd ../.."); + shell.exec("yarn upgrade"); +} diff --git a/config.yaml b/config.yaml index 5ae5b4988edfbaaf4a961c1302c7bd26422eae3f..08b370d17b1c6e6a098a8244735a7d2666e56e46 100644 --- a/config.yaml +++ b/config.yaml @@ -18,6 +18,10 @@ params: position: hero-start # hero-start | hero-end | after-hero | none summary: position: content # content | hero + search: + active: true + position: menu # menu | fixed | footer + enable_text: false home: toc: disabled: true diff --git a/i18n/en.yml b/i18n/en.yml index 83c9383265707e051c4d74a183b73c955ae7f6d2..d168f29290fd3d9e8899e4298a6e28d88e2714b8 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -54,6 +54,9 @@ commons: search: Go to search shortcut_navigation: Navigation d'accès rapide transcription: Transcription + search: + title: Search + close: Close search backtotop: Back to top biography: Biography breadcrumb: Breadcrumb diff --git a/i18n/fr.yml b/i18n/fr.yml index 615a3364eb3817de346b1432aa3145d262056e1c..305b43af06c589ca8300b3b6082b2bc6bc71e9e3 100644 --- a/i18n/fr.yml +++ b/i18n/fr.yml @@ -54,6 +54,9 @@ commons: search: Accéder à la recherche shortcut_navigation: Navigation d'accès rapide transcription: Transcription + search: + title: Rechercher + close: Fermer la recherche backtotop: Haut de page biography: Biographie breadcrumb: Fil d’ariane diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 574bc71f183bc048218172743c2231668a05c99c..96f9fc769d1128cc85028030c2b8949bca2d543b 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -15,6 +15,14 @@ {{- partial "header/accessibility.html" -}} {{- partial "header/header.html" . -}} <main{{ if .Params.contents }} class="page-with-blocks"{{ end }} id="main" tabindex="-1"> + {{ if and (site.Params.search.active) (eq site.Params.search.position "fixed")}} + {{ partial "header/search.html" + (dict + "position" "fixed" + "context" . + ) + }} + {{ end }} {{- block "main" . }}{{- end }} {{- partial "hooks/before-main-end" . -}} </main> diff --git a/layouts/partials/commons/menu.html b/layouts/partials/commons/menu.html index a1f6bab2f1be6e9d98b4c21a358426c101e4ffbd..fe87efa54abd0eef6ed39aebdf6ebbca65035454 100644 --- a/layouts/partials/commons/menu.html +++ b/layouts/partials/commons/menu.html @@ -65,7 +65,15 @@ </li> {{- end -}} {{ end -}} - + + {{ if and (eq $kind "primary") (site.Params.search.active) (eq site.Params.search.position "menu")}} + {{ partial "header/search.html" + (dict + "position" "menu" + "context" . + ) + }} + {{ end }} {{ if and (eq $kind "primary") (site.Params.menu.i18n.display) }} {{ partial "header/i18n.html" . }} {{ end }} diff --git a/layouts/partials/footer/footer-simple.html b/layouts/partials/footer/footer-simple.html index 40f8d28809f71acfc48a40e80154b05198405d20..1791373fd343bc828ed3591eddd2e77f10c8af5f 100644 --- a/layouts/partials/footer/footer-simple.html +++ b/layouts/partials/footer/footer-simple.html @@ -7,6 +7,16 @@ </div> </div> {{ partial "footer/i18n.html" . }} +{{ if and (site.Params.search.active) (eq site.Params.search.position "footer")}} +<div class="container footer-search"> + {{ partial "header/search.html" + (dict + "position" "footer" + "context" . + ) + }} + </div> + {{ end }} <div class="container"> <div class="footer-social"> {{ partial "footer/social.html" }} diff --git a/layouts/partials/footer/i18n.html b/layouts/partials/footer/i18n.html index 30bdbd9eb32aad226504ffeb9fc70e04215615f0..f084432a6a06a6d9e1ed79db9ec5f47940e0a686 100644 --- a/layouts/partials/footer/i18n.html +++ b/layouts/partials/footer/i18n.html @@ -3,22 +3,40 @@ {{ $siteLang := "" }} {{ $url := "" }} {{ if gt (len site.Languages) 1 }} -<div class="container"> - <div class="footer-i18n"> - {{ with site.Languages }} - <ul class="small"> - {{ range site.Languages }} - {{ $siteLang := . }} - {{ $url = printf "/%s/" .Lang }} - {{ range $pageWithTranslations }} - {{ if eq .Lang $siteLang.Lang }} - {{ $url = .Permalink }} + <div class="container"> + <div class="footer-i18n"> + <button + aria-haspopup="menu" + aria-expanded="false" + aria-label="{{ i18n "commons.accessibility.menu_lang" }}" + tabindex="0"> + {{- site.Language.LanguageName -}} + </button> + <div class="dropdown-menu dropdown-languages"> + <ul> + {{ range site.Languages }} + {{ $siteLang := . }} + {{ $url = printf "/%s/" .Lang }} + {{ range $pageWithTranslations }} + {{ if eq .Lang $siteLang.Lang }} + {{ $url = .Permalink }} + {{ end }} {{ end }} + <li> + <a + href="{{ $url }}" + lang="{{ $siteLang }}" + hreflang="{{ $siteLang }}" + {{ if eq $siteLang site.Language }} + class="is-checked" + {{ end }} + > + {{- $siteLang.LanguageName -}} + </a> + </li> {{ end }} - <li><a href="{{ $url }}" lang="{{ $siteLang }}" hreflang="{{ $siteLang }}">{{ $siteLang.LanguageName }}</a></li> - {{ end }} - </ul> - {{ end }} + </ul> + </div> + </div> </div> -</div> {{ end }} \ No newline at end of file diff --git a/layouts/partials/head/csp.html b/layouts/partials/head/csp.html index 82d5cb2279874ffd35e4c4c0a7f0649caa1de7d8..de1b2d9420f69d64cc252834bb4d1a716339b2f9 100644 --- a/layouts/partials/head/csp.html +++ b/layouts/partials/head/csp.html @@ -1,5 +1,8 @@ {{- with site.Data.website.external_domains -}} -<meta - http-equiv="Content-Security-Policy" - content="default-src 'self' {{ delimit . " " }} {{ if not hugo.IsProduction }}'unsafe-inline'{{ end }}" /> -{{- end -}} \ No newline at end of file +<meta http-equiv="Content-Security-Policy" + content=" + default-src 'self' {{ delimit . " " }} + {{ if not hugo.IsProduction }}'unsafe-inline'{{ end }} + {{ if site.Params.search.active }}'wasm-unsafe-eval'{{ end }}; + " /> +{{- end -}} diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html index 9ee56ca29cf9523b5c5b19d806600aa41c90d970..7325b607b08ccf9e854fe66101b0c69a457f11cc 100644 --- a/layouts/partials/head/seo.html +++ b/layouts/partials/head/seo.html @@ -32,6 +32,7 @@ {{- end -}} {{- $ogImage := $seoImage -}} {{- $twitterImage := $seoImage -}} +{{- $pagefindImage := $seoImage -}} {{- with .Params.image -}} {{- $id := . -}} {{ if isset . "id" -}} @@ -46,6 +47,10 @@ "media" $image "size" "1200" ) -}} + {{- $pagefindImage = partial "GetImageUrl" (dict + "media" $image + "size" "244" + ) -}} {{- end -}} {{- $seoUrl := .Permalink -}} @@ -75,6 +80,12 @@ <meta name="twitter:site" content="@{{ site.Data.journal.twitter }}" /> {{ end -}} +{{ if site.Params.search.active }} + {{ with $pagefindImage }} + <meta property="pagefind:image" content="" data-pagefind-meta="image:{{ . }}"> + {{ end }} +{{ end }} + {{/* Limiter le tracking par le CDN https://framagit.org/chatons/CHATONS/-/issues/200#note_1987024 diff --git a/layouts/partials/header/accessibility.html b/layouts/partials/header/accessibility.html index 5bee0e499119724c2309a1a5c151c21f7659dfe9..1bd46fef9c1f28beec7af8818c55c214aa777726 100644 --- a/layouts/partials/header/accessibility.html +++ b/layouts/partials/header/accessibility.html @@ -2,5 +2,6 @@ <ul aria-label="{{ i18n "commons.accessibility.shortcut_navigation"}}"> <li><a href="#main">{{ i18n "commons.accessibility.main_content" }}</a></li> <li><a href="#navigation">{{ i18n "commons.accessibility.menu" }}</a></li> + <li><a href="#search-button">{{ i18n "commons.accessibility.search" }}</a></li> </ul> </nav> diff --git a/layouts/partials/header/search.html b/layouts/partials/header/search.html new file mode 100644 index 0000000000000000000000000000000000000000..b389fd3b8ab69b55d7b625ca14d6cf01ae129e8f --- /dev/null +++ b/layouts/partials/header/search.html @@ -0,0 +1,14 @@ +{{ $search_with_text := site.Params.search.enable_text }} +{{ $search_position := site.Params.search.position }} + +<button id="search-button" class="pagefind-ui__toggle pagefind-{{ .position }} {{- if and (not $search_with_text) (eq $search_position "menu")}} without-text {{- end }}" aria-expanded="false" aria-label='{{- i18n (printf "commons.search.title") -}}'> + <span>{{- i18n (printf "commons.search.title") -}}</span> +</button> + +<script src="/pagefind/pagefind-ui.js"></script> + +<div id="search" class="search__modal" aria-hidden="true" aria-modal="true" role="dialog"> + <button class="search__close" aria-label="{{ i18n "commons.search.close" }}"> + {{ i18n "commons.search.close" }} + </button> +</div> \ No newline at end of file diff --git a/package.json b/package.json index 13a18e053b0128ae1aa86989680156c663375852..6005a3c3af535f055c3a9eb1320bf67a01ee51a5 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,18 @@ "version": "1.0.4", "repository": "git@github.com:noesya/osuny-hugo-theme-aaa.git", "author": "alexisben <alexis.benoit@noesya.coop>", + "contributors": [ + "olivia206 <olivia.simonet@noesya.coop>", + "arnaudlevy <arnaud.levy@noesya.coop>" + ], "license": "MIT", "dependencies": { "@splidejs/splide": "^3.6.12", "glightbox": "^3.1.0", "intersection-observer": "^0.12.0", - "leaflet": "^1.9.4" - } + "leaflet": "^1.9.4", + "pagefind": "^1.0.3", + "shelljs": "^0.8.5" + }, + "bin": "./bin/osuny.js" } diff --git a/pagefind.yml b/pagefind.yml new file mode 100644 index 0000000000000000000000000000000000000000..fdc8f149caff5f333eb42e19a7d84d90ac7cbf24 --- /dev/null +++ b/pagefind.yml @@ -0,0 +1,8 @@ +exclude_selectors: + - ".pages__section, .block-pages" + - ".posts__section, .block-posts" + - ".block-partners" + - ".persons__section, .block-organization_chart" + - ".programs__section" + - ".events__section, .block-agenda" + - ".diplomas__taxonomy" \ No newline at end of file diff --git a/static/assets/fonts/fonticons/IconFont.ttf b/static/assets/fonts/fonticons/IconFont.ttf index 4029cda56ce1d870aa85540f4b543c1870692c17..00ceeaca6d77bbbd891afea88e482e113a94bafa 100644 Binary files a/static/assets/fonts/fonticons/IconFont.ttf and b/static/assets/fonts/fonticons/IconFont.ttf differ diff --git a/static/assets/fonts/fonticons/IconFont.woff b/static/assets/fonts/fonticons/IconFont.woff index 77811ce99dd933d413e48845d7b07e7f25cc1baa..726e7d9be7c6e4eb91d6576bb852a0e42cd29962 100644 Binary files a/static/assets/fonts/fonticons/IconFont.woff and b/static/assets/fonts/fonticons/IconFont.woff differ diff --git a/static/assets/fonts/fonticons/IconFont.woff2 b/static/assets/fonts/fonticons/IconFont.woff2 index 14d31e49ad8e7b0729397b8bd3730e4e781e196d..13f732b98eb3f1fdda3a7c89937349c9b61d0cf4 100644 Binary files a/static/assets/fonts/fonticons/IconFont.woff2 and b/static/assets/fonts/fonticons/IconFont.woff2 differ diff --git a/yarn.lock b/yarn.lock index 4434f7261ffce33f75b9c04c9e3355ef8b4e3fa2..706e6a356bdc7de500587d7f361eb398405ecbea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,22 +2,189 @@ # yarn lockfile v1 +"@pagefind/darwin-arm64@1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@pagefind/darwin-arm64/-/darwin-arm64-1.0.3.tgz#5377ff2c3fca97125d0624da019b52cc2375edb9" + integrity sha512-vsHDtvao3W4iFCxVc4S0BVhpj3E2MAoIVM7RmuQfGp1Ng22nGLRaMP6FguLO8TMabRJdvp4SVr227hL4WGKOHA== + +"@pagefind/darwin-x64@1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@pagefind/darwin-x64/-/darwin-x64-1.0.3.tgz#c4bae6522e3bac09a9f58f48f89356dca931f5ca" + integrity sha512-NhEXHHYmB/hT6lx5rCcmnVTxH+uIkMAd43bzEqMwHQosqTZEIQfwihmV39H+m8yo7jFvz3zRbJNzhAh7G4PiwA== + +"@pagefind/linux-arm64@1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@pagefind/linux-arm64/-/linux-arm64-1.0.3.tgz#ada5ec030c7286f956d506aebe1e1e53ea826966" + integrity sha512-RGsMt4AmGT8WxCSeP09arU7Za6Vf/We4TWHVSbY7vDMuwWql9Ngoib/q1cP9dIAIMdkXh9ePG/S3mGnJYsdzuQ== + +"@pagefind/linux-x64@1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@pagefind/linux-x64/-/linux-x64-1.0.3.tgz#4f658bac9ce5e9fb22e0a4350ff933e621c6b916" + integrity sha512-o+VCKaqImL42scSH1n5gUfppYSNyu3BuGTvtKKgWHmycbL+A3fkFH+ZOFbaLeN7LVTvJqJIOYbk4j2yaq9784Q== + +"@pagefind/windows-x64@1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@pagefind/windows-x64/-/windows-x64-1.0.3.tgz#686c46cb274e087362d0a8d6ff03e89a10ee508e" + integrity sha512-S+Yq4FyvXJm4F+iN/wRiLvEEF8Xs9lTKGtQGaRHXJslQyl65dytDDPIULXJXIadrDbnMrnTt4C2YHmEUIyUIHg== + "@splidejs/splide@^3.6.12": version "3.6.12" resolved "https://registry.yarnpkg.com/@splidejs/splide/-/splide-3.6.12.tgz#9b6bede5c99140fd06754990c91e474374566c30" integrity sha512-ggOUAuSxjWuxxL0IQEZcux26KByfKWfYM2HYmvDBdxkXc5evVW+xuECO+3iuciyrJpgcbYTr4hn0cHfbNlYIeA== +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + glightbox@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/glightbox/-/glightbox-3.2.0.tgz#d460e6ffc70ba2dcc2842e0b31d51a2e03266ba2" integrity sha512-iit1xYixqL4YVL+I2YJLfMeyJwvLi6FE6kY3qNKeZHEJgRIz80QU8Rm7YCyw1wOTgXvmNDnXGVhHOHRCwnDltQ== +glob@^7.0.0: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +has@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== + dependencies: + function-bind "^1.1.1" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +interpret@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" + integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA== + intersection-observer@^0.12.0: version "0.12.2" resolved "https://registry.yarnpkg.com/intersection-observer/-/intersection-observer-0.12.2.tgz#4a45349cc0cd91916682b1f44c28d7ec737dc375" integrity sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg== +is-core-module@^2.13.0: + version "2.13.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.0.tgz#bb52aa6e2cbd49a30c2ba68c42bf3435ba6072db" + integrity sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ== + dependencies: + has "^1.0.3" + leaflet@^1.9.4: version "1.9.4" resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.9.4.tgz#23fae724e282fa25745aff82ca4d394748db7d8d" integrity sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA== + +minimatch@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +pagefind@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pagefind/-/pagefind-1.0.3.tgz#1ce2118408d42fbd303e8b567ed3fff134895138" + integrity sha512-ws7kmMxW6OuxzsOjj3YAx6TYq/54MiE3wfyBM3J5CInbZyBBvM2Z8c8IYvnMkBcb5v2EoB9DewXEekOEiDRu5g== + optionalDependencies: + "@pagefind/darwin-arm64" "1.0.3" + "@pagefind/darwin-x64" "1.0.3" + "@pagefind/linux-arm64" "1.0.3" + "@pagefind/linux-x64" "1.0.3" + "@pagefind/windows-x64" "1.0.3" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== + +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + integrity sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw== + dependencies: + resolve "^1.1.6" + +resolve@^1.1.6: + version "1.22.6" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.6.tgz#dd209739eca3aef739c626fea1b4f3c506195362" + integrity sha512-njhxM7mV12JfufShqGy3Rz8j11RPdLy4xi15UurGJeoHLfJpVXKdh3ueuOqbYUcDZnffr6X739JBo5LzyahEsw== + dependencies: + is-core-module "^2.13.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +shelljs@^0.8.5: + version "0.8.5" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c" + integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow== + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==