项目作者: PicGo

项目描述 :
:truck:A PicGo plugin for pictures in markdown files migrating from one picBed to another one.
高级语言: TypeScript
项目地址: git://github.com/PicGo/picgo-plugin-pic-migrater.git
创建时间: 2019-01-20T15:49:13Z
项目社区:https://github.com/PicGo/picgo-plugin-pic-migrater

开源协议:MIT License

下载


picgo-plugin-pic-migrater

PicGo Convention

A PicGo plugin for pictures in markdown files migrating from one picBed to another one.

中文说明

Features

  1. This plugin can be used in CLI & GUI version of PicGo!
  2. It supports absolute and relative path of images, and the url path of images.
  3. It supports both markdown format and html format image url in markdown file. (Since v1.3.0)

For example, a test.md:

  1. ![](./js.jpg)
  2. ![](http://xxx.com/js.jpg)
  3. <!-- since v1.3.0, support migrating img src -->
  4. <img src="http://yyy.com/js.jpg" />

if you choose imgur as your migrated picBed, after migrating:

  1. ![](https://i.imgur.com/xxx.jpg)
  2. ![](https://i.imgur.com/xxxx.jpg)
  3. <!-- since v1.3.0, support migrating img src -->
  4. <img src="http://i.imgur.com/xxxxx.jpg" />

Version required

picgo-plugin-pic-migrater <= 1.2.2 requires PicGo-GUI version 2.0.2 ~ 2.2.0, PicGo-Cli version 1.4.0 ~ 1.5.0-.

picgo-plugin-pic-migrater > 1.2.2 requires PicGo-GUI version 2.3.0 ~ latest beta, PicGo-Cli version 1.5.0-alpha.1 ~ latest alpha.

Installation

CLI

  1. picgo install pic-migrater

Then pic-migrater will registe a command named migrate.

GUI

search for pic-migrater

Configuration

Please configurate this plugin first!

After migrating, a new markdown file will be written in the same folder. So you should configurate this new file name’s suffix first.

CLI

  1. picgo set plugin pic-migrater

GUI

Open the setting page in the menu of the plugin.

Details

newFileSuffix

For example, if your origin file named 2019.md & if you set the newFileSuffix to _new, then after migrating, a new file named 2019_new.md will be created.

include

If you set the include configuration then migrator will only migrate the files’ path or url which match the include.

For example, if your set the include to sinaimg.cn, then migrator will only migrate the url or path includes sinaimg.cn.

exclude

If you set the exclude configuration then migrator will only migrate the files’ path or url which don’t match the exclude.

For example, if your set the exclude to sinaimg.cn, then migrator will only migrate the url or path doesn’t includes sinaimg.cn.

oldContentWriteToNewFile

Since v1.3.0

If you set the oldContentWriteToNewFile to true, then the old content will be written to the new file and the migrated content will be written to the old file.

Usage

CLI

  1. $ picgo migrate -h
  2. Usage: migrate [options] <files...>
  3. migrating pictures url from markdown files
  4. Options:
  5. -h, --help output usage information
  6. Note:
  7. You should configurate this plugin first!
  8. picgo set plugin pic-migrater
  9. Examples:
  10. # migrate file or files
  11. $ picgo migrate ./test.md ./test1.md
  12. # migrate markdown files in folder
  13. $ picgo migrate ./test/

GUI

Node.js Project(v1.2.3+)

  1. const { PicGo } = require('picgo')
  2. const PluginMigrater = require('picgo-plugin-pic-migrater')
  3. const picgo = new PicGo()
  4. picgo.setConfig({
  5. 'picgo-plugin-pic-migrater': {
  6. newFileSuffix: '_new',
  7. include: '',
  8. exclude: ''
  9. }
  10. })
  11. const plugin = PluginMigrater(picgo)
  12. plugin.migrateFiles(['/xxx/yyy.md']) // { total: number, success: number }

Thanks

Thanks to @Moyf with the python version of this plugin.