npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

astro-link

v1.2.1

Published

Supercharge your links. This component detects external / anchor / same domain / mail / telephone `href`, and apply optimizations accordingly.

Downloads

862

Readme

🚀  Astro — Link, with smart optimizations

NPM Downloads ISC License PRs Welcome
TypeScript Prettier EditorConfig ESLint

Supercharge your links.
This component detects external / anchor / same domain / mail / telephone href, and apply optimizations accordingly.

Features

  • External links
    • rel="noopener nofollow" for search engines optimization
    • target="_blank" for opening link in a new tab
  • JS-based obfuscation for mailto: and tel: links
  • Applying CSS classes for specific link types
  • Internal links
    • Auto prefix URLs with 'BASE_URL'
    • Auto add the rel=prefetch marker (e.g. for @astrojs/prefetch)

Some of these features can be disabled if needed.

Classes

  • link
  • is-external
  • is-internal
  • is-hash
  • is-mail
  • is-tel
  • has-hint

You can then style these globally with :global(.link.is-mail) for example.

📦  Installation

pnpm i astro-link

🛠  Usage

---
import { Link } from 'astro-link';
// ...
---
<!-- ... -->
<body>
	<!-- Place component inside `BODY` tag -->

	<Link
		href={'https://www.juliancataldo.com' /* Required */}
		title={'Bonjour !'}
		externalInNewTab={true}
	>
		Some <strong>external</strong> link, loaded in current tab
	</Link>

	<!-- ... -->
</body>

🎉  Result

<a
	href="https://www.juliancataldo.com"
	class="link is-external astro-H4CCARKM"
	rel="noopener nofollow"
	target="_blank"
>
	Some external link, loaded in a new tab
</a>

🎨  Styling

As all component in this collection, you are responsible to bring style to them.
This will give you maximum freedom, still you can prevent most of potential styles leaking when needed.

Of course, as links are ubiquitous in any website, it's totally valid to style them globally with is:global.


Semi-scoped styles inside parent (it won't effect upstream, only downstream):

<style lang="scss">
	.my-parent-with-custom-links {
		// Use `:global` as a localized escape hatch:

		& :global(.link) {
			font-weight: 700;
			color: green;
		}
		& :global(.link.is-tel) {
			background: yellow;
		}
		& :global(.link.is-mail) {
			color: red;
		}
	}
</style>

-OR-

Global styles (in your layout component, for example):

<style lang="scss" is:global>
	a.link {
		font-weight: 700;
		color: green;
	}
	// ...
</style>

To do

  • [ ] Support Astro base option for prefixing hrefs.

LIVE DEMO  🎭  DOCUMENTATION WEBSITE ⎋

Live demo website

code.juliancataldo.com


🔗  JulianCataldo.com