Search code examples
markdownmediamarkupnikolalektor

Embed media content in lektor pages?


I am currently using Nikola as page generator.

But depending on the page scope and users, Lektor seems to be easier and more streamlined for the end-user. This fits well for a new page I plan.

Nikola also embedds media (youtube, vimeo, soundcloud, etc.) https://getnikola.com/handbook.html#restructuredtext-extensions

How is such functionality provided by Lektor?


Solution

  • The answer of @A. Jesse is right. Due to maintain simplicity in the core of Lektor, much like Flask, automatic embedding is not done by the "core".

    However, in the same spirit of Flask, Lektor is highly extensible. That also applies to its parsing of MarkDown formatted text in the post & rendering the final HTML.

    As he already said, you can directly paste the embeddable code in HTML in your otherwise MarkDown texts. And, it will be included as-is in the final HTML.

    But, personally I thought that hurts the core intention of MarkDown's simplicity & quick readability.

    easy-to-read, easy-to-write plain text format

    That why I felt necessity of lektor-embed-x where the writer will just write down the content's link in a seperate paragraph. This small piece of plugin will do the rest to the possible extent. It is basically a glue-library between embedX and Lektor.

    • If the content is of a relatively "popular" site, and the link is okay format, related necessary embed-code will be generated and included in the final HTML.
    • If not, the link will result in a regular link, i.e. an <a href=... link.

    The usage is very simple.

    step 1 Add the plugin by: $ cd path/to/lektor/project_folder $ lektor plugins add lektor-embed-x Package lektor-embed-x (0.1.2) was added to the project

    That's it. You are ready to go. [as of now, there is no addition configuration.]

    Now, on the post you can add the link on a paragraph of its own paragraph, without any special marker or start-flag, in your MarkDown formatted post as below.

    contents.lr

    title: About this Website
    ---
    body:
    
    This is a website that was made with the Lektor quickstart.
    
    And it does not contain a lot of information.
    
    
    # **HEADING 1**
    
    ## 2nd head
    
    _italic slated text_
    
    ~~mess~~
    
    whatever text i need to write.
    
    https://twitter.com/codinghorror/status/686254714938200064
    
    Below is how I can embed in a post.
    
    http://www.youtube.com/watch?v=_lOT2p_FCvA
    
    
    So, that was what i wanted to say.
    

    After generating final HTMLs through Lektor, the above post will generate something like:

    sample render

    NOTE

    Please note that this is a very nascent one-man project under active development and just out of pre-alpha phase. Hence, not many providers or link format is there. Yet. But, I hope it will be mature in a short time.