Updated postbuild

This commit is contained in:
Relism
2025-02-27 23:38:14 +01:00
parent e9ddd43a46
commit d12f8571b7
4 changed files with 27 additions and 8 deletions
+1
View File
@@ -4,6 +4,7 @@ export default {
title: 'Pixel Services Docs', title: 'Pixel Services Docs',
description: 'Documentation for all public Pixel Services projects.', description: 'Documentation for all public Pixel Services projects.',
siteTitle: 'Documentation for all public Pixel Services projects.', siteTitle: 'Documentation for all public Pixel Services projects.',
ignoreDeadLinks: true,
head: [ head: [
['link', { rel: 'icon', href: 'https://static.pixel-services.com/static/assets/pservices_logo.png' }] ['link', { rel: 'icon', href: 'https://static.pixel-services.com/static/assets/pservices_logo.png' }]
+3 -1
View File
@@ -29,7 +29,9 @@ You can extend the `RequestHandler` class to create custom handlers that process
Because `RequestHandler` is an abstract class, you need to implement both the `handle()` method and the `super` constructor in your custom handler to define the logic that should be executed Because `RequestHandler` is an abstract class, you need to implement both the `handle()` method and the `super` constructor in your custom handler to define the logic that should be executed
when a request is received. when a request is received.
Since `RequestHandler` is an abstract class, you can leverage and chain HDI's to create cleaner and more maintainable route logic (more on that in the [Handler Default Implementations](/flash/advanced/handler-default-implementations) section). Since `RequestHandler` is an abstract class, you can leverage and chain HDI's to create cleaner and more maintainable route logic (more on that in the Handler Default Implementations guide).
```java[Example]
### 2. SimpleHandler ### 2. SimpleHandler
+1 -1
View File
@@ -13,7 +13,7 @@ corresponding file from the server. This is where a dynamic file server comes in
::: warning ::: warning
The dynamic file server relies heavily on the concept of dynamic handlers, which are handlers that will resolve for The dynamic file server relies heavily on the concept of dynamic handlers, which are handlers that will resolve for
any subpath of the endpoint they are registered to (see [Handler Types](/flash/core-concepts/handlers) for more info). any subpath of the endpoint they are registered to (see Handler Types for more info).
::: :::
## Usage ## Usage
+21 -5
View File
@@ -6,11 +6,27 @@ const makeCard = require('twitter-card-image');
const projects = ['flash', 'mobot', 'serverlibraries']; const projects = ['flash', 'mobot', 'serverlibraries'];
const baseDir = path.resolve(__dirname, './'); const baseDir = path.resolve(__dirname, './');
const outputImageDir = path.resolve(__dirname, '../.vitepress/dist/assets/banner-cards/'); const outputImageDir = path.resolve(__dirname, '../.vitepress/dist/assets/banner-cards/');
const excludedFolders = ['assets', 'config', 'vitepress'];
if (!fs.existsSync(outputImageDir)) { if (!fs.existsSync(outputImageDir)) {
fs.mkdirSync(outputImageDir, { recursive: true }); fs.mkdirSync(outputImageDir, { recursive: true });
} }
const getMarkdownFiles = (dir) => {
let results = [];
const list = fs.readdirSync(dir);
list.forEach((file) => {
const filePath = path.join(dir, file);
const stat = fs.statSync(filePath);
if (stat && stat.isDirectory() && !excludedFolders.includes(file)) {
results = results.concat(getMarkdownFiles(filePath));
} else if (file.endsWith('.md')) {
results.push(filePath);
}
});
return results;
};
const generateBannerCard = async (filePath, outputPath) => { const generateBannerCard = async (filePath, outputPath) => {
try { try {
const content = fs.readFileSync(filePath, 'utf-8'); const content = fs.readFileSync(filePath, 'utf-8');
@@ -73,7 +89,7 @@ const generateIndexImage = async () => {
const generateImagesForProjects = async () => { const generateImagesForProjects = async () => {
await generateIndexImage(); await generateIndexImage();
//handle all projects // Handle all projects
for (const project of projects) { for (const project of projects) {
const projectPath = path.join(baseDir, "../" + project); const projectPath = path.join(baseDir, "../" + project);
@@ -82,10 +98,10 @@ const generateImagesForProjects = async () => {
continue; continue;
} }
const files = fs.readdirSync(projectPath).filter((file) => file.endsWith('.md')); const files = getMarkdownFiles(projectPath);
for (const file of files) { for (const filePath of files) {
const filePath = path.join(projectPath, file); const relativePath = path.relative(projectPath, filePath);
const fileName = `${project}-${file.replace('.md', '')}.png`; const fileName = `${project}-${relativePath.replace(/[/\\]/g, '-')}.png`;
const outputImagePath = path.join(outputImageDir, fileName); const outputImagePath = path.join(outputImageDir, fileName);
console.log(`Generating: ${fileName}`); console.log(`Generating: ${fileName}`);
await generateBannerCard(filePath, outputImagePath); await generateBannerCard(filePath, outputImagePath);