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

@tanglemedia/directus-extension-whm-preview-hook

v1.0.25

Published

When a collection data is deleted, created, or updated, it will trigger the scripts that builds the site for preview.

Downloads

1,550

Readme

@tanglemedia/directus-extension-whm-preview-hook

When a collection data is deleted, created, or updated, it will trigger the scripts that builds the hugo site for preview.

Installation

npm i @tanglemedia/directus-extension-whm-preview-hook

How to enable the preview server

Prerequisite

  • A website account on WHM server.
  • Directus ^10.x.x
  • Node ^18.x.x
  • Git

Configuration

Set up SSH Keys to pull repo from Bitbucket

We need to create an ssh key for the server to pull a repo from bitbucket

  • On the WHM server, go to List Accounts
  • Search for the domain you want to add preview.
  • Go to that domain's CPanel
  • Using a terminal, cd .ssh to your domain/site account
  • ssh-keygen -t ed25519 -b 256
  • Enter name of the file for your ssh key. Recommended: <project_name>_bitbucket
  • Leave passphrase blank
  • Once ssh key file is generate, copy contents of the public key to the bitbucket repoitory of the hugo site (Repository Settings > Security > Access keys)

Add the following env variables

Setting up Preview Domain

  • On your site account CPanel, go to Domains
  • Click Create A New Domain
  • Enter the desired domain. By convention, it's usually preview.<CURRENT_DOMAIN_ADMIN_URL> example: preview.admin.example.org.
  • Enter the document root, which is the folder containing the files you want to deploy. It's usually /public_html/preview
  • Then submit

Add the preview domain to the site DNS

  • On your dns provider (in this case, Netlify), add a new A record to the domain
  • Enter the preview domain as the name
  • Enter the IP address of the site account on whm XXX.XXX.XX.XX

Add 404 page

  • In the .htaccess file, append the following:
ErrorDocument 404 {DIRECTUS_BASE_URL}/404/404.html?base_url={PREVIEW_SITE_BASE_URL}&url_req=%{REQUEST_URI}
  • In the public_html/ folder, create a folder called 404. Inside the folder, add the 404.html that will act as the 404 page that gets displayed when the preview pages are being build. The 404 page should also contain a javascript that redirects the user automatically to the preview page after is done building. Also add an image called preview-404.{ext}. It's usually the logo of the website. For example, refer to the other projects.

Folder Structure

By the end of the above steps, you should end up with the following folder structure. For it to work, make sure package-lock.json is not included in the hugo folder

account-root/
   hugo/
      .
      .
      .
      package.json
      .env-local
      node_modules/
         .bin/
            dotenv
            hugo
   preview/
      error.log
      hugo-git-initializer.sh
      preview.sh
   public_html/
      404/
         404.html
         preview-404.{ext}
         .
         .
      preview/
      .htaccess