Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

here's how to handle column support #52

Open
GorvGoyl opened this issue Oct 13, 2022 · 2 comments
Open

here's how to handle column support #52

GorvGoyl opened this issue Oct 13, 2022 · 2 comments

Comments

@GorvGoyl
Copy link

I needed to show 2 images in one row (2 columns), but it isn't directly possible. Currently, content in columns is rendered as individual rows. I figured out a way to show it in columns as how it is shown in Notion.

n2m.setCustomTransformer("column_list", async (block) => {
    const mdBlocks = await n2m.pageToMarkdown(block.id);
    const mdString = n2m.toMarkdownString(mdBlocks);
    return `
    <div style='display:"flex";column-gap:"10px"'>
   ${mdString}
    </div>
    `;
  });
n2m.setCustomTransformer("column", (block) => {
// avoid rendering it twice
    return "";
  });

I thought of sharing it in case others are looking for same.

@souvikinator
Copy link
Owner

Thanks for sharing, I marked it as information and won't close this issue for future reference.

@emilemoureau
Copy link

Improved version with responsive css and support of titles + paragraphs + images in each column (exactly like Notion)

n2m.setCustomTransformer("column_list", async (block) => {
  const mdBlocks_temp = await n2m.pageToMarkdown(block.id);
  let final_md_string = `<div className="column" style={{ display: "flex", columnGap: "25px" }}>`;

  for (const one_block of mdBlocks_temp) {
    const mdString_temp = n2m.toMarkdownString(one_block.children);
    final_md_string = final_md_string + `<div>${mdString_temp}</div>`
  }

  return final_md_string + "</div>"
});
.column div {
  display: flex;
  justify-content: center;
  flex-direction: column;
}

@media screen and (max-width: 630px) {
  .column {
    flex-direction: column;
  }
}

@souvikinator souvikinator moved this to Todo in notion-to-md Apr 14, 2023
@souvikinator souvikinator moved this from Todo to Misc in notion-to-md Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Misc
Development

No branches or pull requests

3 participants