Skip to content

Commit

Permalink
fix: Resolve build issues due to broken projects index
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Jan 26, 2024
1 parent 0670aed commit 2042f59
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export default defineUserConfig({
},

async onPrepared(app) {
await buildPageCache(app, "posts", "posts/")
await buildPageCache(app, "posts", "posts/", { reverse: true })
await buildPageCache(app, "projects", "projects/")
await buildPageCache(app, "licenses", "licenses/")
},

Expand Down
26 changes: 22 additions & 4 deletions src/.vuepress/utils/pageCache.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import { App } from "vuepress";

export async function buildPageCache(app: App, name: string, prefix: string): Promise<void> {
interface BuildPageCacheOptions {
reverse?: boolean
includeReadme?: boolean
requireExcerpt?: boolean
}

const defaultBuildPageCacheOptions: BuildPageCacheOptions = {
reverse: false,
includeReadme: false,
requireExcerpt: true
}

export async function buildPageCache(app: App, name: string, prefix: string, options: BuildPageCacheOptions = {}): Promise<void> {
options = {
...defaultBuildPageCacheOptions,
...options
}

const pages = app.pages
.filter(page => page.filePathRelative?.startsWith(prefix) && page.filePathRelative !== `${prefix}/README.md`)
.filter(page => page.filePathRelative?.startsWith(prefix))
.filter(page => options.includeReadme || page.filePathRelative !== `${prefix}/README.md`)
.map(page => ({
...page,
excerpt: page.contentRendered.includes("<!-- more -->") ? page.contentRendered.split("<!-- more -->")[0] : null
}))
.filter(page => !!page.excerpt)
.filter(page => !options.requireExcerpt || !!page.excerpt)

pages.sort((a, b) => b.filePathRelative! > a.filePathRelative! ? 1 : -1)
pages.sort((a, b) => (b.filePathRelative! > a.filePathRelative! ? -1 : 1) * (options.reverse ? -1 : 1))

await app.writeTemp(`${name}.js`, `export const ${name} = ${JSON.stringify(pages)}`)
}
10 changes: 6 additions & 4 deletions src/projects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ comments: false
editLink: false
---

<Index prefix="projects" />
<PostList :posts="projects" />

<script>
import Index from "../../../components/Index.vue"
import {projects} from "@temp/projects"

export default {
components: {
Index
setup() {
return {
projects
}
}
}
</script>
4 changes: 2 additions & 2 deletions src/projects/arma2ml.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ ArmA 2 Mod Launcher is a command-line based application which enables you to qui
ArmA 2 with a custom selection of mods. Its lightweight nature and easy to use command
line syntax makes creating shortcuts for your favourite mod configurations dead easy.

<!-- more -->

* **Load Your Favourite Mods And Join Your Favourite Server From A Single Shortcut**

ArmA 2 Mod Launcher allows you to easily construct shortcuts which launch ArmA 2 with
Expand All @@ -39,8 +41,6 @@ line syntax makes creating shortcuts for your favourite mod configurations dead
[View on GitHub](https://github.com/SierraSoftworks/arma2ml)
:::

<!-- more -->

## Usage

```bash
Expand Down
2 changes: 2 additions & 0 deletions src/projects/bash-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and tools for a project. Rather than port the scripts to something like Go or Py
or merge them into a single bash script, we opted to build a framework which allows
and executable to be presented as a sub-command.

<!-- more -->

## Example

```sh
Expand Down
2 changes: 2 additions & 0 deletions src/projects/bender.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Bender is a small API which allows you to run a BaaS stack (Bender as a Service)
for those times you really wish you could tell a web app to bite your shiny metal
ass.

<!-- more -->

::: tip
You can go directly to [Bender](https://bender.sierrasoftworks.com/api/v1/quote)
and get your dose of Futurama if you're more interested in that than the API docs.
Expand Down
4 changes: 2 additions & 2 deletions src/projects/coremonitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ download: https://cdn.sierrasoftworks.com/coremonitor/CoreMonitorSetup.exe
# CoreMonitor
Easily monitor your system's resource usage using our powerful replacement for the default Logitech G15/G19 resource monitor widget.

<!-- more -->

::: tip
[Download CoreMonitor](https://cdn.sierrasoftworks.com/coremonitor/CoreMonitorSetup.exe)

[View on GitHub](https://github.com/SierraSoftworks/coremonitor)
:::

<!-- more -->

## Features
### Graphed CPU Usage

Expand Down
4 changes: 2 additions & 2 deletions src/projects/git-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ its biggest advantages is that you no longer need to think about where your
development directory is on different devices. Just `gt o my-repo` and you're
ready to start developing, even if the code wasn't already cloned.

<!-- more -->

## Features

- **Quickly open repositories** whether they are already cloned locally or not, using your favourite Git services and a concise folder structure.
Expand All @@ -29,8 +31,6 @@ ready to start developing, even if the code wasn't already cloned.
- **Aliases** to make opening your most common repositories as quick as possible.
- **Fast autocompletion** on all platforms with support for "sequence search" (`ssgt` matches `SierraSoftworks/git-tool`) as found in Sublime and VSCode.

<!-- more -->

## Example

```powershell
Expand Down
7 changes: 3 additions & 4 deletions src/projects/wkd.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ download: https://cdn.sierrasoftworks.com/wkd/WKDSetup.exe
---

# Web Comic Downloader
WKD is a web comic downloader which allows you to easily download a large number of comics automatically. It makes use of XPath queries to locate images, similarly to the way your web browser does. This allows it to download images which are not named sequentially (1, 2, 3...) without any problems.

WKD is a web comic downloader which allows you to easily download a large number of comics automatically. It makes use of XPath queries to locate images, similarly to the way your web browser does. This allows it to download images which are not named sequentially (1, 2, 3...) without any problems.

<!-- more -->

::: tip
[Download WKD](https://cdn.sierrasoftworks.com/wkd/WKDSetup.exe)

[View on GitHub](https://github.com/SierraSoftworks/web-comic-downloader)
:::

<!-- more -->

## Why make WKD?
I am one of many people who routinely reads web comics, alas I get to the stage where I am not willing to click through each of the 700 strips in a comic. It is just so much easier to browse it on your hard drive, where it loads immediately and can be traversed quickly using thumbnails.
Previously there was an application which performed a similar purpose, called Woofy. It's development ceased a few years ago and it was never able to run on a 64-bit OS. This was a major drawback for me since I only use 64-bit OSes.
Expand Down

0 comments on commit 2042f59

Please sign in to comment.