Giter Site home page Giter Site logo

Comments (6)

that-ambuj avatar that-ambuj commented on June 15, 2024 1

Have you tried using the n2m.setCustomTransformer("video", cb-function) method to handle videos as the way you want? You can checkout the example for custom transformers to achieve the required results.

from notion-to-md.

souvikinator avatar souvikinator commented on June 15, 2024 1

Like @that-ambuj mentioned you can use the setCustomTransformer method to render the element the way you want. Here is a simple example:

n2m.setCustomTransformer("video", async (block) => {
  const { video } = block as any;
  const { type } = video;
  const video_url = video[type].url;
  return `
    <video src="${video_url}" controls>
      Your browser does not support the video tag.
    </video>
  `;
});

do you know if there are any repositories that are open-source and already use notion-to-md so I can check how it works and get some inspiration?

As far as your question is concerned I would suggest checking out the used by section on the right sidebar of the repo or here is the link

from notion-to-md.

hecker avatar hecker commented on June 15, 2024

Thanks your the help! Now this is what I get... I am pretty new to web dev so I am not sure how to program it that it recognizes

Screenshot 2023-05-21 at 17 08 22

from notion-to-md.

souvikinator avatar souvikinator commented on June 15, 2024

So it's a minor fix. In the code sample, I have provided, there is leading space in the string due to which it is rendered as a code block. Here is how you can fix it:

n2m.setCustomTransformer("video", async (block) => {
  const { video } = block as any;
  const { type } = video;
  const video_url = video[type].url;
  return `<video src="${video_url}" controls> Your browser does not support the video tag. </video>`;
});

or

n2m.setCustomTransformer("video", async (block) => {
  const { video } = block as any;
  const { type } = video;
  const video_url = video[type].url;
  return (`
      <video src="${video_url}" controls>
         your browser does not support the video tag.
     </video>
  `).trim();
});

from notion-to-md.

hecker avatar hecker commented on June 15, 2024

Thanks! But it is still displayed as text (not code, but normal text). Maybe it's about how I implemented it?

Screenshot 2023-05-21 at 17 29 30

My implementation:

<section>
      <h1 className="font-bold text-3xl font-serif mb-5">
        {blogPost.metadata.title}
      </h1>
      <article className="prose dark:prose-invert prose-code">
        {blogPost.metadata.updated && (
          <Callout
            text={"Last updated in " + blogPost.metadata.updated + "."}
            emoji="🗓️"
          />
        )}
        <ReactMarkdown>{blogPost.content}</ReactMarkdown>
      </article>
    </section>

from notion-to-md.

souvikinator avatar souvikinator commented on June 15, 2024

I believe react-markdown doesn't render HTML by default you need to use another package as a plugin.

Refer to this: https://stackoverflow.com/a/70548866

from notion-to-md.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.