Skip to content

girobusan/one-line-md-viewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title
README: How to publish Markdown...

😎
How to publish markdown document with one line of code

This idea is borrowed from blogtini project.

  1. Locate your markdown document
  2. Download view.js file from dist folder of this repo and put it in the same folder.
  3. Edit your markdown file, add line <script src="view.js"></script> anywhere in the file (even in frontmatter, if it's present).
  4. Change extension of markdown file to html
  5. Open it in browser. It looks like nicely formatted HTML.

How does it work

  1. Browser loads your markdown-in-html, and interprets it as HTML.
  2. As your file does not have basic HTML structures, browser adds HEAD and BODY tags, and puts all content to BODY.
  3. Browser loads the script.
  4. The script reads the document body content (which is markdown), renders it to HTML, and replaces body content with the rendered one, also adding some style and page title.
  5. Script also recognizes frontmatter, for now only title property.

Can we make an Extremely Minimal CMS from this?

Like My Markdown Site, but even more minimal.

What is missing

  • Navigation
    • File lists (categories)
    • Tags

What to try

  • After first load, script may capture clicks on links and perform nice navigation between further pages.
  • Script may load some kind of menu.
  • Script may have optional access to file list and generate lists (category index, pages by tag) - but how we'd process theirs urls?
  • We can keep some site-wide metadata in special markdown files for accessibility (for clients without JS).(?)

About

One line + one script = markdown viewer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages