Skip to content

Commit

Permalink
add 'convert labels' feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lugenx committed May 9, 2023
1 parent 61c83e2 commit bc39a52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions convertFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@ const convertFile = (file) => {
return formatted;
};

const formatLabels = (labels) => {
const mappedLabel = labels?.map((label) => `#[[${label.name}]]`);
return mappedLabel?.join(" ");
};

const formattedTitle = formatTitle(file.title);
const formattedText = formatText(file.textContent);
const formattedList = formatList(file.listContent);
const formattedAttachments = formatAttachments(file.attachments);
const formattedLabels = formatLabels(file.labels);
const timestamp = `${hours}:${minutes}`;

const content = `\n- ${formattedTitle} (${timestamp}) \n\t- ${
formattedText || formattedList || ""
} \n\t- ${formattedAttachments}`;
const content = `\n- ${formattedTitle} (${timestamp}) ${
formattedLabels || ""
}\n\t- ${formattedText || formattedList || ""} \n\t- ${formattedAttachments}`;

return { mdFileName, content };
};
Expand Down
4 changes: 2 additions & 2 deletions copyAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const copyAssets = (sourceDir, destinationDir) => {
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(
`\x1b[1m\x1b[31m${completedTransfers}/${totalTransfers}\x1b[0m`
`\x1b[1m\x1b[31m${completedTransfers}/${totalTransfers} attachments transfered.\x1b[0m`
);
if (completedTransfers === totalTransfers) {
console.log(
"\n\x1b[92mAll attachments are moved from Takeout folder to Logseq Assets folder\x1b[0m\n"
"\n\x1b[92mTransfer completed. Attachments copied to Assets folder\x1b[0m\n"
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const runSecondQuestion = () => {
}
}
console.log(
`\n\x1b[92m All files processed. Total converted files: ${processedFilesCount}. \n Please look for newly created 'journals' folder in '${
`\n\x1b[92m All notes processed. Total converted notes: ${processedFilesCount}. \n Please look for newly created 'journals' folder in '${
destinationDirectory === "." ? __dirname : destinationDirectory
}' directory. \x1b[0m\n`
);
Expand Down

0 comments on commit bc39a52

Please sign in to comment.