Skip to content

Commit f2af6ea

Browse files
authored
Merge pull request #1 from MicroWebStacks/sql_render
Sql render fully functional and tested rendering of SQLite content from db using Astro components
2 parents 047abe2 + 3ab801c commit f2af6ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+5341
-26
lines changed

astro.config.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig } from 'astro/config';
2+
import node from '@astrojs/node';
3+
import {config} from './config.js'
4+
import yaml from '@rollup/plugin-yaml';
5+
6+
export default defineConfig({
7+
adapter: node({
8+
mode: 'middleware',
9+
}),
10+
output: "server",
11+
outDir: config.outDir,
12+
trailingSlash: 'ignore',
13+
vite: {
14+
plugins: [yaml()],
15+
ssr: {
16+
external: ['better-sqlite3']
17+
},
18+
optimizeDeps: {
19+
exclude: ['better-sqlite3']
20+
}
21+
}
22+
});

config.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import * as dotenv from 'dotenv'
22
import {join} from 'path'
3-
import { fileURLToPath } from "node:url";
43
import path from "node:path";
54
import fsp from "node:fs/promises";
65
import yaml from "js-yaml";
76

8-
const __filename = fileURLToPath(import.meta.url);
9-
const __dirname = path.dirname(__filename);
10-
const ROOT_DIR = path.resolve(__dirname);
11-
127
async function loadManifest() {
13-
const manifestPath = path.join(ROOT_DIR, "manifest.yaml");
8+
const manifestPath = path.join(process.cwd(), "manifest.yaml");
149
const raw = await fsp.readFile(manifestPath, "utf8");
1510
return yaml.load(raw);
1611
}
@@ -34,12 +29,8 @@ const config = {
3429
code_path: `${rootdir}/${outdir}/codes`,
3530
kroki_server: kroki_server,
3631
client_menu:true,
37-
highlighter:{
38-
theme:"dark-plus",
39-
langs:['javascript','js','python','yaml']
40-
},
32+
highlighter:manifest.render.highlighter,
4133
copy_assets:false,
42-
copy_assets_dir: "_astro",
4334
assets_hash_dir:true, //N.A. if(copy_assets == false)
4435
fetch: manifest.fetch
4536
}

manifest.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ fetch:
66
dest: content
77
collect:
88
folder_single_doc: false
9-
file_link_ext: ["svg","webp","png","jpeg","jpg","xlsx","glb"]
9+
file_link_ext: ["svg","webp","png","jpeg","jpg","xlsx","glb","puml"]
1010
file_compress_ext: ['txt','md','json','csv','tsv','yaml','yml']
1111
external_storage_kb: 512
1212
inline_compression_kb: 32
13+
render:
14+
highlighter:
15+
theme: dark-plus
16+
langs: ['javascript','js','python','yaml']

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111
"astro": "astro",
1212
"fetch": "node scripts/fetch.js",
1313
"server": "node server/server.js",
14-
"collect": "node scripts/collect.js"
14+
"collect": "node scripts/collect.js",
15+
"diagrams": "node scripts/diagrams.js"
1516
},
1617
"dependencies": {
18+
"@astrojs/node": "^9.5.1",
1719
"@google/model-viewer": "^4.1.0",
1820
"@octokit/rest": "^21.0.2",
1921
"@svgdotjs/svg.js": "^3.2.4",
2022
"adm-zip": "^0.5.16",
21-
"astro": "^5.0.3",
22-
"content-structure": "2.0.1",
23+
"better-sqlite3": "^12.4.1",
24+
"astro": "^5.16.0",
25+
"content-structure": "^2.1.0",
2326
"cookie-parser": "^1.4.7",
2427
"cors": "^2.8.5",
2528
"datatables.net-dt": "^1.13.7",
@@ -39,7 +42,6 @@
3942
"remark": "^15.0.1",
4043
"sharp": "^0.33.5",
4144
"shiki": "^3.15.0",
42-
"swiper": "^11.1.15",
4345
"three": "^0.172.0",
4446
"unist-util-visit": "^5.0.0",
4547
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"

pnpm-lock.yaml

Lines changed: 94 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/favicon.ico

116 KB
Binary file not shown.

readme.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,24 @@ True content based ISR (Incremental Static Regenration) with cache warmup.
4343
- `folders` pulls those subfolders and flattens their contents into `dest`; omit `folders` to copy the whole repo. `dest` defaults to the repo name and is cleared before copying.
4444
- Set `GITHUB_TOKEN` to avoid GitHub rate limits.
4545
- Run `pnpm fetch` (or `node scripts/fetch.js`) after installing dependencies.
46+
47+
## collection
48+
- All configs are optional and have defaults
49+
- Configure `collect` in `manifest.yaml`. Example:
50+
```yaml
51+
collect:
52+
folder_single_doc: false
53+
file_link_ext: ["svg","webp","png","jpeg","jpg","xlsx","glb"]
54+
file_compress_ext: ['txt','md','json','csv','tsv','yaml','yml']
55+
external_storage_kb: 512
56+
inline_compression_kb: 32
57+
```
58+
- `folder_single_doc` default is false for one document per file, when true, generates one document per folder merging its markdown files.
59+
- `file_link_ext` : only these extensions will be considered as assets to manage
60+
- `file_compress_ext` : files subject to compressions in blobs storage
61+
- `external_storage_kb` : threshold to manage blobs in folders and not in db
62+
- `inline_compression_kb` : threshold above which db blobs get compressed
63+
- Run `pnpm collect` to parse the `.content` directory Markdown and referenced assets and store them in `.structure/structure.db`
64+
65+
# Notes
66+
* XLSX files support dropped but could potentially generate two assets, original file for download and asset table for direct asset vieweing

0 commit comments

Comments
 (0)