Commit aa23d013 authored by Liang Ding's avatar Liang Ding

🎨 #12372

parent 7ab27dd9
......@@ -36,8 +36,8 @@ Solo 沉淀至今的**每一个功能你应该都会用到**。我们不会将
* 上传七牛云
* 友情链接管理
* 多用户写作,团队博客
* SQL 文件导出
* [Hexo/Jekyll 导入](https://hacpai.com/article/1498490209748)
* SQL / JSON / Markdown 导出
* 插件系统
* Atom / RSS 订阅
* Sitemap
......
......@@ -572,8 +572,8 @@ public class AdminConsole {
private void exportHexoMd(final List<JSONObject> articles, final String dirPath) {
articles.forEach(article -> {
final String filename = sanitizeFilename(article.optString("title"));
final String text = article.optString("front") + "\n----\n" + article.optString("content");
final String filename = sanitizeFilename(article.optString("title")) + ".md";
final String text = article.optString("front") + "---\n" + article.optString("content");
try {
final OutputStream output = new FileOutputStream(dirPath + File.separator + filename);
......
......@@ -30,6 +30,7 @@ import org.b3log.solo.model.*;
import org.b3log.solo.repository.*;
import org.json.JSONArray;
import org.json.JSONObject;
import org.yaml.snakeyaml.Yaml;
import java.util.*;
import java.util.stream.Collectors;
......@@ -159,7 +160,8 @@ public class ExportService {
final Map<String, Object> front = new LinkedHashMap<>();
final String title = article.optString(Article.ARTICLE_TITLE);
front.put("title", title);
front.put("date", DateFormatUtils.format((Date) article.opt(Article.ARTICLE_CREATE_DATE), "yyyy-MM-dd HH:mm:ss"));
final String date = DateFormatUtils.format((Date) article.opt(Article.ARTICLE_CREATE_DATE), "yyyy-MM-dd HH:mm:ss");
front.put("date", date);
front.put("updated", DateFormatUtils.format((Date) article.opt(Article.ARTICLE_UPDATE_DATE), "yyyy-MM-dd HH:mm:ss"));
final List<String> tags = Arrays.stream(article.optString(Article.ARTICLE_TAGS_REF).split(",")).filter(StringUtils::isNotBlank).map(String::trim).collect(Collectors.toList());
if (tags.isEmpty()) {
......@@ -168,7 +170,7 @@ public class ExportService {
front.put("tags", tags);
front.put("permalink", article.optString(Article.ARTICLE_PERMALINK));
final JSONObject one = new JSONObject();
one.put("front", front);
one.put("front", new Yaml().dump(front));
one.put("title", title);
one.put("content", article.optString(Article.ARTICLE_CONTENT));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment