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 🙏

© 2026 – Pkg Stats / Ryan Hefner

astro-loader-google-docs

v0.2.2

Published

Astro content loader to use Google Docs as a data source

Readme

Npm Build Status Coverage Downloads PRs welcome MIT license Sponsor


astro-loader-google-docs is an Astro content loader that uses Google Docs as a data source. It syncs a Google Drive folder with google-docs-sync and stores one entry per document in a content collection.

Features

  • One collection entry per document, rendered with render(entry)
  • Metadata validated by a Zod schema, the covers can be optimised images too
  • Images optimised by Astro
  • Incremental syncs: only the documents that changed are fetched and rendered again

Installation

Requires Node 22.12 or later and Astro 5 or later.

npm install astro-loader-google-docs

The loader needs 3 variables (GOOGLE_OAUTH_CLIENT_ID, GOOGLE_OAUTH_CLIENT_SECRET and GOOGLE_DOCS_TOKEN) in the environment of the build. Astro does not put the .env file in process.env: load it in astro.config.mjs with process.loadEnvFile(). Generate them with npx google-docs-sync-token, see the google-docs-sync documentation.

Usage

Go to your Google Drive, create a folder and put some documents inside it. The folders tree gives the slugs and breadcrumbs, and the description of the folders and documents holds their YAML metadata: see organize your documents.

Add the loader to your collection in src/content.config.ts.

import {defineCollection} from "astro:content"
import {
  createGoogleDocsSchema,
  googleDocsLoader,
} from "astro-loader-google-docs"

const docs = defineCollection({
  loader: googleDocsLoader({
    // https://drive.google.com/drive/folders/FOLDER_ID
    folder: "FOLDER_ID",
  }),
  // Optional: makes the covers optimised images
  schema: ({image}) => createGoogleDocsSchema({image}),
})

export const collections = {docs}

Then render the documents like any other collection.

---
import {getCollection, render} from "astro:content"

const docs = await getCollection("docs")
const {Content} = await render(docs[0])
---

<h1>{docs[0].data.name}</h1>
<Content />

The examples/basic site lists the documents of a Drive folder and renders each of them.

Options

googleDocsLoader(options) takes the options of google-docs-sync (folder, outputDir, cacheDir, imagesOptions, debug) and the conversion options of google-docs-to-markdown, with the same names as in gatsby-source-google-docs. The extension is always md: the documents are rendered as Markdown, MDX is not supported.

outputDir and cacheDir are relative to the root of the Astro site. The loader owns outputDir: any other file it contains is deleted, so do not point it to a folder holding your own files. Add outputDir and cacheDir to your .gitignore.

Entries

  • The id of an entry is the path of its file under outputDir, without the extension: index for the root document, guides/install for a nested one.
  • The data of an entry are the metadata of the document: id, name, slug, path, date, createdTime, modifiedTime, breadcrumb, description, cover, related, and the custom metadata of the Drive description.
  • With the comments option, data.comments holds the comments of the document.
  • createGoogleDocsSchema({image}) builds that schema. The loader declares it by default, so the schema of the collection is optional: define it to turn the covers into optimised images.

Images

The images of the documents are written next to them in outputDir, and the Markdown refers to them with relative paths. The loader renders each document relative to its file, so Astro treats them like the images of local Markdown files: they are optimised and fingerprinted at build time. Nothing has to be copied to public/.

Support this project