npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generate-roam-site

v2.14.10

Published

Generate a static site from a Roam Graph.

Downloads

61

Readme

generate-roam-site

Generate a static site from a Roam Graph.

Requirements

You must have a version of google chrome installed.

Windows: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

Linux: /usr/bin/google-chrome-stable

Usage

import run from "generate-roam-site";

await run({
  roamGraph: "dvargas92495",
  roamUsername: "[email protected]",
  roamPassword: process.env.ROAM_PASSWORD,
}).then(() => console.log("Success!"));

Roam Configuration

Most other configuration happens from your Roam DB, on a page called roam/js/static-site. For legacy reasons, roam/js/public-garden is also supported as a valid configuration page name. The following configuration options are supported:

  • Index - The page name that will serve as the entry point of the site. Could be raw text or a page link.
  • Filter - A set of rules that specifies which pages to build. If a page matches any child rule, it will be built into the site. The following rules are supported:
    • Starts With - If a page starts with the given text, it will be included in the site. Useful for namespacing, e.g. Article/Article.
    • Tagged With - If a page contains a tag with the given text, it will be included in the site. Includes pages with any form of tags or attributes. Could be raw text or a page link.
  • Template - An HTML Code block that will be used as the template for every generated HTML file.
    • It supports a few variables that can be interpolated:
      • PAGE_NAME - The name of the page
      • PAGE_CONTENT - The content of the page
      • REFERENCES - An array of pages that reference the current page
    • The default template looks like
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>${PAGE_NAME}</title>
    <style>
      .rm-highlight {
        background-color: hsl(51, 98%, 81%);
        margin: -2px;
        padding: 2px;
      }
    </style>
  </head>
  <body>
    <div id="content">${PAGE_CONTENT}</div>
    <div id="references">
      <ul>
        ${REFERENCES}
      </ul>
    </div>
  </body>
</html>
  • Reference Template - An HTML Code block that will be used as the template for every page reference. The REFERENCES variable interpolates to all references each rendered as one instance of the template
    • It supports a few variables that can be interpolated:
      • REFERENCE - The name of the page referencing the current page
      • LINK - The url of the page html file
    • The default template looks like
<li><a href="${LINK}">${REFERENCE}</a></li>

Here's an example configuration, that uses the Personal Website page as the entry point and includes all pages that start with a P:

  • Index
    • Personal Website
  • Filter
    • Starts With
      • P

Here's an example configuration, that uses the Blog Post page as the entry point and includes all pages that are Tagged with Blog Post:

  • Index
    • Blog Post
  • Filter
    • Tagged With
      • Blog Post

Per Page Configuration

You could ignore specific blocks in pages that are included. Nest everything that you would like to keep on the page but have filtered out of the static site under a block that just says [[roam/js/static-site/ignore]].

You could override any roam page's default title with the roam/js/static-site/title:: attribute. The value set to the right of this attribute will be used in place of the PAGE_NAME variable during template interpolation.

You could add anything to a page's head with the roam/js/static-site/head:: attribute. The HTML code block defined as a child of this block will be injected into this page's head.

Note, that while you'll usually want to have these attributes nested within the ignore block, it's not a strict requirement.

Custom Components

There are many Roam UI elements that render using {{}}. This package includes its own custom UI components on top of the Roam native ones. (Note: not all Roam native components are supported yet.)

Daily Log

On any page, create a {{static site:daily log}} button. The button will be replaced with the blocks where the page is referenced in daily notes. This is an example output:

  • Daily Log:
    • March 29th, 2021
      • Just child blocks
    • March 26th, 2021 Inline
      • And a child block

If there's a block on a daily note page referencing the original page that you would like to be excluded, simply add a #[[roam/js/static-site/ignore]] tag to the block.

Optional Arguments

  • logger - an object specifying which loggers to use for info and error. Defaulted to console
  • pathRoot - an absolute file path denoting where output paths should be relative to. Defaulted to process.cwd().
  • inputConfig - A JSON to override any config options coming from Roam:
    • index - string
    • filter - {rule: string, values: string[]}[]
    • template - string
    • referenceTemplate - string