docs: update readme

This commit is contained in:
pengzhanbo 2024-01-31 12:29:05 +08:00
parent ce3f45733c
commit a35258fa47
11 changed files with 133 additions and 59 deletions

BIN
docs/preview-blog.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 KiB

BIN
docs/preview-home.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 MiB

BIN
docs/preview-note.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 KiB

BIN
docs/preview-post.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 498 KiB

View File

@ -0,0 +1,106 @@
English | [简体中文](./README.md)
# `vuepress-plugin-netlify-functions`
If your vuepress site is deployed on `netlify` and you want to be able to use `netlify functions` for ` serverless`.
You may need this plugin to provide support.
## Features
- On the Vuepress local server, start a `Netlify Functions` local service to help you debug `functions` locally.
- Generate a usable `netlify.toml` and add the appropriate 'functions' configurations if you have already created` netlify.toml`
- This plugin does not provide specific `function` scripts, only `netlify functions` support; It can be used directly in themes, directly in vuepress projects, or based on this plugin, new plugins can be developed to provide more detailed functionality support.
- Use `dotenv` to provide support similar to `Netlify Environment variables` in the local service environment. Create `.env` files in the project root directory to hold development-time environment variables
## Install
```sh
npm install vuepress-plugin-netlify-functions
# or
pnpm add vuepress-plugin-netlify-functions
# or
yarn add vuepress-plugin-netlify-functions
```
## Usage
1. In a Vuepress project, or in a Vuepress theme
``` js
// .vuepress/config.[jt]s
import { netlifyFunctionsPlugin } from 'vuepress-plugin-netlify-functions'
export default {
// ...
plugins: [
netlifyFunctionsPlugin()
]
// ...
}
```
2. In a vuepress plugin:
``` js
import { useNetlifyFunctionsPlugin } from 'vuepress-plugin-netlify-functions'
function myPlugin(): Plugin {
return (app: App) => {
const {
// proxy prefix, default: /api
proxyPrefix,
preparePluginFunctions,
generatePluginFunctions
} = useNetlifyFunctionsPlugin(app, {
// Specifies the functions directory for the plugin where the relevant scripts are developed
directory: path.resolve(__dirname, 'functions')
})
return {
name: 'vuepress-plugin-myPlugin',
onPrepared: () => preparePluginFunctions(),
onGenerated: () => generatePluginFunctions(),
}
}
}
```
## Methods
### `netlifyFunctionsPlugin(options)`
plugin function
In the Vuepress configuration, or in the Vuepress topic configuration.
__options__
- `options.sourceDirectory` functions source directory。
@default `app.dir.source('.vuepress/functions')。
- `options.destDirectory` functions output directory
@default `app.dir.dest('function')
- `options.proxyPrefix` server proxy prefix
@default `/api`
functions request to proxy `^/api/*`
### `useNetlifyFunctionsPlugin(app, options)`
Used in the plugin when developing the VuePress plugin
__app__: `App`
__options__
- `options.directory`
Functions development directory in plugin
## Example
- [vuepress-plugin-page-collection](https://github.com/pengzhanbo/vuepress-theme-plume/tree/main/packages/plugin-page-collection) Log and display the number of page views/visits of blog articles by connecting `leanCloud` in functions based on `netlify-functions`

View File

@ -1,27 +1,18 @@
[English](./README.en-US.md) | 简体中文
# `vuepress-plugin-netlify-functions`
If your vuepress site is deployed on `netlify` and you want to be able to use `netlify functions` for ` serverless`.
You may need this plugin to provide support.
如果你的 vuepress 站点是部署在 `netlify` 的,而且希望能够使用`netlify functions` 来做 `serverless`
那么你可能需要本插件提供支持。
## Feature
- On the Vuepress local server, start a `Netlify Functions` local service to help you debug `functions` locally.
- Generate a usable `netlify.toml` and add the appropriate 'functions' configurations if you have already created` netlify.toml`
- This plugin does not provide specific `function` scripts, only `netlify functions` support; It can be used directly in themes, directly in vuepress projects, or based on this plugin, new plugins can be developed to provide more detailed functionality support.
- Use `dotenv` to provide support similar to `Netlify Environment variables` in the local service environment. Create `.env` files in the project root directory to hold development-time environment variables
## 功能
- 在 vuepress 本地服务器上,启动一个 `netlify functions` 本地服务,帮助你在本地对 `functions` 进行调试。
- 帮助生成一个 可用的 `netlify.toml` ,如果你已经创建了 `netlify.toml`,会添加合适的 `functions` 配置
- 本插件不提供具体的 `function` 脚本,仅提供 `netlify functions` 支持;可以在主题中直接只用,也可以在 vuepress 项目中直接使用,也可以基于本插件,开发新的插件提供更详细的功能支持。
- 使用 `dotenv` 在本地服务环境提供 类似于 `netlify environment variables` 支持。 在项目根目录下 创建 `.env` 文件用于保存开发时环境变量
## Install
## 安装
```sh
npm install vuepress-plugin-netlify-functions
@ -30,11 +21,10 @@ pnpm add vuepress-plugin-netlify-functions
# or
yarn add vuepress-plugin-netlify-functions
```
## Usage
1. In a Vuepress project, or in a Vuepress theme
## 使用
在 vuepress 项目中,或者在一个 vuepress 主题中
1. 在 vuepress 项目中,或者在一个 vuepress 主题中
``` js
// .vuepress/config.[jt]s
import { netlifyFunctionsPlugin } from 'vuepress-plugin-netlify-functions'
@ -48,22 +38,18 @@ yarn add vuepress-plugin-netlify-functions
}
```
2. In a vuepress plugin:
在 vuepress plugin 中:
2. 在 vuepress plugin 中:
``` js
import { useNetlifyFunctionsPlugin } from 'vuepress-plugin-netlify-functions'
function myPlugin(): Plugin {
return (app: App) => {
const {
// proxy prefix, default: /api
// 请求前缀, 默认 /api
proxyPrefix,
preparePluginFunctions,
generatePluginFunctions
} = useNetlifyFunctionsPlugin(app, {
// Specifies the functions directory for the plugin where the relevant scripts are developed
// 指定插件的functions目录相关脚本在此目录中开发
directory: path.resolve(__dirname, 'functions')
})
@ -80,32 +66,12 @@ yarn add vuepress-plugin-netlify-functions
### `netlifyFunctionsPlugin(options)`
plugin function
In the Vuepress configuration, or in the Vuepress topic configuration.
插件函数。
在 vuepress 配置中,或者在 vuepress 主题配置中使用。
__options__
- `options.sourceDirectory` functions source directory。
@default `app.dir.source('.vuepress/functions')。
- `options.destDirectory` functions output directory
@default `app.dir.dest('function')
- `options.proxyPrefix` server proxy prefix
@default `/api`
functions request to proxy `^/api/*`
__options__
- `options.sourceDirectory` functions 源文件夹。
默认 `app.dir.source('.vuepress/functions') 目录。
@ -122,8 +88,6 @@ __options__
### `useNetlifyFunctionsPlugin(app, options)`
Used in the plugin when developing the VuePress plugin
在 开发 vuepress 插件时, 在插件中使用
__app__: `App`
@ -132,8 +96,6 @@ __options__
- `options.directory`
Functions development directory in plugin
插件中的 functions 开发目录
## 查看详细说明文档
@ -142,8 +104,6 @@ __options__
## Example
- [vuepress-plugin-page-collection](https://github.com/pengzhanbo/vuepress-theme-plume/tree/main/packages/plugin-page-collection) Log and display the number of page views/visits of blog articles by connecting `leanCloud` in functions based on `netlify-functions`
## 示例
### 插件开发示例

View File

@ -1,8 +1,8 @@
## vuepress-theme-plume
一个简约的 vuepress 主题。
一个简约的,干净的,容易上手的 vuepress 主题,适用于博客和文档
开箱即用,仅需少量配置即可使用,让您更专注于 内容的创作。
开箱即用,仅需少量配置即可使用,让您更专注于 内容的创作,更好的表达你的想法,形成你的知识笔记
[![npm version](https://img.shields.io/npm/v/vuepress-theme-plume?color=32A9C3&labelColor=1B3C4A&label=npm)](https://www.npmjs.com/package/vuepress-theme-plume)
[![npm beta download](https://img.shields.io/npm/dt/@vuepress-plume/vuepress-theme-plume?color=32A9C3&labelColor=1B3C4A&label=beta%20downloads)](https://www.npmjs.com/package/vuepress-theme-plume)
@ -16,7 +16,7 @@
``` sh
npm install vuepress@next vuepress-theme-plume
# or
pnpm add vuepress@next vuepress-theme-plume vue @vuepress/client
pnpm add vuepress@next vuepress-theme-plume vue
# or
yarn add vuepress@next vuepress-theme-plume
```
@ -45,16 +45,6 @@ __options__ : `PlumeThemeOptions`
- [我的个人博客](https://pengzhanbo.cn/)
### 效果图
![](/docs/preview-home.png?a=1)
![](/docs/preview-blog.png?a=1)
![](/docs/preview-post.png?a=1)
![](/docs/preview-note.png?a=1)
## 内置插件
- [plugin-shikiji](https://github.com/pengzhanbo/vuepress-theme-plume/tree/main/plugins/plugin-shikiji) 使用 [`shikiji`](https://shikiji.netlify.app/) 来为 Markdown 代码块启用代码高亮。
@ -85,3 +75,21 @@ __options__ : `PlumeThemeOptions`
## 贡献指南
查看 [[贡献指南]](/CONTRIBUTING.md) 了解更多
### 效果图
**home page**
![](/docs/preview-home.jpeg)
**blog page**
![](/docs/preview-blog.jpeg)
**post page**
![](/docs/preview-post.jpeg)
**note page**
![](/docs/preview-note.jpeg)