mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
Re-enable lastUpdated, add lastUpdated logic to API doc generator
This commit is contained in:
@@ -10,6 +10,7 @@ import apiRoutes from '../api/index.json';
|
||||
import m3u8Grammar from './m3u8-grammar.json' with { type: 'json' };
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
const DESCRIPTION = 'A JavaScript library for reading, writing, and converting media files. Directly in the browser,'
|
||||
+ ' and faster than anybunny else.';
|
||||
@@ -27,8 +28,14 @@ export default withMermaid({
|
||||
for (const entry of entries) {
|
||||
const isDirectory = await fs.stat(path.join('./examples', entry)).then(stat => stat.isDirectory());
|
||||
if (isDirectory) {
|
||||
const gitDate = execFileSync(
|
||||
'git',
|
||||
['log', '-1', '--format=%cI', '--', path.join('./examples', entry)],
|
||||
).toString().trim();
|
||||
|
||||
items.push({
|
||||
url: `/examples/${entry}/`, // With trailing slash
|
||||
lastmod: new Date(gitDate).toISOString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -36,7 +43,7 @@ export default withMermaid({
|
||||
return items;
|
||||
},
|
||||
},
|
||||
// lastUpdated: true,
|
||||
lastUpdated: true,
|
||||
head: [
|
||||
['link', { rel: 'icon', type: 'image/png', href: '/mediabunny-logo.png' }],
|
||||
['link', { rel: 'icon', type: 'image/svg+xml', href: '/mediabunny-logo.svg' }],
|
||||
@@ -201,7 +208,7 @@ export default withMermaid({
|
||||
tailwindcss() as any,
|
||||
llmstxt({
|
||||
ignoreFiles: [
|
||||
'api/*',
|
||||
'api/!(index).md',
|
||||
'examples.md',
|
||||
'llms.md',
|
||||
],
|
||||
@@ -305,5 +312,10 @@ export default withMermaid({
|
||||
for (const file of files) {
|
||||
await fs.copyFile('./docs/api/' + file, './dist-docs/api/' + file);
|
||||
}
|
||||
|
||||
// The llms.txt generation leaves behind runs of empty lines, collapse them into one
|
||||
const llmsTxtPath = './dist-docs/llms.txt';
|
||||
const llmsTxt = await fs.readFile(llmsTxtPath, 'utf-8');
|
||||
await fs.writeFile(llmsTxtPath, llmsTxt.replace(/\n{3,}/g, '\n\n'));
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user