basic markdown parsing, typography

This commit is contained in:
James Acklin 2021-09-30 15:51:22 -04:00
parent ecea7e798b
commit 0aee364eee
16 changed files with 3210 additions and 8144 deletions

12
components/Layout.js Normal file
View File

@ -0,0 +1,12 @@
import Meta from "./Meta";
export default function Layout({ children }) {
return (
<>
<Meta />
<div className="max-w-full min-h-screen flex justify-center">
{children}
</div>
</>
);
}

5
components/Meta.js Normal file
View File

@ -0,0 +1,5 @@
import Head from "next/head";
export default function Meta() {
return <Head />;
}

View File

@ -1,6 +1,6 @@
+++
---
title: Community
+++
---
The developer community is a combination of top-down stewardship from the Urbit Foundation and Tlon, as well as organic, bottom-up coordination from unaffiliated enthusiasts.
@ -10,50 +10,51 @@ The Urbit Foundation makes direct investments of address space into the communit
Tlon is the primary developer of Urbit itself and the foremost product developer within the Urbit ecosystem. Theyve been developing Urbit since 2013 and are naturally a great source of information. They maintain the most popular Landscape groups, Urbit Community (~bitbex-bolbel/urbit-community) and Urbit Index (~todo-todo/urbit-index).
Directory
## Directory
Our community is comprised of individuals, all of whom happen to be pretty friendly. Heres a list of prominent figures youll likely encounter that are open to being contacted:
~wolref-podlex
`~wolref-podlex`
Executive Director, Urbit Foundation
Partnerships, grants, employment opportunities, technical projects, Urbit Foundation
~ravmel-ropdyl
`~ravmel-ropdyl`
CEO, Tlon
Partnerships, employment opportunities, geodesic domes, future of Urbit
~timluc-miptev
`~timluc-miptev`
Technical Director, Urbit Foundation
Userspace development, grants
~lagrev-nocfep
`~lagrev-nocfep`
Technical Director, Urbit Foundation
Urbit education
~poldec-tonteg
`~poldec-tonteg`
Program Manager, The Combine
Urbit entrepreneurship, organizational grants
~tirwyd-sarmes
`~tirwyd-sarmes`
Content Manager, Urbit Foundation
Content grants, newsletter, blog
~taller-ravnut
`~taller-ravnut`
Developer Relations, Urbit Foundation
Grants, meetups, gifts, Developer Calls
~tinnus-napbus
`~tinnus-napbus`
Technical writer and mentor, Urbit Foundation
Developer documentation, developer support
~wicdev-wisryt
`~wicdev-wisryt`
CTO, Tlon
Infrastructure development, Arvo, apprenticeships
~master-morzod
`~master-morzod`
Senior infrastructure engineer, Tlon
Infrastructure development, Vere, Arvo
~rovnys-ricfer
`~rovnys-ricfer`
Senior infrastructure engineer, Tlon
Infrastructure development, Arvo, software distribution

View File

@ -1,6 +1,6 @@
+++
---
title: Learn
+++
---
Weve made several self-guided tutorials and guides available to get your started on your journey, which should be read in order. All-in-all, a programmer with some experience should be able to work through this material and become proficient at Urbit programming in under a month of regular study.

View File

@ -1,6 +1,6 @@
+++
---
title: Opportunities
+++
---
Developer Grants
Work on Urbit - get a job

View File

@ -1,6 +1,6 @@
+++
---
title: Primer
+++
---
Urbit development involves a fairly typical client/server/database stack. Urbit is both a server, database, and an entire operating system—this means exposes a filesystem, HTTP server, timer, and much more to the programmer (these different parts of the operating system are called vanes).

View File

@ -1,6 +1,6 @@
+++
---
title: Why become an Urbit developer?
+++
---
Urbit is a novel general-purpose computer thats captivated thousands, and its no wonder why—truly novel computing architectures are few and far between, and they tend to be highly transformative. For recent examples, consider iOS and Ethereum. We think Urbit is at least as big of a deal.

43
lib/api.js Normal file
View File

@ -0,0 +1,43 @@
import fs from "fs";
import { join } from "path";
import matter from "gray-matter";
const postsDirectory = join(process.cwd(), "content");
export function getPostSlugs() {
return fs.readdirSync(postsDirectory);
}
export function getPostBySlug(slug, fields = []) {
const realSlug = slug.replace(/\.md$/, "");
const fullPath = join(postsDirectory, `${realSlug}.md`);
const fileContents = fs.readFileSync(fullPath, "utf8");
const { data, content } = matter(fileContents);
const items = {};
// Ensure only the minimal needed data is exposed
fields.forEach((field) => {
if (field === "slug") {
items[field] = realSlug;
}
if (field === "content") {
items[field] = content;
}
if (typeof data[field] !== "undefined") {
items[field] = data[field];
}
});
return items;
}
export function getAllPosts(fields = []) {
const slugs = getPostSlugs();
const posts = slugs
.map((slug) => getPostBySlug(slug, fields))
// sort posts by date in descending order
.sort((post1, post2) => (post1.date > post2.date ? -1 : 1));
return posts;
}

7
lib/markdownToHtml.js Normal file
View File

@ -0,0 +1,7 @@
import remark from "remark";
import html from "remark-html";
export default async function markdownToHtml(markdown) {
const result = await remark().use(html).process(markdown);
return result.toString();
}

8112
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,13 @@
"start": "next start"
},
"dependencies": {
"@tailwindcss/typography": "^0.4.1",
"gray-matter": "^4.0.3",
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react-dom": "^17.0.2",
"remark": "13.0.0",
"remark-html": "13.0.1"
},
"devDependencies": {
"autoprefixer": "^10.3.6",

56
pages/[slug].js Normal file
View File

@ -0,0 +1,56 @@
import { useRouter } from "next/router";
import { getPostBySlug, getAllPosts } from "../lib/api";
import markdownToHtml from "../lib/markdownToHtml";
import Layout from "../components/Layout";
export default function Post({ post, morePosts, preview }) {
const router = useRouter();
if (!router.isFallback && !post?.slug) {
return <ErrorPage statusCode={404} />;
}
return (
<Layout>
<div className="prose lg:prose-lg">
<h1>{post.title}</h1>
<div dangerouslySetInnerHTML={{ __html: post.content }}></div>
</div>
</Layout>
);
}
export async function getStaticProps({ params }) {
const post = getPostBySlug(params.slug, [
"title",
"date",
"slug",
"author",
"content",
"ogImage",
"coverImage",
]);
const content = await markdownToHtml(post.content || "");
return {
props: {
post: {
...post,
content,
},
},
};
}
export async function getStaticPaths() {
const posts = getAllPosts(["slug"]);
return {
paths: posts.map((post) => {
return {
params: {
slug: post.slug,
},
};
}),
fallback: false,
};
}

View File

@ -8,7 +8,7 @@ export default function Home() {
<link rel="icon" href="/favicon.ico" />
</Head>
<main className="">
<main className="prose lg:prose-lg">
<h1>
Urbit is a general-purpose platform for building decentralized,
peer-to-peer applications.

View File

@ -36,7 +36,7 @@ strong {
/* Typography */
h1,
/* h1,
.type-h1 {
@apply text-4xl lg:text-5xl font-extrabold leading-tight text-wall-600;
}
@ -51,20 +51,20 @@ h3,
@apply text-xl font-semibold;
}
h4,
.type-ui {
@apply text-lg font-semibold;
}
h5,
.type-h5,
.type-bold {
@apply text-base font-semibold leading-relaxed;
}
} */
p,
/* p,
.type-p {
@apply text-base leading-relaxed;
} */
.type-ui {
@apply text-lg font-semibold;
}
.type-sub {

View File

@ -65,5 +65,5 @@ module.exports = {
variants: {
extend: {},
},
plugins: [],
plugins: [require("@tailwindcss/typography")],
};

3050
yarn.lock Normal file

File diff suppressed because it is too large Load Diff