Skip to content

Commit

Permalink
default remark layout, navitems, tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrioid committed Sep 14, 2024
1 parent 87fa208 commit 6b58127
Show file tree
Hide file tree
Showing 20 changed files with 140 additions and 105 deletions.
3 changes: 2 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import { defineConfig } from "astro/config";
import remarkEmbedImages from "remark-embed-images";

import node from "@astrojs/node";
import { setLayout } from "./src/lib/remark-default-layout";

export default defineConfig({
site: "https://andri.dk/",
integrations: [react(), tailwind(), icon()],
trailingSlash: "ignore",
markdown: {
drafts: true,
remarkPlugins: [remarkEmbedImages],
remarkPlugins: [remarkEmbedImages, setLayout],
syntaxHighlight: "shiki",
shikiConfig: { theme: "github-dark" },
},
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
"remark-embed-images": "^3.1.0",
"sanitize-html": "^2.13.0",
"simple-icons": "^13.9.0",
"tailwindcss": "~3.4.11"
"tailwindcss": "~3.4.11",
"unified": "^11.0.5",
"vfile": "^6.0.3"
},
"engines": {
"node": ">=18",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

11 changes: 8 additions & 3 deletions src/components/Nav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
import { Image } from "astro:assets";
import andratar from "../../static/img/coffee-art.jpg";
import NavItem from "./NavItem.astro";
import NavItems from "./nav-items.astro";
type Props = {
isHome: boolean;
};
const { isHome } = Astro.props;
---

<nav
Expand All @@ -21,8 +28,6 @@ import NavItem from "./NavItem.astro";
</a>

<ul class="flex space-x-y topmenu gap-2">
<NavItem href="/">Home</NavItem>
<NavItem href="/blog/">Blog</NavItem>
<NavItem href="/rss.xml">RSS</NavItem>
<NavItems isHome={isHome} />
</ul>
</nav>
13 changes: 13 additions & 0 deletions src/components/nav-items.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
import NavItem from "./NavItem.astro";
type Props = {
isHome: boolean;
};
const { isHome } = Astro.props;
---

{!isHome && <NavItem href="/">Home</NavItem>}
<NavItem href="/blog/">Blog</NavItem>
<NavItem href="/rss.xml">RSS</NavItem>
56 changes: 0 additions & 56 deletions src/layout/MarkdownLayout.astro

This file was deleted.

4 changes: 2 additions & 2 deletions src/layout/Layout.astro → src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ const ogImage = blogPost ? `/blog/${blogPost.slug}.png` : undefined;
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content={ogImage} />

<title>{title}</title>
<title>{`andri.dk | ${title}`}</title>
</head>

<body>
<body class="bg-gray-200">
<slot />
<script
data-goatcounter="https://andrioid.goatcounter.com/count"
Expand Down
37 changes: 37 additions & 0 deletions src/layouts/MarkdownLayout.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
// Find all blog posts to generate
import type { CommonBlog } from "src/lib/cms";
import Layout from "./Layout.astro";
import PagesLayout from "./PagesLayout.astro";
type Props = {
frontmatter: CommonBlog;
};
const { frontmatter: post } = Astro.props;
if (post.title === undefined)
throw new Error("Frontmatter page title missing. E.g. 'title: Moo'");
---

<Layout
title={post.title}
description={post.description}
subtitle={post.description}
blogPost={post}
>
<PagesLayout>
<div
class="pt-4 bg-gray-200 py-2 md:py-10 md:px-10 md:flex justify-center"
>
<div
class="bg-white py-10 shadow px-5 lg:px-10 flex-1 lg:max-w-6xl"
>
<article class="mb-6 prose lg:prose-lg prose-li:m-0">
<slot />
</article>

<p>&nbsp;</p>
</div>
</div>
</PagesLayout>
</Layout>
File renamed without changes.
23 changes: 23 additions & 0 deletions src/lib/remark-default-layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { VFile } from "vfile";
import type { CommonBlog } from "../cms";

// This sets our default layout even if there is no frontmatter
// - Use case: Simple pages like /now or /using
interface AstroFile extends VFile {
data: {
astro: {
frontmatter: CommonBlog & {
layout?: string;
};
};
};
}

export const setLayout = () => {
const transformer = (_, file: AstroFile) => {
file.data.astro.frontmatter.layout =
file.data.astro.frontmatter.layout ??
"@layouts/MarkdownLayout.astro";
};
return transformer;
};
4 changes: 2 additions & 2 deletions src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
// Find all blog posts to generate
import { type CollectionEntry } from "astro:content";
import Layout from "../../layout/Layout.astro";
import PagesLayout from "../../layout/PagesLayout.astro";
import Layout from "@layouts/Layout.astro";
import PagesLayout from "@layouts/PagesLayout.astro";
import { getPost } from "../../lib/cms";
import { IS_DEV } from "../../lib/utils/dev";
Expand Down
4 changes: 2 additions & 2 deletions src/pages/blog/index.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import Card from "../../components/card.astro";
import Layout from "../../layout/Layout.astro";
import PagesLayout from "../../layout/PagesLayout.astro";
import Layout from "@layouts/Layout.astro";
import PagesLayout from "@layouts/PagesLayout.astro";
import Section from "../../components/Section.astro";
import { getPosts } from "../../lib/cms";
Expand Down
15 changes: 9 additions & 6 deletions src/pages/contact/index.astro
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
import PagesLayout from "@layouts/PagesLayout.astro";
import { actions } from "astro:actions";
import Layout from "../../layout/Layout.astro";
import PagesLayout from "../../layout/PagesLayout.astro";
import { isInputError } from "astro:actions";
const result = Astro.getActionResult(actions.contactMe);
const inputErrors = isInputError(result?.error) ? result.error.fields : {}
const inputErrors = isInputError(result?.error) ? result.error.fields : {};
---

<PagesLayout title="Contact me">
<form method="post" action={actions.contactMe}>
<input class="block rounded-md border py-1 px-2" name="email" type="email" aria-describedby="error"/>
{inputErrors.email && <p id="error">{inputErrors.email.join(',')}</p>}
<input
class="block rounded-md border py-1 px-2"
name="email"
type="email"
aria-describedby="error"
/>
{inputErrors.email && <p id="error">{inputErrors.email.join(",")}</p>}
<button type="submit">Wat</button>
</form>
</PagesLayout>
2 changes: 1 addition & 1 deletion src/pages/da/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import flagIS from "../../../static/img/iceland-flag.svg";
import coffeeAndri from "../../../static/img/coffee-art.jpg";
import cvJSON from "../../../packages/cv/resume.json";
import { dataTransform } from "../../lib/cv";
import Layout from "../../layout/Layout.astro";
import BlogCards from "../../components/blog-cards.astro";
import Icon from "../../components/Icon.astro";
import { Image } from "astro:assets";
import { getPosts } from "../../lib/cms";
import Layout from "@layouts/Layout.astro";
const blogPosts = await getPosts({ limit: 6 });
const description = "Jeg udvikler og drifter softwareløsninger til alle formål";
Expand Down
17 changes: 4 additions & 13 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
import { Icon } from "astro-icon/components";
import Layout from "../layout/Layout.astro";
import Layout from "@layouts/Layout.astro";
import cv from "../../packages/cv/resume.json";
import { dataTransform } from "../lib/cv";
import ProfileIcon from "../components/profile-icon.astro";
import SkillOverview from "./_cmp/skill-overview.astro";
import NavItems from "@components/nav-items.astro";
const dt = dataTransform(cv.skills, cv.work);
---
Expand Down Expand Up @@ -55,20 +56,10 @@ const dt = dataTransform(cv.skills, cv.work);
})
}
</div>
<header class="relative z-20 p-4 flex justify-between items-center">
<header class="relative z-20 p-4 flex justify-end items-center">
<nav>
<ul class="flex space-x-y topmenu gap-2">
<li>
<a href="/blog/">Blog</a>
</li>
<!--
<li>
<a href="/using">Using</a>
</li>
<li>
<a href="/now">Now</a>
</li>
-->
<NavItems isHome={true} />
</ul>
</nav>
</header>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/is/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import flagIS from "../../../static/img/iceland-flag.svg";
import coffeeAndri from "../../../static/img/coffee-art.jpg";
import cvJSON from "../../../packages/cv/resume.json";
import { dataTransform } from "../../lib/cv";
import Layout from "../../layout/Layout.astro";
import BlogCards from "../../components/blog-cards.astro";
import Icon from "../../components/Icon.astro";
import { Image } from "astro:assets";
import { getPosts } from "../../lib/cms";
import Layout from "@layouts/Layout.astro";
const blogPosts = await getPosts({ limit: 6 });
const description = "Ég þróa og rek hugbúnað til allra nota";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/old.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import flagIS from "../../static/img/iceland-flag.svg";
import coffeeAndri from "../../static/img/coffee-art.jpg";
import cvJSON from "../../packages/cv/resume.json";
import { dataTransform } from "../lib/cv";
import Layout from "../layout/Layout.astro";
import Layout from "@layouts/Layout.astro";
import BlogCards from "../components/blog-cards.astro";
import Icon from "../components/Icon.astro";
import { Image } from "astro:assets";
Expand Down
13 changes: 0 additions & 13 deletions src/pages/test2.md

This file was deleted.

21 changes: 19 additions & 2 deletions src/pages/using.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
---
layout: "../components/MarkdownLayout.astro"
title: Using
---

# Hello
# Using

Here is a list of tools that I use. If I need to reinstall a computer, this serves as a nice document. If it helps you too, that's a bonus!

## Work

- **Computer**: Apple Macbook Pro M1 Max w. 32G RAM.

## Hobby programming

- **Computer**: Apple Macbook Air M3

## Gaming

- **Computer**: AMD Ryzen 3500 w. AMD RX 7900XT GPU, 32G RAM, 2TB SSD
- **Mouse**: Razer Basilisk V3
- **Keyboard**: Ducky One 2 RKL RGB
- **Monitor**: [Samsung 34" CF791](https://www.samsung.com/us/computing/monitors/gaming/34--cf791-wqhd-monitor-lc34f791wqnxza/)
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
"allowSyntheticDefaultImports": true,
"strict": true,
"strictFunctionTypes": true,
"strictNullChecks": true
"strictNullChecks": true,
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@layouts/*": ["src/layouts/*"]
}
},
"extends": "astro/tsconfigs/strict",
"exclude": ["packages/react-cv/dist", "dist"]
Expand Down

0 comments on commit 6b58127

Please sign in to comment.