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

vuepress-plugin-netlify-functions

v1.0.0-rc.71

Published

The Plugin for VuePress 2, Support Netlify Functions

Downloads

70

Readme

vuepress-plugin-netlify-functions

English | 简体中文

如果你的 vuepress 站点是部署在 netlify 的,而且希望能够使用netlify functions 来做 serverless

那么你可能需要本插件提供支持。

功能

  • 在 vuepress 本地服务器上,启动一个 netlify functions 本地服务,帮助你在本地对 functions 进行调试。
  • 帮助生成一个 可用的 netlify.toml ,如果你已经创建了 netlify.toml,会添加合适的 functions 配置
  • 本插件不提供具体的 function 脚本,仅提供 netlify functions 支持;可以在主题中直接只用,也可以在 vuepress 项目中直接使用,也可以基于本插件,开发新的插件提供更详细的功能支持。
  • 使用 dotenv 在本地服务环境提供 类似于 netlify environment variables 支持。 在项目根目录下 创建 .env 文件用于保存开发时环境变量

安装

npm install vuepress-plugin-netlify-functions
# or
pnpm add vuepress-plugin-netlify-functions
# or
yarn add vuepress-plugin-netlify-functions

使用

  1. 在 vuepress 项目中,或者在一个 vuepress 主题中

    // .vuepress/config.[jt]s
    import { netlifyFunctionsPlugin } from 'vuepress-plugin-netlify-functions'
    
    export default {
      // ...
      plugins: [
        netlifyFunctionsPlugin()
      ]
      // ...
    }
  2. 在 vuepress plugin 中:

    import { useNetlifyFunctionsPlugin } from 'vuepress-plugin-netlify-functions'
    
    function myPlugin(): Plugin {
      return (app: App) => {
        const {
          // 请求前缀,  默认 /api
          proxyPrefix,
          preparePluginFunctions,
          generatePluginFunctions
        } = useNetlifyFunctionsPlugin(app, {
          // 指定插件的functions目录,相关脚本在此目录中开发
          directory: path.resolve(__dirname, 'functions')
        })
        return {
          name: 'vuepress-plugin-myPlugin',
          onPrepared: () => preparePluginFunctions(),
          onGenerated: () => generatePluginFunctions(),
        }
      }
    }

Methods

netlifyFunctionsPlugin(options)

插件函数。

在 vuepress 配置中,或者在 vuepress 主题配置中使用。

options

  • options.sourceDirectory functions 源文件夹。

    默认 `app.dir.source('.vuepress/functions') 目录。

  • options.destDirectory functions 输出文件夹。

    默认 `app.dir.dest('function') 目录

  • options.proxyPrefix proxy代理前缀。

    默认 /api

    functions下的请求通过 /api 转发

useNetlifyFunctionsPlugin(app, options)

在 开发 vuepress 插件时, 在插件中使用

  • app: App

  • options.directory

    插件中的 functions 开发目录

查看详细说明文档

待补充

Example

示例

插件开发示例

  • vuepress-plugin-page-collection 基于 netlify-functions 的,通过在 functions中连接 leancloud 实现 博客文章页 阅读数/访问次数 的记录与展示。