Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,28 @@
import { Transform } from './index.js';
import { Block, Line } from '../primitives.js';
import { rewireSource } from '../util.js';
const pull = (offset: number) => (str) => str.slice(offset);
const push = (offset: number) => {
const space = ''.padStart(offset, ' ');
return (str) => str + space;
};
export default function indent(pos: number): Transform {
let shift: (string: string) => string;
const pad = (start: string) => {
if (shift === undefined) {
const offset = pos - start.length;
shift = offset > 0 ? push(offset) : pull(-offset);
}
return shift(start);
};
const update = (line: Line): Line => ({
...line,
tokens: { ...line.tokens, start: pad(line.tokens.start) },
});
return ({ source, ...fields }: Block): Block =>
rewireSource({ ...fields, source: source.map(update) });
}