Reorganise package.json scripts

This commit is contained in:
Leilukin 2025-05-09 12:10:21 +08:00
parent ac61dcbcb7
commit 96906179be
4 changed files with 9 additions and 12 deletions

View File

@ -22,7 +22,7 @@ jobs:
run: bun install run: bun install
- name: Build - name: Build
run: bun run build-pagefind run: bun run build
- name: SSH Deploy to Hostinger - name: SSH Deploy to Hostinger
uses: easingthemes/ssh-deploy@main uses: easingthemes/ssh-deploy@main

View File

@ -18,10 +18,6 @@ It is recommended to use [Bun](https://bun.sh) as the JavaScript runtime for thi
``` ```
1. Run the project: 1. Run the project:
``` ```
bun start-pagefind bun start
``` ```
1. Open http://localhost:1414/ in your web browser. 1. Open http://localhost:1414/ in your web browser.
The `bun start-pagefind` command runs both Eleventy to build the website and [Pagefind](https://pagefind.app/) to create the website's search index, then serves the website project output in a live server.
After the website's search index has been created and updated, when you want to run the project again, you can run the `bun start` command, then open `http://localhost:8080` in your web browser to view the website project output in a live server.

View File

@ -7,10 +7,11 @@
"url": "https://git.32bit.cafe/Leilukin/leilukin-site" "url": "https://git.32bit.cafe/Leilukin/leilukin-site"
}, },
"scripts": { "scripts": {
"start": "bunx @11ty/eleventy --serve --quiet", "build-11ty": "bunx @11ty/eleventy",
"build": "bunx @11ty/eleventy", "start-11ty": "bunx @11ty/eleventy --serve --quiet",
"start-pagefind": "bunx @11ty/eleventy --quiet && bunx -y pagefind --site _site --serve", "create-search-index": "bunx -y pagefind --site _site",
"build-pagefind": "bunx @11ty/eleventy --quiet && bunx -y pagefind --site _site" "build": "bun build-11ty --quiet && bun create-search-index",
"start": "bun run build --serve"
}, },
"type": "module", "type": "module",
"devDependencies": { "devDependencies": {

View File

@ -3,10 +3,10 @@ title: Search
eleventyComputed: eleventyComputed:
desc: Search {{ sitemeta.siteName }}. desc: Search {{ sitemeta.siteName }}.
--- ---
<p>Looking for something on my website? If you have JavaScript enabled, you can use the search field below, which is powered by the static search library <a href="https://pagefind.app/">Pagefind</a>. Your search query will not be recorded anywhere.</p>
<link href="/pagefind/pagefind-ui.css" rel="stylesheet"> <link href="/pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/pagefind/pagefind-ui.js"></script> <script src="/pagefind/pagefind-ui.js"></script>
<p>Looking for something on my website? If you have JavaScript enabled, you can use the search field below, which is powered by the static search library <a href="https://pagefind.app/">Pagefind</a>. Your search query will not be recorded anywhere.</p>
<div id="search"></div> <div id="search"></div>
<script> <script>
window.addEventListener('DOMContentLoaded', (event) => { window.addEventListener('DOMContentLoaded', (event) => {