Skip to content

Commit

Permalink
account for base path
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Feb 8, 2024
1 parent d1741d3 commit 2573d38
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
deno-version: v1.x

- name: Build
run: deno task build
run: deno task build --base-url="/projects"

- name: Setup Pages
uses: actions/configure-pages@v4
Expand Down
1 change: 1 addition & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions lib/projects/ssr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function makeRepositoryURL(repository: string) {
return `https://github.com/acmcsufoss/${repository}`;
}

function ProjectPageComponent(props: { project: Project }) {
const html = render(props.project.md, { baseUrl: "/" });
function ProjectPageComponent(props: { baseURL: string; project: Project }) {
const html = render(props.project.md, { baseUrl: props.baseURL });
return (
<main>
<Helmet>
Expand All @@ -44,7 +44,7 @@ function ProjectPreviewComponent(props: { project: Project }) {
return (
<article>
<h1>
<a href={`/${props.project.id}.html`}>{props.project.attrs?.title}</a>
<a href={`${props.project.id}.html`}>{props.project.attrs?.title}</a>
</h1>
<p>{props.project.attrs?.description}</p>
</article>
Expand Down Expand Up @@ -99,6 +99,8 @@ export function renderProjectsPageHTML(projects: Project[]) {
return renderPageHTML(<ProjectsPageComponent projects={projects} />);
}

export function renderProjectPageHTML(project: Project) {
return renderPageHTML(<ProjectPageComponent project={project} />);
export function renderProjectPageHTML(project: Project, baseURL = "/") {
return renderPageHTML(
<ProjectPageComponent project={project} baseURL={baseURL} />,
);
}
4 changes: 2 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
// in the projects directory.
async function main(args: string[]) {
const flags = parseArgs(args, {
string: ["indir", "outdir", "staticdir"],
string: ["indir", "outdir", "staticdir", "base-url"],
alias: {
indir: ["i"],
outdir: ["o"],
Expand All @@ -30,7 +30,7 @@ async function main(args: string[]) {
const projects: Project[] = [];
for await (const project of walkProjects(`${flags.indir}/*.md`)) {
projects.push(project);
const html = renderProjectPageHTML(project);
const html = renderProjectPageHTML(project, flags["base-url"]);
await Deno.writeTextFile(`${flags.outdir}/${project.id}.html`, html);
const json = JSON.stringify(project, null, 2);
await Deno.writeTextFile(`${flags.outdir}/${project.id}.json`, json);
Expand Down
1 change: 1 addition & 0 deletions projects/crying-counter.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: "Crying Counter"
repository: "crying-counter"
participants: ["Ethan", "Karni", "Jacob", "Justin", "Vamsi"]
labels: ["python"]
---
Expand Down

0 comments on commit 2573d38

Please sign in to comment.