Skip to content

Commit 2bb5b62

Browse files
Move assets outside of web directory, to respect license, and add preprocess script
1 parent e63375c commit 2bb5b62

13 files changed

+75
-3
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

web/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ pnpm-debug.log*
2222

2323
# tmLanguage file
2424
src/grammars/
25-
public/grammars/
25+
public/grammars/
26+
27+
# assets copied from outside web directory
28+
assets/

web/astro.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ export default defineConfig({
6161
{
6262
label: 'Reference',
6363
items: [
64+
{label: 'ID Lists', link: '/reference/ID_Lists'},
6465
{
6566
label: 'Resources',
6667
items: [
6768
{ label: 'Lua API', link: '/reference/Lua_API' },
6869
{ label: 'Meta.xml', link: '/reference/Meta.xml'},
70+
{ label: 'Resource Web Access', link: '/reference/Resource_Web_Access'},
6971
{
7072
label: 'Functions',
7173
collapsed: true,

web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"type": "module",
44
"version": "0.0.1",
55
"scripts": {
6-
"predev": "node mta_highlighting/generate-lua-tmlanguage.js",
6+
"predev": "node scripts/preprocess.js",
77
"dev": "astro dev",
88
"start": "astro dev",
9-
"prebuild": "node mta_highlighting/generate-lua-tmlanguage.js",
9+
"prebuild": "node scripts/preprocess.js",
1010
"build": "astro build",
1111
"preview": "astro preview",
1212
"astro": "astro"

web/scripts/preprocess.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
const srcDir = path.resolve(__dirname, '../../assets');
9+
const destDir = path.resolve(__dirname, '../src/assets');
10+
11+
function deleteDirRecursive(dirPath) {
12+
if (fs.existsSync(dirPath)) {
13+
for (const entry of fs.readdirSync(dirPath)) {
14+
const entryPath = path.join(dirPath, entry);
15+
const stats = fs.lstatSync(entryPath);
16+
17+
if (stats.isDirectory()) {
18+
deleteDirRecursive(entryPath);
19+
} else {
20+
fs.unlinkSync(entryPath);
21+
}
22+
}
23+
fs.rmdirSync(dirPath);
24+
}
25+
}
26+
27+
function copyDirRecursive(src, dest) {
28+
if (!fs.existsSync(dest)) {
29+
fs.mkdirSync(dest, { recursive: true });
30+
}
31+
32+
for (const entry of fs.readdirSync(src)) {
33+
const srcPath = path.join(src, entry);
34+
const destPath = path.join(dest, entry);
35+
const stats = fs.lstatSync(srcPath);
36+
37+
if (stats.isDirectory()) {
38+
copyDirRecursive(srcPath, destPath);
39+
} else {
40+
fs.copyFileSync(srcPath, destPath);
41+
}
42+
}
43+
}
44+
45+
import('../mta_highlighting/generate-lua-tmlanguage.js')
46+
.then(() => {
47+
deleteDirRecursive(destDir);
48+
copyDirRecursive(srcDir, destDir);
49+
console.log(`Copied assets from "${srcDir}" to "${destDir}".`);
50+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3+
import { getSeeAlsoLinksFromList } from '@src/utils/general';
4+
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
5+
6+
---
7+
<StarlightPage frontmatter={{
8+
template: 'doc',
9+
title: 'ID Lists',
10+
tableOfContents: false,
11+
}}>
12+
TODO
13+
14+
<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksFromList([
15+
'reference:Lua_API',
16+
])} currentId='' />
17+
</StarlightPage>

0 commit comments

Comments
 (0)