BlogTool.Core 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BlogTool.Core --version 0.2.0                
NuGet\Install-Package BlogTool.Core -Version 0.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlogTool.Core" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlogTool.Core --version 0.2.0                
#r "nuget: BlogTool.Core, 0.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlogTool.Core as a Cake Addin
#addin nuget:?package=BlogTool.Core&version=0.2.0

// Install BlogTool.Core as a Cake Tool
#tool nuget:?package=BlogTool.Core&version=0.2.0                

BlogTool

使用Hexo风格的Markdown格式化,整理与归档图片的工具。

介绍

根据指定的Hexo模板(Scaffold) 批量将Markdown文件格式化,并将Markdown编辑插入的图片保存到本地。

特点

  1. 支持MetaWeblog协议
  2. Hexo模板头处理和常用标签处理
  3. 支持图片保存为内嵌Base64编码
  4. 支持图片保存为资源文件夹
  5. 支持图片保存为标签插件
  6. 支持自定义图片文字水印(支持:PNG、JPG、Webp、Gif、Tiff、BMP)
  7. 支持图片压缩(支持:PNG、JPG、Webp、Tiff),转换格式

更新内容

Date Version Content
V0.1.0 2024-4-22 初始版本
V0.2.0 2024-5-3 完成本地获取Markdown文件

配置

支持基于JSON配置文件和命令行参数配置。

配置文件

默认的配置文件appsettings.json内容如下:

{
  "HexoPath": "./", //指定一个Hexo的根目录,其中必须包含scaffolds模板Markdown文件【可被-x参数覆盖】
  "OutputPath": "./source/_posts", //指定一个路径,作为Markdown和图片的导出目标,指定后会覆盖配置【可被-o参数覆盖】
  "SkipFileWhenException": true, //是否跳过处理异常的文件 true:跳过该文件,继续处理其它文件 false:抛出异常,终止处理
  "AssetsStore": {
    "AddWatermark": false, // 是否添加水印
    "CompressionImage": false, //是否压缩图片
    "SubPath": ".", //图片于输出子目录
    "Image": {
      "SkipNotSupportFormat": true, // 遇到不支持的图片类型是否跳过,否则就抛异常终止
      "WatermarkText": "InCerry", // 水印文字
      "WatermarkFontSize": 30, // 水印文字大小,如果图片小于文字大小,那么会缩放
      "WatermarkFont": "Microsoft Yahei", // 使用的字体类型,默认使用微软雅黑,Mac和Linux用户可自行配置系统安装的字体
      "WatermarkFontColor": "#FFF", // 字体颜色
      "CompressionLevel": "Low", // 压缩级别,级别越高大小越小,质量就越低,级别从低到高为:Low Medium High
      "ConvertFormatTo": "jpg" // 是否转换格式,支持一些常见的图片格式,如果不想转换,填null即可 如:"ConvertFormatTo": null
    }
  },
  "GetMarkdown": {
    "MetaWeblog": {
      "MetaWeblogURL": "https://rpc.cnblogs.com/metaweblog/jevonsflash", // MetaWeblog地址
      "Username": "jevonslin", //用户名 - 替换成你自己的用户名
      "Password": "9B5BAC9F20931E93EB3F39EF329001C0604ED59808E5656CDB1FA1ED85D7881C" //密码 - 替换成你自己的密码
    },
    "Local": {
      "Path": ".",  //获取Markdown文件的本地路径
      "Recursive": "false"  //是否递归获取
    },
    "ReadMorePosition": 5, //标签所在的行数,设置-1时将不添加此标签
    "RecentTakeCount": 1 //获取最近文件数
  },
  "MarkdownProvider": "MetaWeblog", //Markdown内容提供方式,值为MetaWeblog, Local【可被-m参数覆盖】
  "AssetsStoreProvider": "Local" //图片存储方式,值为Embed, Local, Hexo-Asset-Folder, Hexo-Tag-Plugin【可被-a参数覆盖】
}

命令行参数

参数列表:

参数 含义 用法
-x Hexo 指定一个Hexo的根目录,其中必须包含scaffolds模板Markdown文件, 指定后会覆盖配置
-o Output 指定一个路径,作为Markdown和图片的导出目标,指定后会覆盖配置
-r RecentTakeCount 获取最近Markdown文件数
-m MarkdownProvider 值为metaweblog, local, 指定后会覆盖配置
-a AssetsStoreProvider 值为embed, local, hexo-asset-folder, hexo-tag-plugin, 指定后会覆盖配置
-w WaitAtEnd 指定时,程序执行完成后,将等待用户输入退出
-h Help 查看帮助

示例

使用hexo-cli创建项目

hexo init blog

或从Github下载hexo项目

mkdir -p D:\Project 
cd D:\Project
git clone https://github.com/jevonsflash/blog.git blog

Sample1:图片保存在本地assets文件夹

blogtool.exe -r 5 -a local -x D:\Project\blog\ -o D:\Project\blog\source\_posts

alt text

Sample2:图片保存为标签插件

blogtool.exe -r 5 -a hexo-asset-folder -x D:\Project\blog\ -o D:\Project\blog\source\_posts

alt text

Markdown 中的图片修改为{% asset_path slug %}格式

alt text

Todo:

  • 本地Markdown导入
  • 七牛云存储
  • WPF界面

已知问题

作者信息

作者:林小

邮箱:jevonsflash@qq.com

License

The MIT License (MIT)

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.0 118 8/22/2024
0.2.1 101 5/11/2024
0.2.0 104 5/10/2024