Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ gem "http_parser.rb", "0.8.0", :platforms => [:jruby]
# plugin dependencies
gem "nokogiri", "1.18.10"
gem "addressable", "2.8.7"
gem "mini_racer", "0.20.0" if ENV["ENABLE_EMBEDDED_V8"] == "true" || ENV["DRONE"] == "true"
gem "terser", "1.2.7"
30 changes: 24 additions & 6 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,6 @@ compress_html:
ignore:
envs: development

head_scripts:
- /assets/js/settings.js
- /assets/js/theme.js
after_footer_scripts:
- /assets/js/plugins/jquery.auto-redirect.js

# jekyll-feed
feed:
collections:
Expand All @@ -332,3 +326,27 @@ feed:
- modpack
- eula
- multiplayer

post_process:
terser:
/assets/js/main.min.js:
- /assets/js/settings.js
- /assets/js/theme.js
- /assets/js/vendor/jquery/jquery-3.6.0.js
- /assets/js/plugins/gumshoe.js
- /assets/js/plugins/jquery.ba-throttle-debounce.js
- /assets/js/plugins/jquery.fitvids.js
- /assets/js/plugins/jquery.greedy-navigation.js
- /assets/js/plugins/jquery.magnific-popup.js
- /assets/js/plugins/smooth-scroll.js
- /assets/js/plugins/jquery.auto-redirect.js
- /assets/js/_main.js
remove_dirs:
- /assets/images/
- /assets/js/plugins/
- /assets/js/vendor/
remove_files:
- /assets/js/_main.js
- /assets/js/theme.js
- /assets/js/settings.js
- /assets/js/main.min.js.map
51 changes: 51 additions & 0 deletions _plugins/post_process.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require "terser"

ExecJS.runtime = ExecJS::Runtimes::MiniRacer if ExecJS::Runtimes::MiniRacer.available?

Jekyll::Hooks.register :site, :post_write do |site|
config = site.config["post_process"]
next unless config

terser = config["terser"]
if terser.is_a?(Hash)
terser.each do |terser_output, terser_inputs|
next unless terser_output.is_a?(String) && terser_inputs.is_a?(Array)

terser_codes = []
terser_inputs_all_exist = true
terser_inputs.each do |file|
destination = File.join(site.dest, file)
if File.exist?(destination)
terser_codes << File.read(destination, encoding: "UTF-8")
else
terser_inputs_all_exist = false
break
end
end

if terser_inputs_all_exist
destination = File.join(site.dest, terser_output.to_s)
File.write(destination, Terser.compile(terser_codes.join(";")))
Jekyll.logger.info "Post Process:", "terser #{terser_output}"
end
end
end

remove_files = config["remove_files"]
if remove_files.is_a?(Array)
remove_files.each do |file|
destination = File.join(site.dest, file)
File.delete(destination) if File.exist?(destination)
Jekyll.logger.info "Post Process:", "remove_files #{file}"
end
end

remove_dirs = config["remove_dirs"]
if remove_dirs.is_a?(Array)
remove_dirs.each do |dir|
destination = File.join(site.dest, dir)
FileUtils.rm_rf(destination) if File.directory?(destination)
Jekyll.logger.info "Post Process:", "remove_dirs #{dir}"
end
end
end
3 changes: 3 additions & 0 deletions _sass/minimal-mistakes-plus.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
$large: 1200px !default;
$x-large: 1400px !default;

@import "minimal-mistakes";

blockquote {
Expand Down
132 changes: 132 additions & 0 deletions assets/js/plugins/jquery.greedy-navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
GreedyNav.js - https://github.com/lukejacksonn/GreedyNav
Licensed under the MIT license - http://opensource.org/licenses/MIT
Copyright (c) 2015 Luke Jackson http://lukejacksonn.com
*/

$(function() {

var $btn = $("nav.greedy-nav .greedy-nav__toggle");
var $vlinks = $("nav.greedy-nav .visible-links");
var $hlinks = $("nav.greedy-nav .hidden-links");
var $nav = $("nav.greedy-nav");
var $logo = $('nav.greedy-nav .site-logo');
var $logoImg = $('nav.greedy-nav .site-logo img');
var $title = $("nav.greedy-nav .site-title");
var $search = $('nav.greedy-nav button.search__toggle');

var numOfItems, totalSpace, closingTime, breakWidths;

// This function measures both hidden and visible links and sets the navbar breakpoints
// This is called the first time the script runs and everytime the "check()" function detects a change of window width that reached a different CSS width breakpoint, which affects the size of navbar Items
// Please note that "CSS width breakpoints" (which are only 4) !== "navbar breakpoints" (which are as many as the number of items on the navbar)
function measureLinks(){
numOfItems = 0;
totalSpace = 0;
closingTime = 1000;
breakWidths = [];

// Adds the width of a navItem in order to create breakpoints for the navbar
function addWidth(i, w) {
totalSpace += w;
numOfItems += 1;
breakWidths.push(totalSpace);
}

// Measures the width of hidden links by making a temporary clone of them and positioning under visible links
function hiddenWidth(obj){
var clone = obj.clone();
clone.css("visibility","hidden");
$vlinks.append(clone);
addWidth(0, clone.outerWidth());
clone.remove();
}
// Measure both visible and hidden links widths
$vlinks.children().outerWidth(addWidth);
$hlinks.children().each(function(){hiddenWidth($(this))});
}
// Get initial state
measureLinks();

var winWidth = $( window ).width();
// Set the last measured CSS width breakpoint: 0: < 768px, 1: < 1200px, 2: < 1400px, 3: >= 1400px.
var lastBreakpoint = winWidth < 768 ? 0 : winWidth < 1200 ? 1 : winWidth < 1400 ? 2 : 3;

var availableSpace, numOfVisibleItems, requiredSpace, timer;

function check() {

winWidth = $( window ).width();
// Set the current CSS width breakpoint: 0: <768px, 1: < 1200px, 2: < 1400px, 3: >= 1400px.
var curBreakpoint = winWidth < 768 ? 0 : winWidth < 1200 ? 1 : winWidth < 1400 ? 2 : 3;
// If current breakpoint is different from last measured breakpoint, measureLinks again
if(curBreakpoint !== lastBreakpoint) measureLinks();
// Set the last measured CSS width breakpoint with the current breakpoint
lastBreakpoint = curBreakpoint;

// Get instant state
numOfVisibleItems = $vlinks.children().length;
// Decrease the width of visible elements from the nav innerWidth to find out the available space for navItems
availableSpace = /* nav */ $nav.innerWidth()
- /* logo */ ($logo.length !== 0 ? $logo.outerWidth(true) : 0)
- /* title */ $title.outerWidth(true)
- /* search */ ($search.length !== 0 ? $search.outerWidth(true) : 0)
- /* toggle */ (numOfVisibleItems !== breakWidths.length ? $btn.outerWidth(true) : 0);
requiredSpace = breakWidths[numOfVisibleItems - 1];

// There is not enought space
if (requiredSpace > availableSpace) {
$vlinks.children().last().prependTo($hlinks);
numOfVisibleItems -= 1;
check();
// There is more than enough space. If only one element is hidden, add the toggle width to the available space
} else if (availableSpace + (numOfVisibleItems === breakWidths.length - 1?$btn.outerWidth(true):0) > breakWidths[numOfVisibleItems]) {
$hlinks.children().first().appendTo($vlinks);
numOfVisibleItems += 1;
check();
}
// Update the button accordingly
$btn.attr("count", numOfItems - numOfVisibleItems);
if (numOfVisibleItems === numOfItems) {
$btn.addClass('hidden');
} else $btn.removeClass('hidden');
}

// Window listeners
$(window).resize(function() {
check();
});

$btn.on('click', function() {
$hlinks.toggleClass('hidden');
$(this).toggleClass('close');
clearTimeout(timer);
});

$hlinks.on("click", function () {
// Hide the hidden links & remove the overlay when one is clicked.
$hlinks.addClass("hidden");
$btn.removeClass("close");
}).on('mouseleave', function() {
// Mouse has left, start the timer
timer = setTimeout(function() {
$hlinks.addClass('hidden');
$('.greedy-nav__toggle').removeClass('close');
}, closingTime);
}).on('mouseenter', function() {
// Mouse is back, cancel the timer
clearTimeout(timer);
})

// check if page has a logo
if($logoImg.length !== 0){
// check if logo is not loaded
if(!($logoImg[0].complete || $logoImg[0].naturalWidth !== 0)){
// if logo is not loaded wait for logo to load or fail to check
$logoImg.one("load error", check);
// if logo is already loaded just check
} else check();
// if page does not have a logo just check
} else check();

});