Add export avatar images task

This commit is contained in:
Gabriel Arazas 2023-05-01 18:26:40 +08:00
parent 0b24f26988
commit e7469cbfcb
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
9 changed files with 11 additions and 1 deletions

View File

@ -11,7 +11,7 @@ github_api_headers = {
github_api_headers['Authorization'] = "Token #{ENV['GITHUB_API_BEARER_TOKEN']}" if ENV['GITHUB_API_BEARER_TOKEN']
desc 'Build the site in Netlify with the given context'
task :build, [:context, :base_url] do |_, args|
task :build, [:context, :base_url] => [:optimize_avatars] do |_, args|
args.with_defaults(context: 'production')
draft_args = '--environment development --buildDrafts --buildFuture --buildExpired' unless args.context == 'production'
base_uri_args = "-b #{args.base_url}" if args.base_url
@ -22,6 +22,15 @@ task :build, [:context, :base_url] do |_, args|
sh "nix develop -c hugo #{draft_args} #{base_uri_args} --destination public"
end
desc 'Export the avatar images'
task :export_avatars, [:base_dir, :output_dir, :output_extension] do |_, args|
args.with_defaults(base_dir: './assets/svg/', output_dir: './static/icons/', output_extension: 'webp')
Dir.glob('avatars/**/*.svg', base: args.base_dir) do |f|
output_file = "#{File.dirname(f)}/#{File.basename(f, '.svg')}.#{args.output_extension}"
sh "magick #{args.base_dir}#{f} -quality 10 #{args.output_dir}#{output_file}"
end
end
desc 'Build the webring to be embedded with the site'
task :build_webring, [:limit, :input, :output, :file] do |_, args|
args.with_defaults(

View File

@ -32,6 +32,7 @@ mkShell {
tree-sitter
(tree-sitter.withPlugins (_: tree-sitter.allGrammars))
netlify-cli
imagemagick
# Formatters...
rufo # ...for Ruby.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB