Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
songkg7 committed Jun 29, 2024
1 parent 966b14e commit 26223a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/docusaurus/docusaurus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ export const convertToDocusaurus = async (plugin: O2Plugin) => {
const markdownFiles = await copyMarkdownFile(plugin);

for (const file of markdownFiles) {
let publishedDate = new Date().toISOString().split('T')[0];
await plugin.app.fileManager.processFrontMatter(
file,
fm => {
if (fm.published) {
publishedDate = fm.published;
return fm;
}
},
);

const contents: Contents = await plugin.app.vault.read(file);
const result =
convertComments(
Expand All @@ -50,10 +61,10 @@ export const convertToDocusaurus = async (plugin: O2Plugin) => {

// move files to docusaurus folder
await moveFiles(
file,
`${vaultAbsolutePath(plugin)}/${plugin.docusaurus.readyFolder}`,
plugin.docusaurus.targetPath(),
plugin.docusaurus.pathReplacer,
publishedDate,
)
.then(async () => await markPublished(plugin));
}
Expand Down
2 changes: 0 additions & 2 deletions src/jekyll/chirpy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const convertToChirpyV2 = async (plugin: O2Plugin) => {

// move files to chirpy folder
await moveFiles(
file,
`${vaultAbsolutePath(plugin)}/${settings.readyFolder}`,
settings.targetPath(),
settings.pathReplacer,
Expand Down Expand Up @@ -90,7 +89,6 @@ export async function convertToChirpy(plugin: O2Plugin) {

await plugin.app.vault.modify(file, result);
await moveFiles(
file,
`${vaultAbsolutePath(plugin)}/${settings.readyFolder}`,
settings.targetPath(),
settings.pathReplacer,
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ export const achieve = async (plugin: O2Plugin, settings: O2PluginSettings) => {
};

export const moveFiles = async (
file: TFile,
sourceFolderPath: string,
targetFolderPath: string,
pathReplacer: (year: string, month: string, day: string, title: string) => string,
publishedDate?: string,
) => {
// TODO: published front matter 를 가지고 있는 파일이라면 이미 발행된 적이 있는 파일이므로, targetFolderPath 를 published 로 변경해야 함
console.log(`targetFolderPath: ${targetFolderPath}`);
console.log(`publishedDate: ${publishedDate}`);

copy(
sourceFolderPath,
Expand Down

0 comments on commit 26223a9

Please sign in to comment.