A Pelican plugin that minifies fontawesome css and fonts to include only used icons.
git clone https://mcol.xyz/code/pelican-minify-fontawesome
Log | Files | Refs | README

commit a5e9660092709115462c9ac5224881486def9dcf
parent 4bbf5e7eb952d08a813af71948711d33f1580a02
Author: mcol <mcol@posteo.net>
Date:   Sun, 13 Oct 2019 23:18:19 +0100

add readme and script-top license

Diffstat:
Mminify_fontawesome.py | 35+++++++++++++++++------------------
Areadme.rst | 31+++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 18 deletions(-)

diff --git a/minify_fontawesome.py b/minify_fontawesome.py @@ -1,22 +1,21 @@ # -*- coding: utf-8 -*- -""" -minify-fontawesome - A plugin for the pelican static site generator that -extracts only icons used in your website from fontawesome source files to -copies them to the output folder to lighten served fontawesome files. - -To use, set MINIFY_FONTAWESOME in your pelican config to a locally downloaded -fontawesome icon folder (e.g. '/home/user/fontawesome-free-5.11.2-web'). - -These can be downloaded from https://fontawesome.com/download (the web fonts). - -It also requires that fontforge is installed. - -This will save the css file into output_path/static/css/fa.css, and fonts into -output_path/static/webfonts/. - -To use it, something like this should be added to html headers: - <link rel="stylesheet" href="{{ SITEURL }}/theme/css/fa.css"/> -""" +# +# pelican-minify-fontawesome +# +# Copyright (C) 2019 mcol@posteo.net +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. import fontforge as ff diff --git a/readme.rst b/readme.rst @@ -0,0 +1,31 @@ +minify-fontawesome - pelican plugin +=================================== + +minify-fontawesome is a plugin for the `pelican +<https://github.com/getpelican/pelican>`_ static site generator that extracts +only icons used in your website from fontawesome source files upon site +generation. If you only use a small number of icons it reduces served CSS from +around 70KB to around 5KB. + +At the end of site generation, the plugin identifies which icons are being used +and copies the CSS and font definitions of these icons into +*output_path/static/css/fa.css* and *output_path/static/webfonts/* +respectively. + +To enable, `download fontawesome <https://fontawesome.com/download>`_ and set +this variable in your pelicanconf.py to the path where fontawesome is saved +(for example): + +.. code-block:: python + + MINIFY_FONTAWESOME = '/home/user/fontawesome-free-5.11.2-web' + +Fontforge must be installed, and is available in many linux distribution +repositories. + +Much like with normal fontawesome usage, the CSS file should be linked in html +headers, i.e. put this into page templates: + +.. code-block:: html + + <link rel="stylesheet" href="{{ SITEURL }}/theme/css/fa.css"/>