šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

@astropub/assist

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astropub/assist

A library of tools to help you develop with Astro

0.1.2
latest
npm
Version published
Weekly downloads
4
-42.86%
Maintainers
1
Weekly downloads
Ā 
Created
Source

Astro Assist

Astro Assist is a library of tools to help you develop with Astro.

Usage

Install Astro Assist to your project.

npm install @astropub/assist

Add Astro Assist to your Astro configuration.

// astro.config.js
import assist from '@astropub/assist'

/** @type {import('astro').AstroUserConfig} */
const config = {
  vite: {
    plugins: [
      assist()
    ]
  }
}

export default config

Enjoy!

Features

addAsset

The addAsset method lets you add an asset to the project. The asset will be available in develoment and automatically bundle during build.

Example:

---
// src/pages/kitten.astro
import * as assist from '@astropub/assist'

const kitten = assist.addAsset(Astro.resolve('kitten.jpg'))
---
<img src={kitten} alt="kitten" />

Example in a Component:

---
// src/components/Image.astro
import * as assist from '@astropub/assist'

const src = assist.addAsset(Astro.resolve(Astro.props.src))
---
<img {...Astro.props} {src} />

process

The process method lets you modify an asset that is added to the project. The modified asset will be cached to avoid any repetitive expensive processing.

The process method provides the asset source as a Buffer and the asset details as an Object and returns a new Buffer.

Example:

// astro.config.js
import assist from '@astropub/assist'

/** @type {import('astro').AstroUserConfig} */
const config = {
  vite: {
    plugins: [
      assist({
        async process(buffer, asset) {
          return await doSomethingWith(buffer)
        }
      })
    ]
  }
}

export default config

Example in a Component:

---
import * as assist from '@astropub/assist'

const src = assist.addAsset(Astro.resolve(Astro.props.src), {
  async process(buffer, asset) {
    return await doSomethingWithTheImage(buffer)
  }
})
---
<img {...Astro.props} {src} />

Keywords

asset

FAQs

Package last updated on 28 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts