Skip to content

Instantly share code, notes, and snippets.

View inwardmovement's full-sized avatar

Victor inwardmovement

  • Lyon, France
View GitHub Profile
@inwardmovement
inwardmovement / layouts\_default\_markup\render-link.html
Last active January 3, 2020 14:27
Open external links in new tabs with Hugo (using render hooks)
@inwardmovement
inwardmovement / layouts\partials\styles.html
Last active January 4, 2020 10:03
Add external link icon with Hugo (using CSS)
<style>
a[href^="http"]:not([href^="{{ (urls.Parse .Page.Permalink).Scheme }}://{{ (urls.Parse .Page.Permalink).Host }}"]):not(.no-external-icon)::after
{
content: 'launch';
padding-left: 4px;
position: inline-block;
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 18px;
@inwardmovement
inwardmovement / index.js
Last active February 21, 2020 13:55
Add external links icon (using JS)
// EXTERNAL LINKS
var links = $(document.links).filter(function() {
return this.hostname !== location.hostname
&& !this.classList.contains('no-external-icon');
});
for (var i = 0; i < links.length; i++) {
links[i].innerHTML += " <svg class=\"bi bi-box-arrow-up-right\" width=\"1em\" height=\"1em\" viewBox=\"0 0 20 20\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\"><path fill-rule=\"evenodd\" d=\"M3.5 15A1.5 1.5 0 005 16.5h8a1.5 1.5 0 001.5-1.5v-4a.5.5 0 00-1 0v4a.5.5 0 01-.5.5H5a.5.5 0 01-.5-.5V7a.5.5 0 01.5-.5h4a.5.5 0 000-1H5A1.5 1.5 0 003.5 7v8zm7-11a.5.5 0 01.5-.5h5a.5.5 0 01.5.5v5a.5.5 0 01-1 0V4.5H11a.5.5 0 01-.5-.5z\" clip-rule=\"evenodd\"/><path fill-rule=\"evenodd\" d=\"M16.354 3.646a.5.5 0 010 .708l-8 8a.5.5 0 01-.708-.708l8-8a.5.5 0 01.708 0z\" clip-rule=\"evenodd\"/></svg>";
}
@inwardmovement
inwardmovement / index.js
Created January 2, 2020 10:29
Copy text on click (using JS)
// DISCORD COPY
function copyDiscord(discordTag) {
navigator.clipboard.writeText(discordTag).then(function() {
/* success */
$('button.discord').tooltip('show');
setTimeout(function(){
$('button.discord').tooltip('hide')
}, 2000);
}, function() {
/* fail */
@inwardmovement
inwardmovement / index.js
Last active January 27, 2020 09:13
Top button (using JS)
// TOP BUTTON
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 0 || document.documentElement.scrollTop > 0) {
document.getElementById("top-btn").style.display = "block";
} else {
document.getElementById("top-btn").style.display = "none";
}
}
@inwardmovement
inwardmovement / layouts\partials\styles.html
Created January 27, 2020 09:12
Inline styles with Hugo
{{ with .Site.IsServer }}
<!-- Do not inline styles -->
<link rel="stylesheet" href="{{ $mainCSS.RelPermalink }}">
{{ end }}
<style>
{{ with or (getenv "PREVIEW") (getenv "PRODUCTION") }}
<!-- Inline styles -->
{{ $mainCSS.Content | safeCSS }}
{{ end }}
@inwardmovement
inwardmovement / gist:6f45914eaa3f68dc07389ac5a0f0bc4c
Created March 29, 2020 12:45
Bypass a parent's width to take the full width
https://twitter.com/Una/status/951519740840873984
.full-width {
position: relative;
width: 100vw;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
<img class="alignleft wp-image-9823" style="border: none;" src="https://www.droitaucorps.com/wp-content/uploads/2020/05/logo-new-trans.png" alt="" width="82" height="82" />
<p style="margin-top: -1em;">Droit au Corps publie la synthèse de ses initiatives dans l’AlgoNews, la revue de l’<a style="color: #0399d1;" href="http://algosphere.org/" target="_blank" rel="noopener">Alliance Algosphère</a> dont notre collectif fait partie.</p>
&nbsp;
<p style="text-align: center;"><a style="color: #42beec; border: 1px solid #42beec; padding: 7px; text-decoration: none; border-radius: 3px;" href="http://eepurl.com/deVD4j" target="_blank" rel="noopener"><strong>S'abonner</strong></a></p>
{
"black": { "$type": "color", "$value": "#000000" },
"white": { "$type": "color", "$value": "#ffffff" },
"gray-skeleton": { "$type": "color", "$value": "#e9ecef" },
"gray-disabled": { "$type": "color", "$value": "#adb5bd" },
"gray-secondary": { "$type": "color", "$value": "#6c757d" },
"blue-light": { "$type": "color", "$value": "#cfe2ff" },
"blue-solid": { "$type": "color", "$value": "#0d6efd" },
"blue-dark": { "$type": "color", "$value": "#052c65" },
"green-light": { "$type": "color", "$value": "#d1e7dd" },
@inwardmovement
inwardmovement / node.js
Created December 13, 2023 08:00
Node __dirname ESM
import { mkdir, writeFile } from "node:fs"
import { fileURLToPath } from "node:url"
import path from "node:path"
const __dirname = path.dirname(fileURLToPath(import.meta.url))