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

web-notion

v0.0.4

Published

Lightweight website server using Notion databases.

Downloads

2

Readme

Web-Notion

Web-Notion is a Node.js application that serves a website using Notion databases as the content management system (CMS), it can be hosted as an SSA as well as on a webserver.

Table of Contents

Get Started

Web-notion works by fetching the content of a Notion database and rendering it into a website. It does this by using the Notion API to fetch the content of the database and handlebars.js to render the content into a website.

To get started, follow these steps:

Installation

  1. Install web-notion CLI
npm i -g @rickaym/web-notion
  1. Clone the template repository web-notion-template, this is the repository that contains the handlebars layouts for rendering content, this is where you will be customizing the website (more on it here).
git clone https://github.com/Rickaym/web-notion-template.git

Setup Database

  1. Create a new database in Notion (does not need to be public) Ensure that the database these two columns:
  • Name - This is where the page itself is stored
  • Slug (optional) - This is where the slug of the page is stored, if a value is not present in this column, a slug will be made using the name of the page

E.g.

Notion Database

The content for each page should be stored inside the nested page of the Name column.

Setup Notion

  1. Create a Notion integration by following Step 1: Create an integration from the official docs, this is required to access the database
  2. Create a file named .env in the project root and copy the integration secret into it in the format of NOTION_API_KEY="{secret}"
  3. Then follow Step 2: Share a database with your integration and setup the database to be used with the integration
  4. Copy the ID of the database like this and set it to NOTION_DATABASE_ID in .env

The .env file should look like this when you are done:

NOTION_API_KEY="secret_..."
NOTION_DATABASE_ID="...-...-..-.."
  1. ✨ Run the project!
npx web-notion serve

Customizing the Website

Handlebars layouts are provided with HTML, Markdown and Text variants of content when rendering into HTML. This lets us take advantage of the Markdown format that notion provides by default.

There are two main layouts that are used to render the pages:

  1. web-notion-template/views/index.hbs - This layout is used to render the root page of the website
  2. web-notion-template/views/page.hbs - This layout is used for everything else; non-index and nested pages

You are provided with the following data in the layouts:

{
        "id": "e78f702d-bed1-413e-9623-a93aa9b7d05d",
        "createdTime": "2023-07-30T03:26:00.000Z",
        "lastEditedTime": "2023-08-04T15:32:00.000Z",
        "slug": "index",
        "title": "Web-Notion",
        "pageUrl": "https://www.notion.so/Web-Notion-e78f702dbed1413e9623a93aa9b7d05d",
        "icon": null,
        "cover": null,
        "content": {
            "markdown": "...",
            "text": "...",
            "html": "..."
        }
    }

To use these variables, you can use the following syntax in your layout:

{{variable}}

While both of the layouts have these variables (index.hbs with the data of the index page and page.hbs with the page being rendered) index.hbs gets a special variable called pages, a list of objects of all the pages (without the index page).

Examples

Refer to the web-notion-template repository as an example.

Hosting

Static Hosting

Hosting web-notion as a static site is the easiest way to host it, it is also the cheapest way to host it as it can be hosted on GitHub Pages for free. But as it only pulls data from Notion when the site is built, it is not suitable for websites that require real-time updates.

To generate the static site, run the following command:

npx web-notion build

Webserver Hosting

To host web-notion on a webserver, you will need to run the following command:

npx web-notion serve