• This repository has been archived on 20/Feb/2022
  • Stars
    star
    9
  • Rank 1,939,727 (Top 39 %)
  • Language
    Ruby
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ARCHIVED migrated to bridgetown-svg-inliner

🚨 Archived

This gem has been replaced by ayushn21/bridgetown-svg-inliner and has now been archived since it will not be receiving any future updates as Bridgetown v1.0.0 approaches, which will not be compatible with this gem.

Upgrade to ayushn21/bridgetown-svg-inliner which has a MIT License and works with the latest versions of Bridgetown.


bridgetown-inline-svg

License: GPL-3.0 Gem Version

Installation

Run this command to add this plugin to your site's Gemfile:

bundle add bridgetown-inline-svg -g bridgetown_plugins

Or add the following to your Gemfile:

group :bridgetown_plugins do
  gem "bridgetown-inline-svg", "~> 1.1.0"
end

Optional Configuration

# bridgetown.config.yml

svg:
  # Whether to optimize the SVG files with svg_optimizer.
  #
  # Type: Boolean
  # Optional: true
  # Default: false
  optimize: true

Usage

This plugin provides the svg Liquid tag to your site.

Use the tag in your pages, collections, and components by passing the tag the name of a file:

{% svg path/to/my.svg %}

Note: The .svg file extension is required.

Attributes

Set attributes like you would in HTML:

{% svg assets/svg/square.svg width=24 class="text-indigo-600" foo="bar" %}

Bridgetown will include the SVG file in your output HTML like this:

<svg width="24" height="24" class="text-indigo-600" foo="bar" version="1.1" id="square" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 24 24" >
  <rect width="20" height="20" x="2" y="2" />
</svg>

Note: Anything can be passed through, but we'd recommend setting valid attributes.

Height and Width

height is automatically set to match width if omitted, and vice versa. Height cannot be left unset because IE11 won't use the viewport attribute to calculate the image's aspect ratio.

Paths

Paths with a space should be quoted with single or double quotes:

{% svg "/path/to/my asset.svg" %}

If the path is not in quotes, anything after the first space will be considered an attribute.

Relative paths and absolute paths will both be interpreted from Bridgetown's src directory:

{% svg "/path/to/my.svg" %}
{% svg "path/to/my.svg" %}

Should resolve to /your/site/src/path/to/my.svg.

Variables

Liquid variables will be interpolated if enclosed in double brackets:

{% assign svg_name="my" %}
{% assign size=40 %}
{% svg "/path/to/{{svg_name}}.svg" width="{{size}}" %}

This is helpful inside of Liquid components!

Optimizations

Processing is done to remove useless data when enabled in the Bridgetown config:

  • metadata
  • comments
  • unused groups
  • Other filters from svg_optimizer
  • default size

If any important data gets removed, or the output SVG looks different from input, it's a bug. Please file an issue to this repository describing your problem.

It does not perform any input validation on attributes. They will be appended as-is to the root node.

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can take a look at the contributing guide.

Acknowledgement

This project was initially forked from jekyll-inline-svg.

License

Copyright © 2017-2020 Sebastien Dumetz Copyright © 2020 Andrew Mason

The following code is a derivative work of the code from the jekyll-inline-svg project, which is licensed GPLv3. This code therefore is also licensed under the terms of the GNU Public License, verison 3.

More Repositories

1

obsidian-beginner-vault-template

A minimal template for your first Obsidian vault aimed at setting good defaults.
56
star
2

awesome-lucky

A collection of awesome Lucky libraries, tools, frameworks and resources
44
star
3

standardrb-action

StandardRB Action: A GitHub Action to run StandardRB against your code!
Ruby
33
star
4

warp-one-dark-darker

Warp theme based on One Dark Darker
26
star
5

shotgun

Ready to go Rails App with TailwindCSS, ViewComponent, Devise, and more!
Ruby
25
star
6

pruner

CLI tool to delete Git branches
Ruby
20
star
7

bundler-audit-action

Bundler Audit Action
Dockerfile
17
star
8

stimulus_reflex_table_filter

Demo app showing how you can filter a table in a Ruby on Rails app with StimulusReflex
Ruby
17
star
9

awesome-bridgetown

A curated list of awesome things related to Bridgetown
13
star
10

rails-extension-power-pack

An extension pack of my favorite VS Code extensions for Ruby on Rails development.
Ruby
11
star
11

forem_lite

A simple tool to help you get articles from Forem/Dev.to
Ruby
11
star
12

andrewm.codes

My personal website built on Bridgetown
HTML
11
star
13

dishwasher

A CLI tool to help you easily delete forked repositories.
Ruby
10
star
14

awesome-stars

An Awesome List of my Awesome Stars
9
star
15

bridgetown-netlify-cms-starter

A template to help you get started with Bridgetown + Netlify CMS
JavaScript
8
star
16

bridgetown-gh-pages-action

ARCHIVED See link below, this action is now longer needed following the release of Bridgetown V1
Shell
7
star
17

andrewmcodes

andrewmcodes public readme
6
star
18

andrewmcodes_gem

My gem card
Ruby
4
star
19

haml-lint-action

A GitHub Action that lints your HAML code with HAML Lint!
Ruby
4
star
20

alfred-themes

My personal Alfred 5 themes
4
star
21

redux-on-rails

I DIDNT WANT THIS BUT YOU MADE ME DO IT
Ruby
3
star
22

.github

Default community health files for @andrewmcodes
3
star
23

bridgetown-torchlight-demo

A demo Bridgetown website that has Torchlight syntax highlighting configured!
JavaScript
3
star
24

dotfiles

My personal dot and settings files
Shell
3
star
25

release-please-demo

Ruby
2
star
26

turbo_debug

Ruby
2
star
27

vercel_ruby

WIP Vercel Serverless Functions written in Ruby
Ruby
2
star
28

.dotfiles-update

A temporary repo where I am rebuilding my dotfiles
Shell
2
star
29

rails-cable-route-bug-reproduction

Ruby
1
star
30

actions

Shared GitHub Actions
Shell
1
star
31

prettier-config

My personal Prettier configuration
JavaScript
1
star
32

bridgetown-gh-pages-demo

Demo of the new gh-pages configuration in Bridgetown v1.0
JavaScript
1
star
33

github-actions

MOVED TO andrewmcodes/actions
1
star
34

vscode-tailwindcss-extension-pack

An extension pack for VSCode of extensions for developing with Tailwind CSS.
1
star
35

remote-ruby-vault

Obsidian vault of Remote Ruby episodes for personal research
JavaScript
1
star
36

bridgetown-esbuild-minifySyntax

Benchmarking usage of minifySyntax with esbuild and Bridgetown
JavaScript
1
star
37

warp-radix

Warp theme based on the Radix color system
1
star
38

advent_of_code

Solutions to Advent of Code
Ruby
1
star