JSPM

  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q33638F
  • License MIT

A tiny (dependency free!) library for building bookmark files.

Package Exports

  • bookmarked

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bookmarked) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

bookmarked 🔖

GitHub npm CI/CD

Coverage Lines of Code Vulnerabilities

A tiny (dependency free!) library for building bookmark files.

bookmarked supports ES Modules (ESM), CommonJS (CJS), and the Universal Module Definition (UMD) - so it'll be usable wherever you need it.

Install

$ npm i bookmarked

Usage

Single level deep bookmarks

import { bookmarked } from 'bookmarked';

const bookmarks = [
  {
    href: 'https://www.blackgirlscode.com/',
    name: 'Black Girls Code, BlackGirlsCode, Women of Color in Technology',
  },
  {
    href: 'https://www.freecodecamp.org/',
    name: 'Learn to Code — For Free — Coding Courses for Busy People',
  },
];

const html = bookmarked(bookmarks)
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
      It will be read and overwritten.
      DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL>
  <P>
    <DT>
      <A href="https://www.blackgirlscode.com/">Black Girls Code, BlackGirlsCode, Women of Color in Technology</A>
    </DT>
    <DT>
      <A href="https://www.freecodecamp.org/">Learn to Code — For Free — Coding Courses for Busy People</A>
    </DT>
  </P>
</DL>

Bookmarks inside folders

[
  {
    name: 'Learn to code',
    children: [
      {
        href: 'https://www.blackgirlscode.com/',
        name: 'Black Girls Code, BlackGirlsCode, Women of Color in Technology',
      },
      {
        href: 'https://www.freecodecamp.org/',
        name: 'Learn to Code — For Free — Coding Courses for Busy People',
      },
    ],
  },
];
...
<DL>
  <P>
    <DL>
      <P>
        <DT>
          <H3>Learn Programming</H3>
        </DT>
        <DT>
          <A href="https://www.blackgirlscode.com/">Black Girls Code, BlackGirlsCode, Women of Color in Technology</A>
        </DT>
        <DT>
          <A href="https://www.freecodecamp.org/">Learn to Code — For Free — Coding Courses for Busy People</A>
        </DT>
      </P>
    </DL>
  </P>
</DL>

Folders inside folders

[
  {
    name: 'Programming',
    children: [
      {
        name: 'Learn Programming',
        children: [
          {
            href: 'https://www.blackgirlscode.com/',
            name: 'Black Girls Code, BlackGirlsCode, Women of Color in Technology'
          },
          {
            href: 'https://www.freecodecamp.org/',
            name: 'Learn to Code — For Free — Coding Courses for Busy People'
          }
        ]
      },
      {
        name: 'JavaScript',
        children: [ { href: 'https://www.npmjs.com/', name: 'npm' } ]
      }
    ]
  }
]
...
<DL>
  <P>
    <DL>
      <P>
        <DT>
          <H3>Programming</H3>
        </DT>
        <DL>
          <P>
            <DT>
              <H3>Learn Programming</H3>
            </DT>
            <DT>
              <A href="https://www.blackgirlscode.com/">Black Girls Code, BlackGirlsCode, Women of Color in Technology</A>
            </DT>
            <DT>
              <A href="https://www.freecodecamp.org/">Learn to Code — For Free — Coding Courses for Busy People</A>
            </DT>
          </P>
        </DL>
        <DL>
          <P>
            <DT>
              <H3>JavaScript</H3>
            </DT>
            <DT>
              <A href="https://www.npmjs.com/">npm</A>
            </DT>
          </P>
        </DL>
      </P>
    </DL>
  </P>
</DL>

Check out the test file for more examples