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

@juliendargelos/nuxt-admin

v1.0.3

Published

Admin module for nuxt using Netlify CMS.

Downloads

4

Readme

Nuxt admin

Admin module for nuxt using Netlify CMS.

Install

With yarn:

yarn add @juliendargelos/nuxt-admin

With npm:

npm install @juliendargelos/nuxt-admin --save

Usage

Nuxt admin makes your static nuxt project able to edit data files through Netlify CMS.

I recommend using the nuxt-data package to manage yaml data files.

Also see my nuxt-starter which is an example using nuxt-admin and nuxt-data.

Read the Netlify CMS documentation for more informations.

Add the module in your nuxt config:

export default {
   modules: [
    ['@juliendargelos/nuxt-admin', {
      title: 'My website - Admin',
      lazy: !process.env.ADMIN
    }]
   ]
}

Options:

  • title (default: 'Admin'): Specify the title of the admin page.
  • lazy (default: false): If set to true, the admin page will not be built if it has already been.

Create the admin folder

Create the following files at the root of your nuxt project:

Import and configure admin

You have to import nuxt admin from pages/index.vue and admin/index.js:

// pages/index.vue

<script>
import 'admin' // required
</script>
// admin/index.js

import 'admin' // Required
import '~/assets/admin.sass' // You can import a custom stylesheet
import cms from 'netlify-cms' // Required
import Preview from 'admin/preview'
import Home from '~/pages/index'
import Article from '~/components/article'

// Register your stylesheets
cms.registerPreviewStyle(document.querySelector('link[rel="stylesheet"]').href)

// Register your previews
cms.registerPreviewTemplate('home', Preview.for(Home))
cms.registerPreviewTemplate('article', Preview.for(Article))

You can use any of your vue component as a Netlify CMS preview with Preview.for which creates a bridge from react to vue.

Your vue component will recieve data from admin form as props (see Netlify CMS widgets):

# static/admin/config.yml

collections:
  - label: Articles
    label_singular: Article
    name: article
    folder: data/articles/
    extension: yml
    create: true
    fields:
      - {label: Title, name: title, widget: string}
      - {label: Image, name: image, widget: image}
      - {label: Content, name: content, widget: markdown}

components/article.vue:

<template>
  <div>
    <h2>{{title}}</h2>
    <img :src="image">
    <Markdown :source="content"/>
  </div>
</template>

<script>
  import Markdown from '~/components/markdown'

  export default {
    props: ['title', 'content', 'image'],

    components: {
      Markdown // Assuming that this component translates markdown into html
    }
  }
</script>

Build

The admin page is generated in a separate webpack process which output to static/admin. So the admin page is published as a static file, independently of vue and vue router.

The admin page is only generated when NODE_ENV is equal to 'production'. So make sure to run nuxt build or nuxt generate before running nuxt if you want to access admin from dev server.

You might want to push the built admin to your repository so Netlify deploys will be much faster. Also use the lazy module option to prevent unnecessary admin build when deploying to Netlify (especially for deploys triggered by Netlify CMS):

// nuxt.config.js

export default {
  modules: [
    ['@juliendargelos/nuxt-admin', {
      lazy: !!process.env.CONTEXT // The CONTEXT environment variable is set by Netlify
    }]
  ]
}