@astropub/url-protocol
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

URL Protocol

URL Protocol lets you use a url: protocol to link to local files in Astro.

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>URL Protocol: Inline Example</title>
    <link rel="stylesheet" href={await import('url:style.css')} />
  </head>
  <body>
    <h1>URL Protocol: Inline Example</h1>
  </body>
</html>
---
import styleURL from 'url:style.css'
---
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>URL Protocol: Frontmatter Example</title>
    <link rel="stylesheet" href={await styleURL} />
  </head>
  <body>
    <h1>URL Protocol: Frontmatter Example</h1>
  </body>
</html>

Usage

Install URL Protocol to your project.

npm install @astropub/url-protocol

Add URL Protocol to the renderers list.

// astro.config.js
export default {
  renderers: [
    '@astropub/url-protocol'
  ]
}

You can also add URL Protocol as a Vite Plugin.

// astro.config.js
import { urlProtocolPlugin } from '@astropub/url-protocol'

export default {
  vite: {
    plugins: [
      urlProtocolPlugin()
    ]
  }
}

Package Sidebar

Install

npm i @astropub/url-protocol

Weekly Downloads

1

Version

0.1.0

License

CC0-1.0

Unpacked Size

5.91 kB

Total Files

10

Last publish

Collaborators

  • jonathantneal