Huge News!Announcing our $40M Series B led by Abstract Ventures.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
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc