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 fs from "node:fs";
|
||||||
import * as posix from "node:path/posix";
|
import * as posix from "node:path/posix";
|
||||||
import { prettify, htmlDocument } from "antihtml";
|
import { prettify, htmlDocument } from "antihtml";
|
||||||
import { pages } from "./content/pages.js";
|
import { pages } from "./pages.js";
|
||||||
import type { Page } from "./content/types.js";
|
import type { Page } from "./types.js";
|
||||||
import { resolveRefs } from "./utils/resolve-refs.js";
|
import { resolveRefs } from "./utils/resolve-refs.js";
|
||||||
import { createServer } from "./utils/http-server.js";
|
import { createServer } from "./utils/http-server.js";
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ function pageToHtml(page: Page) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function assembleResources() {
|
function assembleResources() {
|
||||||
const webDir = "public";
|
const webDir = "web";
|
||||||
const resources = new Map<string, string | Page>();
|
const resources = new Map<string, string | Page>();
|
||||||
for (const entry of fs.readdirSync(webDir, { recursive: true, withFileTypes: true })) {
|
for (const entry of fs.readdirSync(webDir, { recursive: true, withFileTypes: true })) {
|
||||||
if (!entry.isFile())
|
if (!entry.isFile())
|
|
@ -4,7 +4,7 @@ interface BaseProps {
|
||||||
title: string;
|
title: string;
|
||||||
children: Node | Node[],
|
children: Node | Node[],
|
||||||
}
|
}
|
||||||
export function BasePage(props: BaseProps) {
|
export default function BasePage(props: BaseProps) {
|
||||||
return <html lang="en">
|
return <html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<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 { projects } from "./projects.js"
|
||||||
import { updates } from "./updates.js"
|
import { updates } from "./updates.js"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { readFileSync } from "node:fs";
|
import { readFileSync } from "node:fs";
|
||||||
import { BasePage } from "./bases.js";
|
import BasePage from "../components/BasePage.js";
|
||||||
import type { Page } from "./types.js";
|
import type { Page } from "../types.js";
|
||||||
|
|
||||||
interface LinkData {
|
interface LinkData {
|
||||||
title: string,
|
title: string,
|
||||||
|
@ -25,7 +25,7 @@ function Link(props: { link: LinkData }) {
|
||||||
{link.tags.join(", ")}
|
{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
|
data.links.pop(); // Remove template at the end
|
||||||
const title = "Links!";
|
const title = "Links!";
|
||||||
export const links: Page = {
|
export const links: Page = {
|
|
@ -1,5 +1,5 @@
|
||||||
import { BasePage } from "./bases.js";
|
import BasePage from "../components/BasePage.js";
|
||||||
import type { Page } from "./types.js";
|
import type { Page } from "../types.js";
|
||||||
import mySite from "./projects/my-site.js";
|
import mySite from "./projects/my-site.js";
|
||||||
|
|
||||||
export const projects: Page[] = [
|
export const projects: Page[] = [
|
|
@ -1,4 +1,4 @@
|
||||||
import type { ProjectMeta } from "../types.js";
|
import type { ProjectMeta } from "../../types.js";
|
||||||
const project: ProjectMeta = {
|
const project: ProjectMeta = {
|
||||||
status: "draft",
|
status: "draft",
|
||||||
title: "My Website",
|
title: "My Website",
|
|
@ -1,5 +1,5 @@
|
||||||
import { BasePage } from "./bases.js";
|
import BasePage from "../components/BasePage.js";
|
||||||
import type { Page } from "./types.js";
|
import type { Page } from "../types.js";
|
||||||
|
|
||||||
export const updates: Page[] = [
|
export const updates: Page[] = [
|
||||||
{
|
{
|
|
@ -1,5 +1,5 @@
|
||||||
import { BasePage } from "./bases.js";
|
import BasePage from "../components/BasePage.js";
|
||||||
import type { Page } from "./types.js";
|
import type { Page } from "../types.js";
|
||||||
import uselessDashboard from "./words/useless-dashboard.js";
|
import uselessDashboard from "./words/useless-dashboard.js";
|
||||||
|
|
||||||
export const words: Page[] = [
|
export const words: Page[] = [
|
|
@ -1,4 +1,4 @@
|
||||||
import type { WordsMeta } from "../types.js";
|
import type { WordsMeta } from "../../types.js";
|
||||||
const words: WordsMeta = {
|
const words: WordsMeta = {
|
||||||
status: "draft",
|
status: "draft",
|
||||||
title: "Useless Dashboards",
|
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": ["src"],
|
||||||
"include": ["content", "utils"],
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "build/node",
|
"outDir": "build/node",
|
||||||
"rootDir": ".",
|
"rootDir": "src",
|
||||||
|
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"jsxImportSource": "antihtml",
|
"jsxImportSource": "antihtml",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue