diff --git a/.gitignore b/.gitignore index 8b01b9b..16d54bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,24 @@ -node_modules -static/css/out.css -static/learn -static/js/highlighter.js +# build output +dist/ +# generated types +.astro/ + +# dependencies +node_modules/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store + +# jetbrains setting folder +.idea/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e34a99b --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# Astro Starter Kit: Minimal + +```sh +npm create astro@latest -- --template minimal +``` + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal) +[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal) +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/minimal/devcontainer.json) + +> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun! + +## 🚀 Project Structure + +Inside of your Astro project, you'll see the following folders and files: + +```text +/ +├── public/ +├── src/ +│ └── pages/ +│ └── index.astro +└── package.json +``` + +Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. + +There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. + +Any static assets, like images, can be placed in the `public/` directory. + +## 🧞 Commands + +All commands are run from the root of the project, from a terminal: + +| Command | Action | +| :------------------------ | :----------------------------------------------- | +| `npm install` | Installs dependencies | +| `npm run dev` | Starts local dev server at `localhost:4321` | +| `npm run build` | Build your production site to `./dist/` | +| `npm run preview` | Preview your build locally, before deploying | +| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` | +| `npm run astro -- --help` | Get help using the Astro CLI | + +## 👀 Want to learn more? + +Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). diff --git a/astro.config.mjs b/astro.config.mjs new file mode 100644 index 0000000..036bef9 --- /dev/null +++ b/astro.config.mjs @@ -0,0 +1,12 @@ +import { defineConfig } from 'astro/config'; +import tailwind from "@astrojs/tailwind"; + +import mdx from "@astrojs/mdx"; + +// https://astro.build/config +export default defineConfig({ + integrations: [tailwind(), mdx()], + markdown: { + syntaxHighlight: false, + }, +}); \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 8f1bb0a..32fc5fd 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/md-docs.config.yaml b/md-docs.config.yaml deleted file mode 100644 index e70befb..0000000 --- a/md-docs.config.yaml +++ /dev/null @@ -1,11 +0,0 @@ -input: md -output: static -template: static/template.html - -headings: - h1: text-4xl mb-4 mt-8 font-display opacity-90 font-black text-c-text-2 - h2: text-2xl mt-10 mb-4 font-display opacity-90 font-bold text-c-text-2 - h3: text-xl mt-10 mb-4 font-display opacity-90 text-c-text-2 - -file_tree_title_classes: "uppercase font-display text-c-text-2 font-medium" -link_classes: text-blue-500 hover:underline diff --git a/md/learn/basics/operators.md b/md/learn/basics/operators.md deleted file mode 100644 index 949fc93..0000000 --- a/md/learn/basics/operators.md +++ /dev/null @@ -1,5 +0,0 @@ -# Operators - -Some common operators - - diff --git a/md/learn/flow-control/blocks.md b/md/learn/flow-control/blocks.md deleted file mode 100644 index 8037ecd..0000000 --- a/md/learn/flow-control/blocks.md +++ /dev/null @@ -1,4 +0,0 @@ -# Blocks - -Blocks :D - diff --git a/md/learn/index.yaml b/md/learn/index.yaml deleted file mode 100644 index 5320cbe..0000000 --- a/md/learn/index.yaml +++ /dev/null @@ -1,72 +0,0 @@ -path: "" -name: "" -has_index: true -children: -- path: index - name: Index -- path: install - name: Install -- path: basics - name: Basics - children: - - path: hello-world - name: Hello, world! - - name: Variables - path: variables - - path: datatypes - name: Datatypes - - path: comments - name: Comments -- name: Flow control - path: flow-control - children: - - name: Blocks - path: blocks - - name: Conditionals - path: conditionals - - name: Loops - path: loops - - name: Match - path: match -- name: Data structures - path: data-structures - children: - - name: Tuples - path: tuples - - name: Arrays - path: arrays - - name: Maps - path: maps - - name: Enums - path: enums -- name: Functions - path: functions - children: - - name: Declaration - path: declaration - - name: Parameter references - path: parameters - - name: Higher-order functions - path: higher-order - - name: Lambdas - path: lambdas -- name: Error handling - path: error-handling - children: - - name: Nullable types - path: "null" - - name: Try expressions - path: try -- name: Classes - path: classes - children: - - name: Definition - path: definition - - name: Static - path: static - - name: Interfaces - path: interfaces - - name: Anonymous classes - path: anonymous - - name: Magic - path: magic diff --git a/package.json b/package.json index 25a10ef..cc4f1bd 100644 --- a/package.json +++ b/package.json @@ -1,29 +1,22 @@ { - "name": "docs", - "version": "1.0.0", - "description": "", - "main": "index.js", + "name": "thp-docs", + "type": "module", + "version": "0.0.1", "scripts": { - "generate": "md-docs", - "bundle": "bun build ./lexer/highlighter.ts --outdir ./static/js/ --format esm --minify", - "dev": "concurrently -k \"tailwindcss -i ./tailwind.css -o ./static/css/out.css --watch\" \"serve ./static/ -l 3333\"", - "tailwind:watch": "tailwindcss -i ./tailwind.css -o ./static/css/out.css --watch", - "tailwind:build": "tailwindcss -i ./tailwind.css -o ./static/css/out.css" + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview", + "astro": "astro" }, - "keywords": [], - "author": "", - "license": "ISC", "dependencies": { - "@types/bun": "^1.0.10", + "@astrojs/check": "^0.5.10", + "@astrojs/mdx": "^2.3.0", + "@astrojs/tailwind": "^5.1.0", + "@types/bun": "^1.0.12", + "astro": "^4.6.1", "codejar": "^4.2.0", - "tailwindcss": "^3.2.7" - }, - "devDependencies": { - "concurrently": "^8.2.0", - "serve": "^14.2.1", - "bun-types": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" + "tailwindcss": "^3.4.3", + "typescript": "^5.4.5" } } \ No newline at end of file diff --git a/tailwind.css b/public/css/global.css similarity index 96% rename from tailwind.css rename to public/css/global.css index fc18947..fec57de 100644 --- a/tailwind.css +++ b/public/css/global.css @@ -1,6 +1,3 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; :root { --c-bg: #121212; diff --git a/public/css/pages.css b/public/css/pages.css new file mode 100644 index 0000000..e8a17e4 --- /dev/null +++ b/public/css/pages.css @@ -0,0 +1,39 @@ + +.markdown h1 { + font-size: 2.25rem; + line-height: 2.5rem; + margin-bottom: 1rem; + margin-top: 2rem; + font-family: Inter, sans-serif; + opacity: 0.9; + font-weight: 900; + color: var(--c-text-2); +} + +.markdown h2 { + /* use these tailwind classes: text-2xl mt-10 mb-4 font-display opacity-90 font-bold text-c-text-2 */ + font-size: 1.5rem; + line-height: 2rem; + margin-bottom: 1rem; + margin-top: 2.5rem; + font-family: Inter, sans-serif; + opacity: 0.9; + font-weight: 700; + color: var(--c-text-2); +} + +.markdown ul { + list-style-type: disc; + list-style-position: inside; +} + +.markdown ul li { + padding: 0.5rem 0; +} + +.markdown pre { + margin: 0.5em 0; + padding: 0.75em 0.75em; + color: var(--code-theme-color); + background: var(--code-theme-bg-color); +} diff --git a/static/css/prism.min.css b/public/css/prism.min.css similarity index 100% rename from static/css/prism.min.css rename to public/css/prism.min.css diff --git a/static/css/xcode-colors.css b/public/css/xcode-colors.css similarity index 100% rename from static/css/xcode-colors.css rename to public/css/xcode-colors.css diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000..f157bd1 --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1,9 @@ + + + + diff --git a/static/img/desc_thp.jpg b/public/img/desc_thp.jpg similarity index 100% rename from static/img/desc_thp.jpg rename to public/img/desc_thp.jpg diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro new file mode 100644 index 0000000..896a131 --- /dev/null +++ b/src/components/Navbar.astro @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/src/components/Sidebar.astro b/src/components/Sidebar.astro new file mode 100644 index 0000000..9fdbfbc --- /dev/null +++ b/src/components/Sidebar.astro @@ -0,0 +1,39 @@ +--- +import type { PageEntry } from "../layouts/PagesLayout.astro"; + +const entry: PageEntry = Astro.props.entry; +const basePath: string = Astro.props.basePath; + +const entryPath = entry.path === "index"? "": entry.path; +--- + +{ + !entry.children && ( +
  • + + {entry.title} + +
  • + ) +} +{ + entry.children && ( + <> +
    + {entry.title} +
    + + + + ) +} diff --git a/src/components/TOC.astro b/src/components/TOC.astro new file mode 100644 index 0000000..1bafb8b --- /dev/null +++ b/src/components/TOC.astro @@ -0,0 +1,39 @@ +--- +// github.com/rezahedi/rezahedi.dev/blob/main/src/components/TOC.astro +import TOCHeading from "./TOCHeading.astro"; + +const { headings } = Astro.props; + +const toc = buildHierarchy(headings); + +function buildHierarchy(headings: any) { + const toc: any[] = []; + const parentHeadings = new Map(); + + if (!headings) return toc; + + headings.forEach((h: any) => { + const heading = { ...h, subheadings: [] }; + parentHeadings.set(heading.depth, heading); + // Change 2 to 1 if your markdown includes your

    + if (heading.depth === 1) { + toc.push(heading); + } else { + parentHeadings.get(heading.depth - 1).subheadings.push(heading); + } + }); + return toc; +} +--- + +{ + toc && toc.length > 0 && ( + + ) +} diff --git a/src/components/TOCHeading.astro b/src/components/TOCHeading.astro new file mode 100644 index 0000000..4c39d6e --- /dev/null +++ b/src/components/TOCHeading.astro @@ -0,0 +1,19 @@ +--- +// github.com/rezahedi/rezahedi.dev/blob/main/src/components/TOCHeading.astro +const { heading } = Astro.props; +--- + +
  • + + {heading.text} + + { + heading.subheadings.length > 0 && ( + + ) + } +
  • diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 0000000..f964fe0 --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro new file mode 100644 index 0000000..c4e7635 --- /dev/null +++ b/src/layouts/BaseLayout.astro @@ -0,0 +1,31 @@ +--- +const {title} = Astro.props; +--- + + + + + + + {title ?? "THP: Typed Hypertext Processor"} + + + + + + + + + + + + + + + diff --git a/src/layouts/PagesLayout.astro b/src/layouts/PagesLayout.astro new file mode 100644 index 0000000..5541a06 --- /dev/null +++ b/src/layouts/PagesLayout.astro @@ -0,0 +1,146 @@ +--- +import Navbar from "../components/Navbar.astro"; +import BaseLayout from "./BaseLayout.astro"; +import TOC from "../components/TOC.astro"; +import Sidebar from "../components/Sidebar.astro"; + +const { frontmatter, headings } = Astro.props; + +const posts = await Astro.glob("../pages/learn/**/*.md"); + +// The index.md page must have a `pagesLayout` frontmatter, which declares the order of all the pages. +const indexSubpath = `/learn/index.md`; + +const indexPage = posts.find((post) => post.file.endsWith(indexSubpath)); + +if (indexPage === undefined) { + throw new Error(`No index page found at ${indexSubpath}`); +} + +export type PageEntry = { + path: string; + title?: string; + children?: Array; +}; + +const pagesIndex: Array | undefined = + indexPage.frontmatter.pagesLayout; + +if (pagesIndex === undefined) { + console.error(indexPage.frontmatter); + throw new Error(`No pagesLayout frontmatter found in ${indexSubpath}`); +} + +function validateEntry(entry: PageEntry, basePath: string) { + if (!entry.children) { + // Attempt to get the page title from frontmatter + const pageData = posts.find((post) => + post.file.endsWith(entry.path + ".md"), + ); + + if (pageData === undefined) { + console.error(entry); + console.error(entry.path + ".md"); + throw new Error(`No page found at ${entry.path}`); + } + + // set the title + entry.title = pageData.frontmatter.title ?? "Title not set"; + + return; + } + + // Recursively search for children + if (!entry.title) { + console.log(entry); + throw new Error( + `No title found in ${basePath + entry.path}, which is a folder and requires it.`, + ); + } + + const folderName = entry.title; + + entry.children.forEach((child) => + validateEntry(child, basePath + "/" + folderName), + ); +} + +for (const entry of pagesIndex) { + validateEntry(entry, `/learn/`); +} +--- + + + + +
    +
    + +
    + +
    + +
    + +
    + +
    +
    + + + +
    diff --git a/lexer/highlighter.ts b/src/lexer/highlighter.ts similarity index 57% rename from lexer/highlighter.ts rename to src/lexer/highlighter.ts index c1b612b..5509a79 100644 --- a/lexer/highlighter.ts +++ b/src/lexer/highlighter.ts @@ -1,7 +1,7 @@ -import {lex} from "./lexer.ts"; -import { CodeJar } from "codejar" +import { lex } from "./lexer"; +import {CodeJar as Codejar} from "codejar"; -function thp_highlighter(editor: any) { +export function thp_highlighter(editor: any) { let code: string = editor.textContent; let tokens = lex(code); @@ -15,7 +15,4 @@ function thp_highlighter(editor: any) { editor.innerHTML = highlighted_code; } -// @ts-ignore -window.thp_highlighter = thp_highlighter; -// @ts-ignore -window.CodeJar = CodeJar; +export const CodeJar = Codejar; diff --git a/lexer/identifier_lexer.test.ts b/src/lexer/identifier_lexer.test.ts similarity index 100% rename from lexer/identifier_lexer.test.ts rename to src/lexer/identifier_lexer.test.ts diff --git a/lexer/identifier_lexer.ts b/src/lexer/identifier_lexer.ts similarity index 93% rename from lexer/identifier_lexer.ts rename to src/lexer/identifier_lexer.ts index 109c6cc..d7e55ce 100644 --- a/lexer/identifier_lexer.ts +++ b/src/lexer/identifier_lexer.ts @@ -1,5 +1,5 @@ -import type { Token } from "./lexer.ts"; -import { is_identifier_char } from "./utils.ts"; +import type { Token } from "./lexer"; +import { is_identifier_char } from "./utils"; /** * Scans an identifier, at the given position in the input string. diff --git a/lexer/lexer.test.ts b/src/lexer/lexer.test.ts similarity index 100% rename from lexer/lexer.test.ts rename to src/lexer/lexer.test.ts diff --git a/lexer/lexer.ts b/src/lexer/lexer.ts similarity index 94% rename from lexer/lexer.ts rename to src/lexer/lexer.ts index 3239728..b683c16 100644 --- a/lexer/lexer.ts +++ b/src/lexer/lexer.ts @@ -1,7 +1,7 @@ -import { scan_identifier } from "./identifier_lexer.ts"; -import { scan_number } from "./number_lexer.ts"; -import { scan_string } from "./string_lexer.ts"; -import { is_digit, is_lowercase, is_uppercase } from "./utils.ts"; +import { scan_identifier } from "./identifier_lexer"; +import { scan_number } from "./number_lexer"; +import { scan_string } from "./string_lexer"; +import { is_digit, is_lowercase, is_uppercase } from "./utils"; export type Token = { v: string, diff --git a/lexer/number_lexer.test.ts b/src/lexer/number_lexer.test.ts similarity index 100% rename from lexer/number_lexer.test.ts rename to src/lexer/number_lexer.test.ts diff --git a/lexer/number_lexer.ts b/src/lexer/number_lexer.ts similarity index 93% rename from lexer/number_lexer.ts rename to src/lexer/number_lexer.ts index e5875e8..0d04620 100644 --- a/lexer/number_lexer.ts +++ b/src/lexer/number_lexer.ts @@ -1,5 +1,5 @@ -import type { Token } from "./lexer.ts"; -import { is_digit } from "./utils.ts"; +import type { Token } from "./lexer"; +import { is_digit } from "./utils"; /** * Scans a number, at the given position in the input string. diff --git a/lexer/string_lexer.test.ts b/src/lexer/string_lexer.test.ts similarity index 100% rename from lexer/string_lexer.test.ts rename to src/lexer/string_lexer.test.ts diff --git a/lexer/string_lexer.ts b/src/lexer/string_lexer.ts similarity index 96% rename from lexer/string_lexer.ts rename to src/lexer/string_lexer.ts index a03569d..b5e75bd 100644 --- a/lexer/string_lexer.ts +++ b/src/lexer/string_lexer.ts @@ -1,4 +1,4 @@ -import type { Token } from "./lexer.ts"; +import type { Token } from "./lexer"; export function scan_string(input: string, starting_position: number): [Token, number] { let value = "\""; diff --git a/lexer/utils.ts b/src/lexer/utils.ts similarity index 100% rename from lexer/utils.ts rename to src/lexer/utils.ts diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000..023d9e4 --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,125 @@ +--- +import BaseLayout from "../layouts/BaseLayout.astro"; +import Navbar from "../components/Navbar.astro"; +--- + + + + +
    +
    +
    +

    + A modern, type safe, + + secure language + + compiled to PHP +

    +

    + Inspired by Rust, Zig and Swift, THP has a modern syntax, + semantics, type system and stdlib. +

    +
    +
    + +
    +
    + +
    + + + + + + + + + +
    +
    +
    +
    + + +
    diff --git a/md/learn/basics/comments.md b/src/pages/learn/basics/comments.md similarity index 76% rename from md/learn/basics/comments.md rename to src/pages/learn/basics/comments.md index 7965040..7f7e9d3 100644 --- a/md/learn/basics/comments.md +++ b/src/pages/learn/basics/comments.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Comments +--- + # Comments Only these two: diff --git a/md/learn/basics/datatypes.md b/src/pages/learn/basics/datatypes.md similarity index 83% rename from md/learn/basics/datatypes.md rename to src/pages/learn/basics/datatypes.md index 4af7ee0..25054fb 100644 --- a/md/learn/basics/datatypes.md +++ b/src/pages/learn/basics/datatypes.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Datatypes +--- + # Datatypes Datatypes's first character are always uppercase. diff --git a/md/learn/basics/hello-world.md b/src/pages/learn/basics/hello-world.md similarity index 64% rename from md/learn/basics/hello-world.md rename to src/pages/learn/basics/hello-world.md index 4338752..74c8efa 100644 --- a/md/learn/basics/hello-world.md +++ b/src/pages/learn/basics/hello-world.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Hello world +--- + # Hello, world! Create a file named `hello.thp` with the contents: diff --git a/src/pages/learn/basics/operators.md b/src/pages/learn/basics/operators.md new file mode 100644 index 0000000..d6a2813 --- /dev/null +++ b/src/pages/learn/basics/operators.md @@ -0,0 +1,10 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Install +--- + +# Operators + +Some common operators + + diff --git a/md/learn/basics/variables.md b/src/pages/learn/basics/variables.md similarity index 93% rename from md/learn/basics/variables.md rename to src/pages/learn/basics/variables.md index 420fdd5..3666b2c 100644 --- a/md/learn/basics/variables.md +++ b/src/pages/learn/basics/variables.md @@ -1,3 +1,9 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Variables + +--- + # Variables thp distinguishes between mutable and immutable variables. diff --git a/md/learn/classes/anonymous.md b/src/pages/learn/classes/anonymous.md similarity index 83% rename from md/learn/classes/anonymous.md rename to src/pages/learn/classes/anonymous.md index 86f4135..7d849fe 100644 --- a/md/learn/classes/anonymous.md +++ b/src/pages/learn/classes/anonymous.md @@ -1,3 +1,7 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Anonymous classes +--- # Anonymous classes diff --git a/md/learn/classes/definition.md b/src/pages/learn/classes/definition.md similarity index 96% rename from md/learn/classes/definition.md rename to src/pages/learn/classes/definition.md index 0dba89a..1b885f2 100644 --- a/md/learn/classes/definition.md +++ b/src/pages/learn/classes/definition.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Classes +--- + # Classes Basically kotlin syntax. diff --git a/md/learn/classes/interfaces.md b/src/pages/learn/classes/interfaces.md similarity index 78% rename from md/learn/classes/interfaces.md rename to src/pages/learn/classes/interfaces.md index c3968c6..648a0d1 100644 --- a/md/learn/classes/interfaces.md +++ b/src/pages/learn/classes/interfaces.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Interfaces +--- + # Interfaces diff --git a/md/learn/classes/magic.md b/src/pages/learn/classes/magic.md similarity index 78% rename from md/learn/classes/magic.md rename to src/pages/learn/classes/magic.md index 0d3e5cd..bda80d1 100644 --- a/md/learn/classes/magic.md +++ b/src/pages/learn/classes/magic.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Magic methods +--- + # Magic methods Don't get special treatment. diff --git a/md/learn/classes/static.md b/src/pages/learn/classes/static.md similarity index 88% rename from md/learn/classes/static.md rename to src/pages/learn/classes/static.md index f310b5a..efadc26 100644 --- a/md/learn/classes/static.md +++ b/src/pages/learn/classes/static.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Static +--- + # Static in classes diff --git a/md/learn/data-structures/arrays.md b/src/pages/learn/data-structures/arrays.md similarity index 86% rename from md/learn/data-structures/arrays.md rename to src/pages/learn/data-structures/arrays.md index cf3e1a8..dc79315 100644 --- a/md/learn/data-structures/arrays.md +++ b/src/pages/learn/data-structures/arrays.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Arrays +--- + # Arrays Use square brackets as usual. diff --git a/md/learn/data-structures/enums.md b/src/pages/learn/data-structures/enums.md similarity index 88% rename from md/learn/data-structures/enums.md rename to src/pages/learn/data-structures/enums.md index e9a558c..578e0c9 100644 --- a/md/learn/data-structures/enums.md +++ b/src/pages/learn/data-structures/enums.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Enums +--- + # Enums (Tagged unions) ## Basic enums diff --git a/md/learn/data-structures/maps.md b/src/pages/learn/data-structures/maps.md similarity index 97% rename from md/learn/data-structures/maps.md rename to src/pages/learn/data-structures/maps.md index 9d6d9d5..268adcd 100644 --- a/md/learn/data-structures/maps.md +++ b/src/pages/learn/data-structures/maps.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Maps +--- + # Maps Also known as Associative Arrays, or Objects in other languages. diff --git a/md/learn/data-structures/tuples.md b/src/pages/learn/data-structures/tuples.md similarity index 78% rename from md/learn/data-structures/tuples.md rename to src/pages/learn/data-structures/tuples.md index 9c463cc..b9b264d 100644 --- a/md/learn/data-structures/tuples.md +++ b/src/pages/learn/data-structures/tuples.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Tuples +--- + # Tuples Uses `#()` just to avoid confusion with function calls and grouping (`()`). diff --git a/md/learn/error-handling/null.md b/src/pages/learn/error-handling/null.md similarity index 95% rename from md/learn/error-handling/null.md rename to src/pages/learn/error-handling/null.md index df0b690..36d0e7b 100644 --- a/md/learn/error-handling/null.md +++ b/src/pages/learn/error-handling/null.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Nullable types +--- + # Nullable types All datatypes in THP disallow the usage of `null` by default. diff --git a/md/learn/error-handling/try.md b/src/pages/learn/error-handling/try.md similarity index 91% rename from md/learn/error-handling/try.md rename to src/pages/learn/error-handling/try.md index cd677b9..0c85a71 100644 --- a/md/learn/error-handling/try.md +++ b/src/pages/learn/error-handling/try.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Try expressions +--- + # Try expressions ```thp diff --git a/src/pages/learn/flow-control/blocks.md b/src/pages/learn/flow-control/blocks.md new file mode 100644 index 0000000..5e95d1c --- /dev/null +++ b/src/pages/learn/flow-control/blocks.md @@ -0,0 +1,9 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Blocks +--- + +# Blocks + +Blocks :D + diff --git a/md/learn/flow-control/conditionals.md b/src/pages/learn/flow-control/conditionals.md similarity index 90% rename from md/learn/flow-control/conditionals.md rename to src/pages/learn/flow-control/conditionals.md index 0846b95..91337c2 100644 --- a/md/learn/flow-control/conditionals.md +++ b/src/pages/learn/flow-control/conditionals.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Conditionals +--- + # Conditionals - Only `Bool` are accepted. No truthy/falsy. diff --git a/md/learn/flow-control/loops.md b/src/pages/learn/flow-control/loops.md similarity index 93% rename from md/learn/flow-control/loops.md rename to src/pages/learn/flow-control/loops.md index 758a017..338b95e 100644 --- a/md/learn/flow-control/loops.md +++ b/src/pages/learn/flow-control/loops.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Loops +--- + # Loops ## For loop diff --git a/md/learn/flow-control/match.md b/src/pages/learn/flow-control/match.md similarity index 89% rename from md/learn/flow-control/match.md rename to src/pages/learn/flow-control/match.md index c969df8..962c3a9 100644 --- a/md/learn/flow-control/match.md +++ b/src/pages/learn/flow-control/match.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Match +--- + # Match ## Syntax diff --git a/md/learn/functions/declaration.md b/src/pages/learn/functions/declaration.md similarity index 94% rename from md/learn/functions/declaration.md rename to src/pages/learn/functions/declaration.md index 2c16d0b..9a3d791 100644 --- a/md/learn/functions/declaration.md +++ b/src/pages/learn/functions/declaration.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Declaration +--- + # Declaration diff --git a/md/learn/functions/higher-order.md b/src/pages/learn/functions/higher-order.md similarity index 82% rename from md/learn/functions/higher-order.md rename to src/pages/learn/functions/higher-order.md index 4ae4bd4..b6112ed 100644 --- a/md/learn/functions/higher-order.md +++ b/src/pages/learn/functions/higher-order.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Higher Order Functions +--- + # Higher Order functions diff --git a/md/learn/functions/lambdas.md b/src/pages/learn/functions/lambdas.md similarity index 93% rename from md/learn/functions/lambdas.md rename to src/pages/learn/functions/lambdas.md index 370a6b3..02a31bd 100644 --- a/md/learn/functions/lambdas.md +++ b/src/pages/learn/functions/lambdas.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Lambdas +--- + # Lambdas / Anonymous functions diff --git a/md/learn/functions/parameters.md b/src/pages/learn/functions/parameters.md similarity index 94% rename from md/learn/functions/parameters.md rename to src/pages/learn/functions/parameters.md index 4a802ab..8467517 100644 --- a/md/learn/functions/parameters.md +++ b/src/pages/learn/functions/parameters.md @@ -1,3 +1,8 @@ +--- +layout: ../../../layouts/PagesLayout.astro +title: Function parameters +--- + # Function parameters diff --git a/md/learn/ideas/idea_1.md b/src/pages/learn/ideas/idea_1.md similarity index 100% rename from md/learn/ideas/idea_1.md rename to src/pages/learn/ideas/idea_1.md diff --git a/md/learn/index.md b/src/pages/learn/index.md similarity index 79% rename from md/learn/index.md rename to src/pages/learn/index.md index 62e626b..ca817a5 100644 --- a/md/learn/index.md +++ b/src/pages/learn/index.md @@ -1,3 +1,53 @@ +--- +layout: ../../layouts/PagesLayout.astro +title: Welcome +pagesLayout: +- path: index +- path: install +- path: basics + title: Basics + children: + - path: hello-world + - path: variables + - path: datatypes + - path: comments +- path: flow-control + title: Flow control + children: + - path: blocks + - path: conditionals + - path: loops + - path: match +- path: data-structures + title: Data structures + children: + - path: tuples + - path: arrays + - path: maps + - path: enums +- path: functions + title: Functions + children: + - path: declaration + - path: parameters + - path: higher-order + - path: lambdas +- path: error-handling + title: Error handling + children: + - path: "null" + - path: try +- path: classes + title: Classes + children: + - path: definition + - path: static + - path: interfaces + - path: anonymous + - path: magic + +--- + # Welcome Welcome to the documentation of the THP programming languague. @@ -9,7 +59,7 @@ THP is a new programming language that compiles to PHP.
    This page discusses some of the design decitions of the language, -if you want to install THP go to the [installation guide](/installation-guide) +if you want to install THP go to the [installation guide](install) If you want to learn the language, go to the learn section. diff --git a/md/learn/install.md b/src/pages/learn/install.md similarity index 78% rename from md/learn/install.md rename to src/pages/learn/install.md index 444187a..8d54dfd 100644 --- a/md/learn/install.md +++ b/src/pages/learn/install.md @@ -1,3 +1,8 @@ +--- +layout: ../../layouts/PagesLayout.astro +title: Install +--- + # Install ## From scratch diff --git a/static/index.html b/static/index.html deleted file mode 100644 index aa302dd..0000000 --- a/static/index.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - THP: Typed Hypertext Processor - - - - - - - - - - - - - - -
    -
    -
    -

    - A modern, type safe, - - secure language - - compiled to PHP -

    -

    - Inspired by Rust, Zig and Swift, THP has a modern syntax, semantics, - type system and stdlib. -

    -
    -
    - -
    -
    - -
    - - - - - - - - - -
    -
    -
    -
    - - - - - - diff --git a/static/template.html b/static/template.html deleted file mode 100644 index 99adab3..0000000 --- a/static/template.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - THP: Typed Hypertext Processor - - - - - - - - - - - - - - -
    -
    - -
    - -
    - {{markdown}} -
    - -
    - -
    -
    - - - - - - - \ No newline at end of file diff --git a/tailwind.config.js b/tailwind.config.mjs similarity index 91% rename from tailwind.config.js rename to tailwind.config.mjs index d7be3c5..5717238 100644 --- a/tailwind.config.js +++ b/tailwind.config.mjs @@ -1,8 +1,8 @@ /** @type {import('tailwindcss').Config} */ -module.exports = { - content: ["./static/**/*.html"], - theme: { - extend: { +export default { + content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'], + theme: { + extend: { colors: { "c-bg": "var(--c-bg)", "c-text": "var(--c-text)", @@ -22,8 +22,8 @@ module.exports = { "display": ["Inter", "'Josefin Sans'", "'Fugaz One'", "sans-serif"], "body": ["Inter", "sans-serif"], }, - }, - corePlugins: { + }, + corePlugins: { container: false }, plugins: [ @@ -48,4 +48,3 @@ module.exports = { } ], } - diff --git a/tsconfig.json b/tsconfig.json index df2b488..3fd7ae6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,27 +1,3 @@ { - "compilerOptions": { - // Enable latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags - "noUnusedLocals": true, - "noUnusedParameters": true, - "noPropertyAccessFromIndexSignature": true - } -} + "extends": "astro/tsconfigs/strictest" +} \ No newline at end of file