feat: Hugo rebuild folder structure

- Update package.json to latest versions
- Add scripts/copy-assts.js script to build assets and static folders
  with required files.
This commit is contained in:
2025-09-03 21:06:24 +10:00
parent 887e490b15
commit ff21a2903e
200 changed files with 4463 additions and 4893 deletions

145
README.md
View File

@ -1,73 +1,108 @@
# Static Assets for Chirpy Jekyll Theme
# Chirpy Hugo Assets
## Introduction
This repository provides the JavaScript, CSS, and font assets needed for the Chirpy theme in Hugo.
Static assets (libraries/plugins/web-fonts) required by the [_Chirpy_][chirpy] based website to run. It provides the opportunity to choose self-host assets in production or development mode.
It can be used as a Hugo Module for theme development or local site builds.
## Usage
---
- If you want to use these assets only in local development:
## Installation (Remote)
Go to the root of your site and clone the assets as follows:
Add the following to your site's `config.toml` or `hugo.toml`:
```console
$ git submodule init
$ git submodule update
```
```toml
[module]
[[module.imports]]
path = "github.com/comprofix/chirpy-hugo-assets"
```
And then set your site configuration options:
Then run:
```yml
# _config.yml
assets:
self_host:
enabled: true
env: development
```
```bash
hugo mod get
```
- If you expect the assets to be self-hosted when your website is published:
This will fetch the latest committed assets from the remote repository.
Keep the `_config.yml` options as follows:
---
```yml
# _config.yml
assets:
self_host:
enabled: true
```
## Installation (Local / Development)
And then update the GitHub Actions workflow in `.github/workflows/pages-deploy.yml`:
For local development, you can use a local clone instead of the remote module. This is useful if you want to make changes to the assets and test them in your site.
```diff
steps:
- name: Checkout
uses: actions/checkout@v2
with:
+ submodules: true
```
Clone the repository somewhere on your system:
## Versions
```bash
git clone https://github.com/geekifan/chirpy-hugo-assets.git /path/to/local/chirpy-hugo-assets
```
| Dependency | Version |
| :------------------------------------------------------- | --------: |
| [Clipboard][clipboard] | `2.0.11` |
| [Day.js][dayjs] | `1.11.13` |
| [Font Awesome Free][fontawesome] | `6.7.1` |
| [GLightbox][glightbox] | `3.3.0` |
| [Loading-attribute-polyfill][loading-attribute-polyfill] | `2.1.1` |
| [Mermaid][mermaid] | `11.4.0` |
| [Simple-Jekyll-Search][simple-jekyll-search] | `1.10.0` |
| [Tocbot][tocbot] | `4.32.2` |
Then in your site's `go.mod` file, add a replace directive:
[chirpy]: https://github.com/cotes2020/jekyll-theme-chirpy
```go
replace github.com/geekifan/chirpy-hugo-assets => /path/to/local/chirpy-hugo-assets
```
<!-- deps -->
Now Hugo will use your local copy of the assets when building the site.
[clipboard]: https://www.jsdelivr.com/package/npm/clipboard
[dayjs]: https://www.jsdelivr.com/package/npm/dayjs
[fontawesome]: https://fontawesome.com/download
[loading-attribute-polyfill]: https://www.jsdelivr.com/package/npm/loading-attribute-polyfill
[glightbox]: https://www.jsdelivr.com/package/npm/glightbox
[mermaid]: https://www.jsdelivr.com/package/npm/mermaid
[simple-jekyll-search]: https://www.jsdelivr.com/package/npm/simple-jekyll-search
[tocbot]: https://www.jsdelivr.com/package/npm/tocbot
Run:
```bash
hugo mod tidy
hugo mod clean
hugo mod get
```
to refresh modules and ensure everything is linked correctly.
---
## Folder Structure
The assets are organized as follows:
```
assets/
js/ # JavaScript libraries
clipboard/
dayjs/
glightbox/
lazysizes/
mermaid/
tocbot/
fontawesome-free/ # Font Awesome CSS & webfonts
static/
fonts/ # Lato, Source Sans Pro fonts
```
---
## Updating Assets
All assets are managed via `npm`. To update packages or add new ones:
```bash
npm install
node scripts/copy-assets.js
```
This script copies the necessary files from `node_modules` to the Hugo assets folders.
### Supported Packages
| Dependency | Version |
| :-------------------------------------------------------------------------------------------- | --------: |
| [Clipboard](https://www.jsdelivr.com/package/npm/clipboard) | `2.0.11` |
| [Day.js](https://www.jsdelivr.com/package/npm/dayjs) | `1.11.18` |
| [Font Awesome Free](https://www.jsdelivr.com/package/npm/@fortawesome/fontawesome-free) | `7.0.0` |
| [GLightbox](https://www.jsdelivr.com/package/npm/glightbox) | `3.3.1` |
| [Lazysizes](https://www.jsdelivr.com/package/npm/lazysizes) | `5.3.2` |
| [Mermaid](https://www.jsdelivr.com/package/npm/mermaid) | `11.10.1` |
| [Tocbot](https://www.jsdelivr.com/package/npm/tocbot) | `4.36.4` |
| [Lato Font](https://www.jsdelivr.com/package/npm/lato-font) | `3.0.0` |
| [Source Sans Pro](https://www.jsdelivr.com/package/npm/source-sans-pro) | `3.6.0` |
---
## Acknowledgements
This project is based on [cotes2020/chirpy-static-assets](https://github.com/cotes2020/chirpy-static-assets). We acknowledge their original contributions and work.