Nice looking hero image
This commit is contained in:
parent
1417ab0b65
commit
65beeedd94
@ -2,6 +2,10 @@
|
|||||||
transition: all 1s;
|
transition: all 1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body > header {
|
||||||
|
text-shadow: 0 0 4px black;
|
||||||
|
}
|
||||||
|
|
||||||
.breadcrumb {
|
.breadcrumb {
|
||||||
display: none;
|
display: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Some javascript trick to sleep for some number of seconds
|
||||||
|
*/
|
||||||
const sleep = (seconds) => new Promise(resolve => {
|
const sleep = (seconds) => new Promise(resolve => {
|
||||||
document.body.classList.add('sleeping')
|
document.body.classList.add('sleeping')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -5,3 +8,13 @@ const sleep = (seconds) => new Promise(resolve => {
|
|||||||
resolve()
|
resolve()
|
||||||
}, seconds * 1000)
|
}, seconds * 1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From the current URL generate an UUID
|
||||||
|
*/
|
||||||
|
getUuidFromUrl = (pathname = document.location.pathname) =>
|
||||||
|
pathname
|
||||||
|
.split('')
|
||||||
|
.reverse()
|
||||||
|
.filter(l => l.match(/[0-9a-f]/))
|
||||||
|
.join('')
|
||||||
|
@ -10,7 +10,7 @@ note = (context, freq, counter) => {
|
|||||||
// console.log("Note n°", counter, freq)
|
// console.log("Note n°", counter, freq)
|
||||||
|
|
||||||
const oscil = context.createOscillator()
|
const oscil = context.createOscillator()
|
||||||
oscil.type = 'triangle'
|
oscil.type = 'sine'
|
||||||
oscil.frequency.value = freq
|
oscil.frequency.value = freq
|
||||||
|
|
||||||
const gainNode = context.createGain()
|
const gainNode = context.createGain()
|
||||||
@ -20,37 +20,27 @@ note = (context, freq, counter) => {
|
|||||||
const notesPerSecond = 5 // In Hertz
|
const notesPerSecond = 5 // In Hertz
|
||||||
// All are in seconds
|
// All are in seconds
|
||||||
const start = counter / notesPerSecond
|
const start = counter / notesPerSecond
|
||||||
const duration = 1.2 / notesPerSecond
|
const duration = 1 / notesPerSecond
|
||||||
const ramp = .2 / notesPerSecond / 3 // Exponential increase
|
const ramp = .2 / notesPerSecond / 3 // Exponential increase
|
||||||
|
|
||||||
// Increase volume
|
// Increase volume
|
||||||
gainNode.gain.setTargetAtTime(1, start, ramp)
|
gainNode.gain.linearRampToValueAtTime(1, start)
|
||||||
// Decrease volume
|
|
||||||
gainNode.gain.setTargetAtTime(0, start + duration - ramp * 3, ramp)
|
|
||||||
|
|
||||||
oscil.start(start)
|
oscil.start(start)
|
||||||
|
|
||||||
|
// Decrease volume
|
||||||
|
gainNode.gain.exponentialRampToValueAtTime(0.001, start + 1);
|
||||||
oscil.stop(start + duration)
|
oscil.stop(start + duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* From the current URL generate an UUID
|
|
||||||
*/
|
|
||||||
getUuidFromUrl = () =>
|
|
||||||
document.location.pathname
|
|
||||||
.split('')
|
|
||||||
.reverse()
|
|
||||||
.filter(l => l.match(/[0-9a-f]/))
|
|
||||||
.join('')
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Launch notes based on the current URL
|
* Launch notes based on the current URL
|
||||||
*/
|
*/
|
||||||
launchNotes = (event, counter = 0, uuid = getUuidFromUrl()) => {
|
launchNotes = (event, counter = 0, uuid = getUuidFromUrl()) => {
|
||||||
if (counter >= uuid.length || counter >= 5) return
|
if (counter >= uuid.length || counter >= 5) return
|
||||||
|
|
||||||
const context = new AudioContext()
|
const context = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
|
||||||
const freq = tons[parseInt(uuid[counter], 16) % tons.length] / 2
|
const freq = tons[parseInt(uuid[counter], 16) % tons.length]
|
||||||
// freq *= Math.max(1, parseInt(uuid[counter], 16)) / Math.max(1, parseInt(uuid[counter + 1], 16))
|
// freq *= Math.max(1, parseInt(uuid[counter], 16)) / Math.max(1, parseInt(uuid[counter + 1], 16))
|
||||||
// freq = Math.min(2000, Math.round(freq))
|
// freq = Math.min(2000, Math.round(freq))
|
||||||
|
|
||||||
@ -58,3 +48,5 @@ launchNotes = (event, counter = 0, uuid = getUuidFromUrl()) => {
|
|||||||
|
|
||||||
launchNotes(event, counter + 1, uuid)
|
launchNotes(event, counter + 1, uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// document.onclick = launchNotes
|
||||||
|
25
themes/acoeur/assets/js/prettify.js
Normal file
25
themes/acoeur/assets/js/prettify.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* Generate some random css effects on a specific item
|
||||||
|
*/
|
||||||
|
|
||||||
|
const nextDigit = (uuid, counter) => parseInt(uuid[counter], 16)
|
||||||
|
|
||||||
|
const generateColor = (uuid, counter = 0) =>
|
||||||
|
`rgb(${nextDigit(uuid, counter) * 16 + nextDigit(uuid, counter + 1)},
|
||||||
|
${nextDigit(uuid, counter + 2) * 16 + nextDigit(uuid, counter + 3)},
|
||||||
|
${nextDigit(uuid, counter + 4) * 16 + nextDigit(uuid, counter + 5)})`
|
||||||
|
|
||||||
|
const prettify = (element, uuid = getUuidFromUrl()) => {
|
||||||
|
if (element.style.backgroundImage || uuid.length < 6) return
|
||||||
|
|
||||||
|
element.style.backgroundImage = `linear-gradient(black, ${generateColor(uuid)}, ${generateColor(uuid, 6)})`
|
||||||
|
element.style.boxShadow = `0 0 1em inset ${generateColor(uuid, 6)}`
|
||||||
|
|
||||||
|
Array.from(element.children)
|
||||||
|
.forEach(c => c.style.backgroundColor = 'transparent')
|
||||||
|
}
|
||||||
|
|
||||||
|
prettify(document.querySelector('body > header'))
|
||||||
|
|
||||||
|
Array.from(document.querySelectorAll('a.hero-pill'))
|
||||||
|
.forEach(element => prettify(element, getUuidFromUrl(element.href)))
|
@ -114,5 +114,5 @@ uuid = () => {
|
|||||||
const temp_url = URL.createObjectURL(new Blob())
|
const temp_url = URL.createObjectURL(new Blob())
|
||||||
const uuid = temp_url.toString()
|
const uuid = temp_url.toString()
|
||||||
URL.revokeObjectURL(temp_url)
|
URL.revokeObjectURL(temp_url)
|
||||||
return uuid.substr(uuid.lastIndexOf('/') + 1) // remove prefix (e.g. blob:null/, blob:www.test.com/, ...)
|
return uuid.substring(uuid.lastIndexOf('/') + 1) // remove prefix (e.g. blob:null/, blob:www.test.com/, ...)
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,17 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ range .Pages }}
|
{{ range .Pages }}
|
||||||
{{ .Render "summary-with-image" }}
|
{{ $featured_image := partial "func/GetFeaturedImage.html" . }}
|
||||||
|
<article class="bb b--black-10 w-100 mb4 bg-white pa3-ns flex flex-column flex-row-ns relative">
|
||||||
|
{{ if $featured_image }}
|
||||||
|
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}">
|
||||||
|
{{ end }}
|
||||||
|
{{ .Title }}
|
||||||
|
-
|
||||||
{{ range (.Paginate .RegularPagesRecursive).Pages }}
|
{{ range (.Paginate .RegularPagesRecursive).Pages }}
|
||||||
{{ .Title }}
|
{{ .Title }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
</article>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</section>
|
</section>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -9,9 +9,12 @@
|
|||||||
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}">
|
<img src="{{ $featured_image }}" class="img" alt="image from {{ .Title }}">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
{{ else }}
|
||||||
|
<a class="hero-pill fl w-10-ns bg-black mr3"
|
||||||
|
href="{{.RelPermalink}}"></a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<div class="blah w-100{{ if $featured_image }} w-60-ns{{ end }}">
|
<div class="blah w-100{{ if $featured_image }} w-60-ns{{ else }} w-90-ns{{ end }}">
|
||||||
<header>
|
<header>
|
||||||
<time class="db f6 fr" datetime="{{ .Date }}">
|
<time class="db f6 fr" datetime="{{ .Date }}">
|
||||||
{{ .Date | time.Format .Site.Params.date_format }}
|
{{ .Date | time.Format .Site.Params.date_format }}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script>const file = '{{ .File }}'</script>
|
<script>const file = '{{ .File }}'</script>
|
||||||
|
|
||||||
<script defer
|
<script defer
|
||||||
src="https://unpkg.com/tinymce@6.3.0/tinymce.js"
|
src="https://unpkg.com/tinymce@6.3.1/tinymce.js"
|
||||||
referrerpolicy="origin"></script>
|
referrerpolicy="origin"></script>
|
||||||
|
|
||||||
<script defer
|
<script defer
|
||||||
@ -36,3 +36,7 @@
|
|||||||
{{ with resources.Get "js/notes.js" | minify | fingerprint }}
|
{{ with resources.Get "js/notes.js" | minify | fingerprint }}
|
||||||
<script defer src="{{ .Permalink }}"></script>
|
<script defer src="{{ .Permalink }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ with resources.Get "js/prettify.js" | minify | fingerprint }}
|
||||||
|
<script defer src="{{ .Permalink }}"></script>
|
||||||
|
{{ end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user