mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-20 15:14:01 +09:00
Make tags and categories arrays
This commit is contained in:
+4
-2
@@ -94,10 +94,12 @@ function getTags(post) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processCategoryTags(post, domain) {
|
function processCategoryTags(post, domain) {
|
||||||
|
if (!post.category) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return post.category
|
return post.category
|
||||||
.filter(c => c["$"].domain === domain)
|
.filter(c => c["$"].domain === domain)
|
||||||
.map(({ $: c }) => c.nicename)
|
.map(({ $: c }) => c.nicename);
|
||||||
.join(", ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectAttachedImages(data) {
|
function collectAttachedImages(data) {
|
||||||
|
|||||||
+4
-2
@@ -58,8 +58,10 @@ async function loadMarkdownFilePromise(post) {
|
|||||||
let output = '---\n';
|
let output = '---\n';
|
||||||
Object.entries(post.frontmatter).forEach(pair => {
|
Object.entries(post.frontmatter).forEach(pair => {
|
||||||
const key = pair[0];
|
const key = pair[0];
|
||||||
const value = (pair[1] || '').replace(/"/g, '\\"');
|
const value = Array.isArray(pair[1])
|
||||||
output += key + ': "' + value + '"\n';
|
? (pair[1].length === 0 ? "" : "\n - \"" + pair[1].join("\"\n - \"") + "\"")
|
||||||
|
: '"' + (pair[1] || '').replace(/"/g, '\\"') +'"';
|
||||||
|
output += key + ': ' + value + '\n';
|
||||||
});
|
});
|
||||||
output += '---\n\n' + post.content + '\n';
|
output += '---\n\n' + post.content + '\n';
|
||||||
return output;
|
return output;
|
||||||
|
|||||||
Reference in New Issue
Block a user