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

nuxt-content-lite

v1.4.6

Published

Light-use, markdown driven content engine inspired by Nuxt Content

Downloads

26

Readme

Nuxt Content Lite

npm version npm downloads License Nuxt

Light-use markdown driven content engine inspired by Nuxt Content for doing amazing things with markdown, with less.

Why?

Nuxt Content is an amazing module, but it's a bit heavy for some use cases. Nuxt Content Lite is a lightweight alternative for those who don't need all the bells and whistles.

The goal of Nuxt Content Lite is to provide a simple, lightweight, and flexible way to use markdown content in your Nuxt app or website, while keeping things light and fast.

Who is this for?

Smaller sites, blogs, and apps that don't need all the bells and whistles of Nuxt Content.

The primary use case for Nuxt Content Lite is for small sites that need a little more than just static content, but don't need a full-blown CMS like Wordpress.

If you're building a large site, a blog with a ton of posts, or app, you should probably use Nuxt Content.

What's the difference?

We use tuples instead of objects for storing content!

...and we don't have a lot of the features that Nuxt Content has.

Currently, Nuxt Content Lite renders all content into a single file on build. This means that while you can use Nuxt Content Lite to build a blog, you probably shouldn't use it to build a blog with a ton of posts.

We're working on a way to split content into multiple files, but for now, Nuxt Content Lite is best for smaller sites.

Usage

The primary way to use Nuxt Content Lite is with the ContentLiteDoc component and the useContentLite composable.

ContentLiteDoc

The ContentLiteDoc component is a simple component that renders markdown content. It's primary use is for rendering markdown content in a page or layout.

It accepts an optional item prop, which is the content item you want to render the content for.

If no item prop is provided, it will attempt to fetch the content for the current route, using the singleRouteContent method of the useContentLite composable.


<template>
  <ContentLiteDoc/>
  <!-- or -->
  <ContentLiteDoc :item="item"/>
  <!-- or -->
  <div v-for="post in posts" :key="post.slug">
    {{post.title}}
  </div>
</template>

<script lang="ts" setup>

  // instantiate the composable
  import { IContentLiteItem } from "./index"

  const cl = await useContentLite({
    // generates word list w/ counts as Map<string, number> 
    // as `words` property on the content item
    filterable: true,
    // flattens the frontmatter into the content item
    flattenData: true,
  })

  // get a single content item for the current route
  const item = await cl.singleRouteContent()
  // or at a specific path
  const post = await cl.findOne("blog/awesome-post")
  const author = await cl.findOne(`authors/${post.author}`)


  // get all content for the current route
  const allItems = await cl.routeContent()
  // or all content for a specific path
  const posts = await cl.find("blog")


  // get all content
  const allContent = cl.contentData

</script>

Features

  • Markdown-based content
  • Frontmatter
  • Supports Nuxt layers
  • Supports Vue components

Roadmap

  • [x] ~~Markdown content~~
  • [x] ~~Markdown content rendering~~
  • [x] ~~Vue Composable~~
  • [x] ~~ContentLiteDoc component~~
  • [x] ~~Basic content rendering~~
  • [x] ~~Frontmatter~~
  • [x] ~~Nuxt layers~~
  • [x] ~~Vue components~~
  • [x] ~~Generate unique word lists with counts~~
  • [x] ~~Find all content for path~~
  • [x] ~~Find single content for route/path~~
  • [x] ~~Live content updates during development~~
  • [ ] Content API
  • [ ] (better) Content search
  • [ ] Content pagination
  • [ ] Content tags
  • [ ] Content categories
  • [ ] Split content into multiple files
  • [ ] Content caching

Quick Setup

  1. Add nuxt-content-lite dependency to your project
# Using pnpm
pnpm add -D nuxt-content-lite

# Using yarn
yarn add --dev nuxt-content-lite

# Using npm
npm install --save-dev nuxt-content-lite
  1. Add nuxt-content-lite to the modules section of nuxt.config.ts
export default defineNuxtConfig({
    modules: [
        'nuxt-content-lite'
    ]
})

That's it! You can now use Nuxt Content Lite in your Nuxt app ✨

Development

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release