Reorganise source files into src and web
Use a more traditional source code layout with the code located in the src/ dir and static web content in the web/ dir, while the other places are for data not related to code or content.
This commit is contained in:
parent
82323c9158
commit
c8527f17f7
20 changed files with 35 additions and 36 deletions
|
@ -1,17 +0,0 @@
|
|||
import type { Page } from "./types.js";
|
||||
import { index } from "./index.js";
|
||||
import { updates, updatesIndex } from "./updates.js";
|
||||
import { words, wordsIndex } from "./words.js";
|
||||
import { projects, projectsIndex } from "./projects.js";
|
||||
import { links } from "./links.js";
|
||||
|
||||
export const pages: Page[] = [
|
||||
index,
|
||||
updatesIndex,
|
||||
...updates,
|
||||
wordsIndex,
|
||||
...words,
|
||||
projectsIndex,
|
||||
...projects,
|
||||
links,
|
||||
];
|
|
@ -1,8 +1,8 @@
|
|||
import * as fs from "node:fs";
|
||||
import * as posix from "node:path/posix";
|
||||
import { prettify, htmlDocument } from "antihtml";
|
||||
import { pages } from "./content/pages.js";
|
||||
import type { Page } from "./content/types.js";
|
||||
import { pages } from "./pages.js";
|
||||
import type { Page } from "./types.js";
|
||||
import { resolveRefs } from "./utils/resolve-refs.js";
|
||||
import { createServer } from "./utils/http-server.js";
|
||||
|
||||
|
@ -21,7 +21,7 @@ function pageToHtml(page: Page) {
|
|||
}
|
||||
|
||||
function assembleResources() {
|
||||
const webDir = "public";
|
||||
const webDir = "web";
|
||||
const resources = new Map<string, string | Page>();
|
||||
for (const entry of fs.readdirSync(webDir, { recursive: true, withFileTypes: true })) {
|
||||
if (!entry.isFile())
|
|
@ -4,7 +4,7 @@ interface BaseProps {
|
|||
title: string;
|
||||
children: Node | Node[],
|
||||
}
|
||||
export function BasePage(props: BaseProps) {
|
||||
export default function BasePage(props: BaseProps) {
|
||||
return <html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
|
@ -1,4 +1,4 @@
|
|||
import { BasePage } from "./bases.js";
|
||||
import BasePage from "../components/BasePage.js";
|
||||
import { projects } from "./projects.js"
|
||||
import { updates } from "./updates.js"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { readFileSync } from "node:fs";
|
||||
import { BasePage } from "./bases.js";
|
||||
import type { Page } from "./types.js";
|
||||
import BasePage from "../components/BasePage.js";
|
||||
import type { Page } from "../types.js";
|
||||
|
||||
interface LinkData {
|
||||
title: string,
|
||||
|
@ -25,7 +25,7 @@ function Link(props: { link: LinkData }) {
|
|||
{link.tags.join(", ")}
|
||||
</>
|
||||
}
|
||||
const data: Data = eval(`(${readFileSync("content/links.jsonc", "utf8")})`);
|
||||
const data: Data = eval(`(${readFileSync("src/content/links.jsonc", "utf8")})`);
|
||||
data.links.pop(); // Remove template at the end
|
||||
const title = "Links!";
|
||||
export const links: Page = {
|
|
@ -1,5 +1,5 @@
|
|||
import { BasePage } from "./bases.js";
|
||||
import type { Page } from "./types.js";
|
||||
import BasePage from "../components/BasePage.js";
|
||||
import type { Page } from "../types.js";
|
||||
import mySite from "./projects/my-site.js";
|
||||
|
||||
export const projects: Page[] = [
|
|
@ -1,4 +1,4 @@
|
|||
import type { ProjectMeta } from "../types.js";
|
||||
import type { ProjectMeta } from "../../types.js";
|
||||
const project: ProjectMeta = {
|
||||
status: "draft",
|
||||
title: "My Website",
|
|
@ -1,5 +1,5 @@
|
|||
import { BasePage } from "./bases.js";
|
||||
import type { Page } from "./types.js";
|
||||
import BasePage from "../components/BasePage.js";
|
||||
import type { Page } from "../types.js";
|
||||
|
||||
export const updates: Page[] = [
|
||||
{
|
|
@ -1,5 +1,5 @@
|
|||
import { BasePage } from "./bases.js";
|
||||
import type { Page } from "./types.js";
|
||||
import BasePage from "../components/BasePage.js";
|
||||
import type { Page } from "../types.js";
|
||||
import uselessDashboard from "./words/useless-dashboard.js";
|
||||
|
||||
export const words: Page[] = [
|
|
@ -1,4 +1,4 @@
|
|||
import type { WordsMeta } from "../types.js";
|
||||
import type { WordsMeta } from "../../types.js";
|
||||
const words: WordsMeta = {
|
||||
status: "draft",
|
||||
title: "Useless Dashboards",
|
17
src/pages.tsx
Normal file
17
src/pages.tsx
Normal file
|
@ -0,0 +1,17 @@
|
|||
import type { Page } from "./types.js";
|
||||
import { index } from "./content/index.js";
|
||||
import { updates, updatesIndex } from "./content/updates.js";
|
||||
import { words, wordsIndex } from "./content/words.js";
|
||||
import { projects, projectsIndex } from "./content/projects.js";
|
||||
import { links } from "./content/links.js";
|
||||
|
||||
export const pages: Page[] = [
|
||||
index,
|
||||
updatesIndex,
|
||||
...updates,
|
||||
wordsIndex,
|
||||
...words,
|
||||
projectsIndex,
|
||||
...projects,
|
||||
links,
|
||||
];
|
|
@ -1,9 +1,8 @@
|
|||
{
|
||||
"files": ["cli.ts"],
|
||||
"include": ["content", "utils"],
|
||||
"include": ["src"],
|
||||
"compilerOptions": {
|
||||
"outDir": "build/node",
|
||||
"rootDir": ".",
|
||||
"rootDir": "src",
|
||||
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "antihtml",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue