An open API service indexing awesome lists of open source software.

https://github.com/pumpncode/fresh-plugin-svg-inject

This is a plugin for fresh that injects SVGs referenced in img tags into the rendered html text.
https://github.com/pumpncode/fresh-plugin-svg-inject

deno fresh fresh-plugin

Last synced: 4 months ago
JSON representation

This is a plugin for fresh that injects SVGs referenced in img tags into the rendered html text.

Awesome Lists containing this project

README

          

# fresh-plugin-svg-inject

This is a plugin for [fresh](https://github.com/denoland/fresh) that injects SVGs referenced in `img` tags into the rendered html text.

It turns this:

```html


```

```html



```

into this:

```html



```

before your site gets served.

The ids are renamed to avoid collisions. This plugin is in essence a modern, less sophisticated port of [iconfu/svg-inject](https://github.com/iconfu/svg-inject) for fresh.

## Usage

```js
import tailwind from "$fresh/plugins/tailwind.ts";
import svgInjectPlugin from "https://deno.land/x/fresh_plugin_svg_inject/main.js";
import { defineConfig } from "$fresh/server.ts";

export default defineConfig({
plugins: [
tailwind(),
svgInjectPlugin()
]
});
```

You can also pass an options object to `svgInjectPlugin()` with a single `staticFolder` option, which should be the same as the `staticDir` option specified on the fresh config. Default is `"./static"` and I know this should be read automatically but I have no idea how; contributions are welcome.

## Contributing

We appreciate your help! To contribute, please read our [contributing instructions](./contributing.md).