mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-22 09:56:51 +01:00
commit
10680cbd7a
22
Gruntfile.js
22
Gruntfile.js
@ -11,7 +11,8 @@ module.exports = function(grunt){
|
||||
css: 'assets/css',
|
||||
js: 'assets/js',
|
||||
img: 'assets/img',
|
||||
fonts: 'assets/fonts'
|
||||
fonts: 'assets/fonts',
|
||||
cdnurl: 'https://d2jlreog722xe2.cloudfront.net/assets/'
|
||||
}
|
||||
};
|
||||
|
||||
@ -50,7 +51,8 @@ module.exports = function(grunt){
|
||||
},
|
||||
production: {
|
||||
options: {
|
||||
lsi: true
|
||||
lsi: true,
|
||||
raw: 'enable_cdnurl: true\n'
|
||||
}
|
||||
},
|
||||
development: {
|
||||
@ -204,6 +206,19 @@ module.exports = function(grunt){
|
||||
assetsDirs: ['<%= config.build %>', '<%= config.build %>/assets/{css,js,img,fonts}']
|
||||
}
|
||||
},
|
||||
|
||||
// CDN some assets
|
||||
cdn: {
|
||||
options: {
|
||||
cdn: '<%= config.cdnurl %>',
|
||||
flatten: true
|
||||
},
|
||||
dist: {
|
||||
src: [
|
||||
'<%= config.build %>/assets/**/*.css' // CDN all assets called from css files
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// rsync stuff around
|
||||
rsync: {
|
||||
@ -287,7 +302,8 @@ module.exports = function(grunt){
|
||||
'imagemin:touchicons',
|
||||
'rsync:copy_build',
|
||||
'rev',
|
||||
'usemin'
|
||||
'usemin',
|
||||
'cdn'
|
||||
]);
|
||||
|
||||
// Optimze media
|
||||
|
@ -15,6 +15,8 @@ description: 'Blog of designer & developer Matthias Kretschmann'
|
||||
url: https://kremalicious.com
|
||||
author: Matthias Kretschmann
|
||||
email: m@kretschmann.io
|
||||
cdnurl: https://d2jlreog722xe2.cloudfront.net
|
||||
enable_cdnurl: false
|
||||
|
||||
|
||||
# Urls
|
||||
|
@ -65,7 +65,6 @@
|
||||
<!-- Picturefill -->
|
||||
<script src="/assets/js/picturefill.min.js" defer></script>
|
||||
|
||||
|
||||
<!-- Canonical URL -->
|
||||
<link rel="canonical" href="{{ site.url}}{{ page.url | replace:'index.html','' }}">
|
||||
|
||||
|
@ -142,7 +142,7 @@ module Jekyll
|
||||
|
||||
# Generate resized images
|
||||
instance.each { |key, source|
|
||||
instance[key][:generated_src] = generate_image(source, site.source, site.dest, settings['source'], settings['output'], site.config["baseurl"])
|
||||
instance[key][:generated_src] = generate_image(source, site.source, site.dest, settings['source'], settings['output'], site.config['cdnurl'], site.config["baseurl"], site.config['enable_cdnurl'])
|
||||
}
|
||||
|
||||
# Construct and return tag
|
||||
@ -169,7 +169,7 @@ module Jekyll
|
||||
picture_tag
|
||||
end
|
||||
|
||||
def generate_image(instance, site_source, site_dest, image_source, image_dest, baseurl)
|
||||
def generate_image(instance, site_source, site_dest, image_source, image_dest, cdnurl, baseurl, enable_cdnurl)
|
||||
image = MiniMagick::Image.open(File.join(site_source, image_source, instance[:src]))
|
||||
digest = Digest::MD5.hexdigest(image.to_blob).slice!(0..5)
|
||||
|
||||
@ -230,7 +230,12 @@ module Jekyll
|
||||
end
|
||||
|
||||
# Return path relative to the site root for html
|
||||
Pathname.new(File.join(baseurl, image_dest, image_dir, gen_name)).cleanpath
|
||||
if enable_cdnurl == true
|
||||
Pathname.new(File.join(cdnurl, baseurl, image_dest, image_dir, gen_name)).cleanpath
|
||||
else
|
||||
Pathname.new(File.join(baseurl, image_dest, image_dir, gen_name)).cleanpath
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,6 +10,7 @@ pre,
|
||||
samp
|
||||
font-family: $font-family-monospace
|
||||
font-size: $font-size-small
|
||||
hyphens: none
|
||||
|
||||
code,
|
||||
kbd
|
||||
|
@ -23,7 +23,8 @@
|
||||
"grunt-jekyll": ">=0.4.0",
|
||||
"grunt-rsync": ">=0.2.1",
|
||||
"grunt-rev": ">=0.1.0",
|
||||
"grunt-usemin": ">=2.0.2"
|
||||
"grunt-usemin": ">=2.0.2",
|
||||
"grunt-cdn": ">=0.5.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.29"
|
||||
|
Loading…
Reference in New Issue
Block a user