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

@hyperupcall/ten

v0.4.0

Published

Ten will be / is a static site generator / content management system / web framework solution. I created it because:

Downloads

95

Readme

Ten

Ten will be / is a static site generator / content management system / web framework solution. I created it because:

  • I want my website code to last for decades
    • Frameworks like Hugo, Zola, etc. will eventually go the way of Jekyll
    • Migrating working code is a waste of time
  • It's easier to implement bespoke features

Plans

  • on watch mode:
    • it's VERY useful for debugging output
    • it felt slow and bad because i was using it with browser-sync to serve the generated contents
    • it should now be "re-added" (without browser-sync), and everything will make sense
  • Blog RSS feed and fix tags/categories in dev server
  • Be able to build only certain files/directory matching a glob
  • later: Linter to always ensure trailing slash for local URLs

Introduction

Summary

Ten is a static site generator. Conventionally, it recursively reads input files from content/. Then, it processes each file path and content. Finally, it writes the result path and content to build/.

Content Files

Content files are any files located in the content directory that aren't special.

Transformations are done to file paths in two cases:

  1. If a file ends with .md (or similar) files, it is converted into a .html file.
  • /mathematics.md -> /mathematics.html
  • /index.md -> /index.html
  1. If a file name (excluding file extensions) is the same as the directory name of it's parent directory, then that file is renamed to index.html.
  • /about/about.md -> /about/index.html

This makes it easier to edit files in IDEs (unlike Next.js's page.js).

Supported Formats

The following formats are supported:

HTML, XML

These are processed with the templating engine Handlebars.

Templates have access to the following variables:

  • Page (layouts & partials, pages)
  • Title (layouts & partials, pages)
  • Body (layouts & partials)

Markdown

Markdown files support the following features:

  • Syntax highlighting (via Shiki)
  • Emoji conversion
  • KaTeX

Special File Names

Special file modify behavior and are not processed. They include:

  • *.ten.js

Described further in JavaScript Customization

  • _*

These are ignored.

  • *_

These are ignored.

Website JavaScript Customization

This file potentially customizes the behavior of the whole website. To be recognized, its name must be /ten.config.js.

It can export:

  • defaults
  • transformUri()
  • decideLayout()
  • validateFrontmatter()
  • handlebearsHelpers
  • tenHelpers

Page JavaScript Customization

This file potentially customizes the behavior of a single page. To be recognized, its name must match /**/<adjacentFileName>.ten.js.

It can export:

  • Meta()
  • Head()
  • GenerateSlugMapping()
  • GenerateTemplateVariables()

Directory Structure

Nothing here is out of the ordinary.

build/

Where output files are written to.

content/

User-generated content. There are several variants:

layouts/

Handlebars templates that are applied to all pages and posts. Individual pages and posts can specify a particular template in the frontmatter using the layout property.

partials/

Handlebars partials that can be used in any HTML file.

static/

These assets are copied directly to the build directory without processing.

Older Ideas

Entrypoints. Entrypoints were created to make it easier to approximate tracking dependencies of a page. For example, if /math/theme.cls changed, then probably /math/slides.tex should be regenerated as well. This breaks down too often, as it's not uncommon for files under a particular directory to be unrelated. An alternative to entrypoints was tracking dependencies of a page by parsing the page with either regular expressions or a laguage parser library. This wasn't chosen since it would mean adding regular expressions or traverse functions for each markup language. And, detection would not be posssible with more dynamic markup languages.