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

@dorfjungs/hunamic

v0.1.8

Published

Make hugo dynamic

Downloads

26

Readme

@dorfjungs/hunamic

Build Status NPM version

Fetch and render content into hugo from an external service

Installation

npm install -g @dorfjungs/hunamic

Docker

Docker Version Docker Pulls Docker Size

Hunamic comes with a pre-built docker container. You should consider using this container, especially for production.

app:
  image: dorfjungs/hunamic:X.X.X

  # All volume mappings. Make sure to not just mount the src folder directly.
  # This could lead to unwanted files in your working directory
  volumes:
    # Example forlders for your assets. For more check out:
    # https://gohugo.io/hugo-pipes/introduction/#asset-directory
    - ./scripts:/src/assets/scripts
    - ./styles:/src/assets/styles

    # These are the hugo layouts. For more information see here:
    # https://cloudcannon.com/community/learn/hugo-tutorial/layouts-in-hugo/#what-s-a-layout
    - ./layouts:/src/layouts

    # Static files to serve directly (e.g. images). For more check out:
    # https://gohugo.io/content-management/static-files/
    - ./static:/src/static

    # This is a specific folder you can use to organize your configuration.
    # This is also included in the watcher, so changes will be detected
    - ./config:/src/config

    # The config file of your app
    - ./config.ts:/src/config.ts

    # tsconfig, node_modules, pacakge.json for bundling and compiling
    - ./tsconfig.json:/src/tsconfig.json
    - ./node_modules:/src/node_modules
    - ./package.json:/src/package.json
  environment:
    # Defines the environment used in your app. Default: production.
    # If set to dev, it'll start the hug server automatically
    ENVIRONMENT: 'dev'

    # This defines the secret to access. If this is empty the generation endpoint
    # will be public. So it's highly recommended to set it.
    SERVER_SECRET: xx-random-xx-openssl-xx-string-xx

    # The path for the reverse proxy, which points to the generation server
    # Default value: 11B368FF15C711A1A45DCFF68E74D190
    GENERATION_PATH: 11B368FF15C711A1A45DCFF68E74D190

    # Arguments attached to the hugo build command
    # For more see here: https://gohugo.io/commands/hugo/#options
    BUILD_ARGS: "gc,logFile=/tmp/hugo.log"

    # Arguments attached to the hugo server command
    # For more see here: https://gohugo.io/commands/hugo_server/#options
    DEV_SERVER_ARGS: "disableFastRender,gc"

    # The base url to serve images etc. from
    APP_BASE_URL: http://app.hunamic.localhost/

    # The endpoint to the api, used in `query` command
    API_ENDPOINT: http://api.hunamic.localhost/

    # The seconds to wait before aborting the waiting for the api endpoint
    # Default: 180
    API_WAIT_TIMEOUT: 360

General structure

Structure

Services and exposed ports

This pacakge runs nginx in the background and hunamic in the foreground. This means we basically have two (three in development) servers running in one container. To reduce the number of exposed ports hunamic serves the generation service (the one you call when you want to rebuild) through an nginx proxy, defined by the environment variable $GENERATION_PATH.

Now you have two ways to attach to the exposed ports. If you're in production you want to connect to port 8080, which is used by nginx. If you're in development you want to use the port 7652, which attaches to the hugo server command.

Since hugo server is not available when ENVIRONMENT != "dev", this service will be unavailable in production environments

Connect the generation service via a webhook

If you want to connect the generation service to a webhook (e.g. a headless CMS), you simply use the following format:

{PROTOCOL}://{HOST:3000}/{GENERATION_PATH}/generate?secret={SECRET}

# Example
https://dorfjungs.com/11B368FF15C711A1A45DCFF68E74D190/generate?secrect=84jf

Now everytime the webhook gets executed a rebuild will happen. Easy.

You have to access this resource via a POST request

Commands

hunamic generate

Generates hugo front matter via a config

USAGE
  $ hunamic generate

OPTIONS
  -b, --buildArg=buildArg  Arg for the hugo build command --buildArg=gc
  -c, --config=config      [default: ./config.ts] Path to the config file
  -h, --help               show CLI help
  --builDelay=builDelay    [default: 10] The delay before starting the build
  --skipBuild              Whether to skip the build and only do the generation

EXAMPLE
  $ humanic generate --config=./config.ts

hunamic help [COMMAND]

display help for hunamic

USAGE
  $ hunamic help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

hunamic server

Starts an api service to access the generator

USAGE
  $ hunamic server

OPTIONS
  -b, --buildArg=buildArg      Arg for the hugo build command --buildArg=gc
  -c, --config=config          [default: ./config.ts] Path to the config file
  -d, --devServer              Whether to start the hugo dev server. Default = no
  -h, --help                   show CLI help
  -h, --host=host              [default: 0.0.0.0] The server hostname
  -p, --port=port              [default: 3000] The port for the server
  -s, --secret=secret          Secret parameter to add to your URL (http://...?secret=XX)
  -w, --watch=watch            Comma separated list of files and dirs to watch
  --builDelay=builDelay        [default: 10] The delay before starting the build
  --devServerArg=devServerArg  Arg for the hugo server command --devServerArg=gc
  --devServerVerbose           Output everything from the dev server, #no-filter
  --genDelay=genDelay          [default: 0] The delay before starting the generation
  --skipBuild                  Whether to skip the build and only do the generation

EXAMPLES
  $ humanic server --secret=test123 --config=./config.ts
  $ humanic server --skipBuild --secret=test123 --config=./config.ts

Development

To release a new version simply run yarn version --(major|minor|patch) to update the package.json and then just git push origin master. Our CI/CD will handle the rest. It will also deploy the corresponding docker image.