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

[Question] Context seem not to be passed to plugins #96

Open
kmlbgn opened this issue Jan 6, 2024 · 0 comments
Open

[Question] Context seem not to be passed to plugins #96

kmlbgn opened this issue Jan 6, 2024 · 0 comments

Comments

@kmlbgn
Copy link

kmlbgn commented Jan 6, 2024

Currently, the standard notion-to-md library is utilized for parsing any sub-content within a block. For example, if there's a column-list containing blocks of content, these blocks will not be processed by docu-notion according to its configuration. I'm attempting to parse sub-content recursively using docu-notion's context and its custom function named doNotionToMarkdown. This function is supposed to carry the configuration and registered plugins, but for some reason, it's not functioning as expected. As if the context is not being properly passed.
I've also attempted re-registering the plugins within the column plugin's context itself, but this approach hasn't been successful either. Which got me confused.

Has anyone tried similar implementation? I'm trying to avoid re-writing an entire parsing logic within the Column Plugin itself.

async function notionColumnListToTabs(
  docunotionContext: IDocuNotionContext,
  getBlockChildren: (id: string) => Promise<NotionBlock[]>,
  block: NotionBlock
): Promise<string> {
  const { id, has_children } = block as any;

  if (!has_children) return "";

  const columnListChildren = await getBlockChildren(id);

  const tabItemsPromises = columnListChildren.map(async (column) => {
    const columnChildren = await getBlockChildren(column.id);

    let label = "Tab";
    if (columnChildren.length > 0 && columnChildren[0].type === 'heading_1') {
      const richTextItems = columnChildren[0].heading_1.rich_text;
      
      if (richTextItems.length > 0 && richTextItems[0].type === 'text') {
        label = richTextItems[0].text.content; // Directly accessing the content of the first text item
      }
    }

    // const markdownContent = await Promise.all(
    //   columnChildren.map(
    //     async child => await docunotionContext.notionToMarkdown.blockToMarkdown(child)
    //   )
    // );
    // const content = markdownContent.join("\n\n");
    const content = await doNotionToMarkdown(docunotionContext, columnChildren);

    return `<TabItem value="${label.toLowerCase()}" label="${label}">\n\n${content}\n\n</TabItem>`;
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant