Skip to content

Commit

Permalink
Add basic markdown rendering for about-us page
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Jan 2, 2025
1 parent b7e4fd5 commit 1f75c87
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

24 changes: 23 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
import {
lazy,
LocationProvider,
ErrorBoundary,
Router,
Route,
} from 'preact-iso'

import aboutUsUrl from './routes/about-us.md'
import { renderMarkdownRoute } from './utils/renderMarkdownRoute'

const AboutUs = lazy(() => renderMarkdownRoute(aboutUsUrl))

export default function App() {
return <div>Hello World!</div>
return (
<LocationProvider>
<ErrorBoundary>
<Router>
<Route path="/about-us" component={AboutUs} />
<Route default component={() => 'Not found'} />
</Router>
</ErrorBoundary>
</LocationProvider>
)
}
4 changes: 4 additions & 0 deletions src/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.md' {
const url: string
export default url
}
22 changes: 22 additions & 0 deletions src/routes/about-us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: About Us
excerpt: SeattleJS is a safe and inclusive event for everyone
---

![SeattleJS at the Collective](/_public/images/seattlejs-march-2022.jpg)

SeattleJS is the largest JavaScript and web developer meetup in Seattle.

We are an inclusive community and welcome everyone, including folks who are just getting started in tech.

Our mission is to help folks:

<i class="fa-solid fa-battery-bolt"></i> Level up their skills

<i class="fa-solid fa-handshake-simple"></i> Grow their network

<i class="fa-solid fa-briefcase"></i> Get connected to job opportunities

<i class="fa-solid fa-globe"></i> Advocate for the open web

Our meetings are the 2nd Wednesday of each month, we hope you can join us!
16 changes: 16 additions & 0 deletions src/utils/renderMarkdownRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export async function renderMarkdownRoute(
markdownPath: string
): Promise<preact.ComponentType> {
const [frontMatter, marked] = await Promise.all([
import('front-matter'),
import('marked'),
])

const res = await fetch(markdownPath)
const text = await res.text()

const { attributes, body } = frontMatter.default(text)
const html = await marked.marked(body)

return () => <div dangerouslySetInnerHTML={{ __html: html }}></div>
}
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "bundler",
"jsx": "react-jsx",
"jsxImportSource": "preact",
"noEmit": true,
"strict": true,
"verbatimModuleSyntax": true,
"esModuleInterop": true
"esModuleInterop": true,
"allowImportingTsExtensions": true
},
"include": ["src"],
"exclude": ["node_modules"]
Expand Down
3 changes: 2 additions & 1 deletion vite.config.js → vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import preact from '@preact/preset-vite'

// https://vitejs.dev/config/
export default defineConfig({
base: '/preact-starter/',
// base: '/seattlejs.com/',
publicDir: 'public',
plugins: [preact()],
assetsInclude: ['**/*.md'],
})

0 comments on commit 1f75c87

Please sign in to comment.