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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ykocaman/astro-medium-loader

v0.2.4-2

Published

Astro plugin to fetch Medium feeds by username

Downloads

60

Readme

@ykocaman/astro-medium-loader

npm version npm downloads GitHub stars GitHub issues

An Astro loader that fetches and parses Medium RSS feeds by username. Supports canonical links, optional caching, and flexible storage strategies.

Installation

pnpm install @ykocaman/astro-medium-loader
# or
npm install @ykocaman/astro-medium-loader
# or
yarn add @ykocaman/astro-medium-loader

Usage

Import and configure the loader in your content.config.ts:

1. Live Fetching (Every Request)

Fetch and parse the user’s Medium posts on every build or request.

// content.config.ts
import { defineCollection } from 'astro:content';
import { mediumLoader } from '@ykocaman/astro-medium-loader';

const medium = defineCollection({
  loader: mediumLoader({
    username: 'ykocaman'
  })
});

export const collections = { medium };

2. Cached Fetching (Recommended for Development)

Cache the fetched feed under .astro/storage/medium to speed up repeated requests during development.

// content.config.ts
import { defineCollection } from 'astro:content';
import { mediumLoader } from '@ykocaman/astro-medium-loader';

const medium = defineCollection({
  loader: mediumLoader({
    username: 'ykocaman',
    storage: {
      enabled: true,
      path: '.astro/storage/medium'
    }
  })
});

export const collections = { medium };

Note: The .astro directory is typically git-ignored, so each new deploy will re-fetch the latest Medium posts.

3. Persistent Storage (Offline Builds)

Store the feed data permanently in a local directory (e.g. src/content/medium) so no further requests to Medium are needed after the initial build.

// content.config.ts
import { defineCollection } from 'astro:content';
import { mediumLoader } from '@ykocaman/astro-medium-loader';

const medium = defineCollection({
  loader: mediumLoader({
    username: 'ykocaman',
    storage: {
      enabled: true,
      path: 'src/content/medium'
    }
  })
});

export const collections = { medium };

Note: On the first build, the loader writes to src/content/medium/${username}.json. Subsequent builds read directly from that file.

4. Rendering Your Collection

Use Astro’s content API to retrieve and render your Medium posts just like any other collection:

---
import { type CollectionEntry, getCollection, render } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';

export async function getStaticPaths() {
	const posts = await getCollection('medium');
	return posts.map((post) => ({
		params: { slug: post.id },
		props: post,
	}));
}
type Props = CollectionEntry<'medium'>;

const post = Astro.props;
const { Content } = await render(post);
---

<BlogPost {...post.data}>
	<Content />
</BlogPost>

Options

| Option | Type | Default | Description | | ----------------- | ------- | ------- | --------------------------------------------------------------------------------------------- | | username | string | — | Medium username (without the @) | | storage.enabled | boolean | false | Enable caching or persistent storage | | storage.path | string | .astro/storage/medium | Path to content directory (e.g. src/content/medium) |

Features

  • RSS Fetching & Parsing Automatically fetches and parses Medium RSS feeds.
  • Canonical Links Injects a canonical link pointing back to the original Medium post.
  • Flexible Caching Cache feed data in .astro for faster development builds.
  • Persistent Content Storage Save feed output to your src/content directory for offline or CI-friendly builds.
  • Full Astro Content Integration Works seamlessly with Astro’s default blog template, render and getCollection APIs.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'Add my feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License.