Skip to content

Instantly share code, notes, and snippets.

View ankedsgn's full-sized avatar

Anke ankedsgn

  • Flink
View GitHub Profile
@ankedsgn
ankedsgn / record.twig
Last active January 4, 2019 15:22
Responsive images with sourceset in bolt
{% if record.image is not empty %}
<figure class="main-img">
<div class="img-container">
<img class=""
{# give the browser three possible imagesizes to choose from #}
srcset="{{ record.image|thumbnail(1800,750,'c') }} 1800w ,
{{ record.image|thumbnail(1200,500,'c') }} 1200w,
{{ record.image|thumbnail(800,330,'c') }} 800w"
{# give the width the image is used on different mediaqueries - in this case always 100% #}
sizes="100vw"
@ankedsgn
ankedsgn / master_with_404_title.twig
Created January 11, 2019 11:16
Return a title in the Bolt 404 page with SEO extension
{% if app.request.get('_route') %}{# no route, no SEO tags #}
<title>{{ seo.title() }}</title>
{{ seo.metatags() }}
{% else %}
<title>Niet Gevonden | {{ config.get('general/sitename') }}</title>
{% endif %}
@ankedsgn
ankedsgn / Bolt forms config - boltforms.yml
Created January 14, 2019 13:26
how to customize boltforms
## Debugging
# OFF on global config! - to make sure it is enabled on PROD by default.
debug:
enabled: false
address: [email protected]
# TEMPLATES
# Custom for museon site, in the museon2019/templates folder
@ankedsgn
ankedsgn / skiplinks.scss
Created January 17, 2019 10:57
skiplinks
@ankedsgn
ankedsgn / record.twig
Created February 27, 2019 16:45
Show preview of youtube before clicking; no cookies before playing. - Bolt
{% if 'youtube' in record.video.url %}
{% set embedurl = 'https://www.youtube-nocookie.com/embed/' ~ record.video.url|split('=')|last ~ '?feature=oembed&rel=0&autoplay=1' %}
{% elseif 'youtu.be' in record.video.url %}
{% set embedurl = 'https://www.youtube-nocookie.com/embed/' ~ record.video.url|split('/')|last ~ '?feature=oembed&rel=0&autoplay=1' %}
{% elseif 'vimeo' in record.video.url %}
{% set embedurl = 'https://player.vimeo.com/video/' ~ record.video.url|split('/')|last ~'?autoplay=1' %}
{% else %}
{% set embedurl = '[todo-else]' %}
{% endif %}
@ankedsgn
ankedsgn / Sharing urls of social media
Created May 10, 2019 09:47
Twitter, FB, etc zonder scripts
Source: https://crunchify.com/list-of-all-social-sharing-urls-for-handy-reference-social-media-sharing-buttons-without-javascript/
Facebook:
Facebook social share URL:
https://www.facebook.com/sharer.php?u=[post-url]
Twitter:
Twitter social share URL:
@ankedsgn
ankedsgn / contenttypes.yml and template.twig
Last active June 6, 2019 14:39
Multilanguage alts and titles in Bolt
in contenttypes.yml:
image:
type: image
attrib: [ alt_nl, title_nl, alt_en, title_en, alt_fr, title_fr ]
in de template:
{% set alt = attribute(record.values.image, 'alt_'~getlanguage() )|default('') %}
{% set title = attribute(record.values.image, 'title_'~getlanguage() )|default('') %}
@ankedsgn
ankedsgn / app.js
Created February 26, 2020 08:37
History path / breadcrumbs
$( document ).ready(function() {
/**
* breadcrumbs / history path
*/
breadcrumbStateSaver(document.location.href, document.title);
showBreadCrumb();
)};
//breadcrumbs -> https://stackoverflow.com/questions/18998797/create-breadcrumbs-dynamically-on-client-side-using-javascript
@ankedsgn
ankedsgn / app.js
Last active December 22, 2020 08:47
Responsive table - Adds th's to each td in mobile version
if(window.innerWidth < 768) {
$('table.content-table').each(function( index ) {
var ths = $( this ).find('th');
var trs = $( this ).find('tr');
trs.each(function(){
$(this).find('td').each(function(i){
var text="<span>"+ths.eq(i).html()+"</span>";
$(this).prepend(text);
})
});
@ankedsgn
ankedsgn / scroll to right anchors.scss
Created March 24, 2020 10:23
Scroll to anchors with fixed headers
h2 a[name] { // all anchors
scroll-margin-top: 70px;
@supports (-webkit-overflow-scrolling: touch) { // bc ios safari is not playing along
/* CSS specific to iOS devices only */
padding-top: 70px;
margin-top: -70px;
}
}