mirror of
https://github.com/prdlk/website.git
synced 2026-08-02 17:31:41 +00:00
fix: .gitignore
This commit is contained in:
+936
-1
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 642 B After Width: | Height: | Size: 527 KiB |
@@ -1,9 +0,0 @@
|
||||
---
|
||||
title: Hello, Welcome
|
||||
description: An introduction to using the note feature in Astro Cactus
|
||||
publishDate: "2024-10-14T11:23:00Z"
|
||||
---
|
||||
|
||||
Hi, Hello. This is an example note feature included with Astro Cactus 🌵
|
||||
|
||||
They're for shorter, more concise posts that you'd like to share. They generally don't include headings, but hey, it's entirely up to you!
|
||||
@@ -1,135 +0,0 @@
|
||||
---
|
||||
title: "Markdown Admonitions"
|
||||
description: "This post showcases using the markdown admonition feature in Astro Cactus"
|
||||
publishDate: "25 Aug 2024"
|
||||
updatedDate: "4 July 2025"
|
||||
tags: ["markdown", "admonitions"]
|
||||
---
|
||||
|
||||
## What are admonitions
|
||||
|
||||
Admonitions (also known as “asides”) are useful for providing supportive and/or supplementary information related to your content.
|
||||
|
||||
## How to use them
|
||||
|
||||
To use admonitions in Astro Cactus, wrap your Markdown content in a pair of triple colons `:::`. The first pair should also include the type of admonition you want to use.
|
||||
|
||||
For example, with the following Markdown:
|
||||
|
||||
```md
|
||||
:::note
|
||||
Highlights information that users should take into account, even when skimming.
|
||||
:::
|
||||
```
|
||||
|
||||
Outputs:
|
||||
|
||||
:::note
|
||||
Highlights information that users should take into account, even when skimming.
|
||||
:::
|
||||
|
||||
## Admonition Types
|
||||
|
||||
The following admonitions are currently supported:
|
||||
|
||||
- `note`
|
||||
- `tip`
|
||||
- `important`
|
||||
- `warning`
|
||||
- `caution`
|
||||
|
||||
### Note
|
||||
|
||||
```md
|
||||
:::note
|
||||
Highlights information that users should take into account, even when skimming.
|
||||
:::
|
||||
```
|
||||
|
||||
:::note
|
||||
Highlights information that users should take into account, even when skimming.
|
||||
:::
|
||||
|
||||
### Tip
|
||||
|
||||
```md
|
||||
:::tip
|
||||
Optional information to help a user be more successful.
|
||||
:::
|
||||
```
|
||||
|
||||
:::tip
|
||||
Optional information to help a user be more successful.
|
||||
:::
|
||||
|
||||
### Important
|
||||
|
||||
```md
|
||||
:::important
|
||||
Crucial information necessary for users to succeed.
|
||||
:::
|
||||
```
|
||||
|
||||
:::important
|
||||
Crucial information necessary for users to succeed.
|
||||
:::
|
||||
|
||||
### Caution
|
||||
|
||||
```md
|
||||
:::caution
|
||||
Negative potential consequences of an action.
|
||||
:::
|
||||
```
|
||||
|
||||
:::caution
|
||||
Negative potential consequences of an action.
|
||||
:::
|
||||
|
||||
### Warning
|
||||
|
||||
```md
|
||||
:::warning
|
||||
Critical content demanding immediate user attention due to potential risks.
|
||||
:::
|
||||
```
|
||||
|
||||
:::warning
|
||||
Critical content demanding immediate user attention due to potential risks.
|
||||
:::
|
||||
|
||||
## Customising the admonition title
|
||||
|
||||
You can customise the admonition title using the following markup:
|
||||
|
||||
```md
|
||||
:::note[My custom title]
|
||||
This is a note with a custom title.
|
||||
:::
|
||||
```
|
||||
|
||||
Outputs:
|
||||
|
||||
:::note[My custom title]
|
||||
This is a note with a custom title.
|
||||
:::
|
||||
|
||||
## GitHub Repository Cards
|
||||
|
||||
You can add dynamic cards that link to GitHub repositories, on page load, the repository information is pulled from the GitHub API.
|
||||
|
||||
::github{repo="chrismwilliams/astro-theme-cactus"}
|
||||
|
||||
You can also link a Github user:
|
||||
|
||||
::github{user="withastro"}
|
||||
|
||||
To use this feature you just use the "Github" directive:
|
||||
|
||||
```markdown title="Linking a repo"
|
||||
::github{repo="chrismwilliams/astro-theme-cactus"}
|
||||
```
|
||||
|
||||
```markdown title="Linking a user"
|
||||
::github{user="withastro"}
|
||||
```
|
||||
@@ -1,174 +0,0 @@
|
||||
---
|
||||
title: "A post of Markdown elements"
|
||||
description: "This post is for testing and listing a number of different markdown elements"
|
||||
publishDate: "22 Feb 2023"
|
||||
updatedDate: 22 Jan 2024
|
||||
tags: ["test", "markdown"]
|
||||
pinned: true
|
||||
---
|
||||
|
||||
## This is a H2 Heading
|
||||
|
||||
### This is a H3 Heading
|
||||
|
||||
#### This is a H4 Heading
|
||||
|
||||
##### This is a H5 Heading
|
||||
|
||||
###### This is a H6 Heading
|
||||
|
||||
## Horizontal Rules
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Emphasis
|
||||
|
||||
**This is bold text**
|
||||
|
||||
_This is italic text_
|
||||
|
||||
~~Strikethrough~~
|
||||
|
||||
## Quotes
|
||||
|
||||
"Double quotes" and 'single quotes'
|
||||
|
||||
## Blockquotes
|
||||
|
||||
> Blockquotes can also be nested...
|
||||
>
|
||||
> > ...by using additional greater-than signs right next to each other...
|
||||
|
||||
## References
|
||||
|
||||
An example containing a clickable reference[^1] with a link to the source.
|
||||
|
||||
Second example containing a reference[^2] with a link to the source.
|
||||
|
||||
[^1]: Reference first footnote with a return to content link.
|
||||
|
||||
[^2]: Second reference with a link.
|
||||
|
||||
If you check out this example in `src/content/post/markdown-elements/index.md`, you'll notice that the references and the heading "Footnotes" are added to the bottom of the page via the [remark-rehype](https://github.com/remarkjs/remark-rehype#options) plugin.
|
||||
|
||||
## Lists
|
||||
|
||||
Unordered
|
||||
|
||||
- Create a list by starting a line with `+`, `-`, or `*`
|
||||
- Sub-lists are made by indenting 2 spaces:
|
||||
- Marker character change forces new list start:
|
||||
- Ac tristique libero volutpat at
|
||||
- Facilisis in pretium nisl aliquet
|
||||
- Nulla volutpat aliquam velit
|
||||
- Very easy!
|
||||
|
||||
Ordered
|
||||
|
||||
1. Lorem ipsum dolor sit amet
|
||||
2. Consectetur adipiscing elit
|
||||
3. Integer molestie lorem at massa
|
||||
|
||||
4. You can use sequential numbers...
|
||||
5. ...or keep all the numbers as `1.`
|
||||
|
||||
Start numbering with offset:
|
||||
|
||||
57. foo
|
||||
1. bar
|
||||
|
||||
## Code
|
||||
|
||||
Inline `code`
|
||||
|
||||
Indented code
|
||||
|
||||
// Some comments
|
||||
line 1 of code
|
||||
line 2 of code
|
||||
line 3 of code
|
||||
|
||||
Block code "fences"
|
||||
|
||||
```
|
||||
Sample text here...
|
||||
```
|
||||
|
||||
Syntax highlighting
|
||||
|
||||
```js
|
||||
var foo = function (bar) {
|
||||
return bar++;
|
||||
};
|
||||
|
||||
console.log(foo(5));
|
||||
```
|
||||
|
||||
### Expressive code examples
|
||||
|
||||
Adding a title
|
||||
|
||||
```js title="file.js"
|
||||
console.log("Title example");
|
||||
```
|
||||
|
||||
A bash terminal
|
||||
|
||||
```bash
|
||||
echo "A base terminal example"
|
||||
```
|
||||
|
||||
Highlighting code lines
|
||||
|
||||
```js title="line-markers.js" del={2} ins={3-4} {6}
|
||||
function demo() {
|
||||
console.log("this line is marked as deleted");
|
||||
// This line and the next one are marked as inserted
|
||||
console.log("this is the second inserted line");
|
||||
|
||||
return "this line uses the neutral default marker type";
|
||||
}
|
||||
```
|
||||
|
||||
[Expressive Code](https://expressive-code.com/) can do a ton more than shown here, and includes a lot of [customisation](https://expressive-code.com/reference/configuration/).
|
||||
|
||||
## Tables
|
||||
|
||||
| Option | Description |
|
||||
| ------ | ------------------------------------------------------------------------- |
|
||||
| data | path to data files to supply the data that will be passed into templates. |
|
||||
| engine | engine to be used for processing templates. Handlebars is the default. |
|
||||
| ext | extension to be used for dest files. |
|
||||
|
||||
### Table Alignment
|
||||
|
||||
| Item | Price | # In stock |
|
||||
| ------------ | :---: | ---------: |
|
||||
| Juicy Apples | 1.99 | 739 |
|
||||
| Bananas | 1.89 | 6 |
|
||||
|
||||
### Keyboard elements
|
||||
|
||||
| Action | Shortcut |
|
||||
| --------------------- | ------------------------------------------ |
|
||||
| Vertical split | <kbd>Alt+Shift++</kbd> |
|
||||
| Horizontal split | <kbd>Alt+Shift+-</kbd> |
|
||||
| Auto split | <kbd>Alt+Shift+d</kbd> |
|
||||
| Switch between splits | <kbd>Alt</kbd> + arrow keys |
|
||||
| Resizing a split | <kbd>Alt+Shift</kbd> + arrow keys |
|
||||
| Close a split | <kbd>Ctrl+Shift+W</kbd> |
|
||||
| Maximize a pane | <kbd>Ctrl+Shift+P</kbd> + Toggle pane zoom |
|
||||
|
||||
## Images
|
||||
|
||||
Image in the same folder: `src/content/post/markdown-elements/logo.png`
|
||||
|
||||

|
||||
|
||||
## Links
|
||||
|
||||
[Content from markdown-it](https://markdown-it.github.io/)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 591 KiB |
@@ -1,10 +0,0 @@
|
||||
---
|
||||
title: "Example Cover Image"
|
||||
description: "This post is an example of how to add a cover/hero image"
|
||||
publishDate: "04 July 2023"
|
||||
updatedDate: "14 August 2023"
|
||||
coverImage:
|
||||
src: "./cover.png"
|
||||
alt: "Astro build wallpaper"
|
||||
tags: ["test", "image"]
|
||||
---
|
||||
@@ -1,9 +0,0 @@
|
||||
---
|
||||
title: "A working draft title"
|
||||
description: "This post is for testing the draft post functionality"
|
||||
publishDate: "10 March 2024"
|
||||
tags: ["test"]
|
||||
draft: true
|
||||
---
|
||||
|
||||
If this is working correctly, this post should only be accessible in a dev environment, as well as any tags that are unique to this post.
|
||||
@@ -1,8 +0,0 @@
|
||||
---
|
||||
title: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Id"
|
||||
description: "This post is purely for testing if the css is correct for the title on the page"
|
||||
publishDate: "01 Feb 2023"
|
||||
tags: ["test"]
|
||||
---
|
||||
|
||||
## Testing the title tag
|
||||
@@ -1,22 +0,0 @@
|
||||
---
|
||||
title: "Example OG Social Image"
|
||||
publishDate: "27 January 2023"
|
||||
description: "An example post for Astro Cactus, detailing how to add a custom social image card in the frontmatter"
|
||||
tags: ["example", "blog", "image"]
|
||||
ogImage: "/social-card.png"
|
||||
---
|
||||
|
||||
## Adding your own social image to a post
|
||||
|
||||
This post is an example of how to add a custom [open graph](https://ogp.me/) social image, also known as an OG image, to a blog post.
|
||||
By adding the optional ogImage property to the frontmatter of a post, you opt out of [satori](https://github.com/vercel/satori) automatically generating an image for this page.
|
||||
|
||||
If you open this markdown file `src/content/post/social-image.md` you'll see the ogImage property set to an image which lives in the public folder[^1].
|
||||
|
||||
```yaml
|
||||
ogImage: "/social-card.png"
|
||||
```
|
||||
|
||||
You can view the one set for this template page [here](https://astro-cactus.chriswilliams.dev/social-card.png).
|
||||
|
||||
[^1]: The image itself can be located anywhere you like.
|
||||
@@ -1,66 +0,0 @@
|
||||
---
|
||||
title: "Adding Webmentions to Astro Cactus"
|
||||
description: "This post describes the process of adding webmentions to your own site"
|
||||
publishDate: "11 Oct 2023"
|
||||
tags: ["webmentions", "astro", "social"]
|
||||
updatedDate: 6 December 2024
|
||||
pinned: true
|
||||
---
|
||||
|
||||
## TLDR
|
||||
|
||||
1. Add a link on your homepage to either your GitHub profile and/or email address as per [IndieLogin's](https://indielogin.com/setup) instructions. You _could_ do this via `src/components/SocialList.astro`, just be sure to include `isWebmention` to the relevant link if doing so.
|
||||
2. Create an account @ [Webmention.io](https://webmention.io/) by entering your website's address.
|
||||
3. Add the link feed and api key to a `.env` file with the key `WEBMENTION_URL` and `WEBMENTION_API_KEY` respectively, you could rename `.env.example` found in this template. You can also add the optional `WEBMENTION_PINGBACK` link here too.
|
||||
4. Go to [brid.gy](https://brid.gy/) and sign-in to each social account[s] you wish to link.
|
||||
5. Publish and build your website, remember to add the api key, and it should now be ready to receive webmentions!
|
||||
|
||||
## What are webmentions
|
||||
|
||||
Put simply, it's a way to show users who like, comment, repost and more, on various pages on your website via social media.
|
||||
|
||||
This theme displays the number of likes, mentions and replies each blog post receives. There are a couple of more webmentions that I haven't included, like reposts, which are currently filtered out, but shouldn't be too difficult to include.
|
||||
|
||||
## Steps to add it to your own site
|
||||
|
||||
Your going to have to create a couple of accounts to get things up-and-running. But, the first thing you need to ensure is that your social links are correct.
|
||||
|
||||
### Add link(s) to your profile(s)
|
||||
|
||||
Firstly, you need to add a link on your site to prove ownership. If you have a look at [IndieLogin's](https://indielogin.com/setup) instructions, it gives you 2 options, either an email address and/or GitHub account. I've created the component `src/components/SocialList.astro` where you can add your details into the `socialLinks` array, just include the `isWebmention` property to the relevant link which will add the `rel="me authn"` attribute. Whichever way you do it, make sure you have a link in your markup as per IndieLogin's [instructions](https://indielogin.com/setup)
|
||||
|
||||
```html
|
||||
<a href="https://github.com/your-username" rel="me">GitHub</a>
|
||||
```
|
||||
|
||||
### Sign up to Webmention.io
|
||||
|
||||
Next, head over to [Webmention.io](https://webmention.io/) and create an account by signing in with your domain name, e.g. `https://astro-cactus.chriswilliams.dev/`. Please note that .app TLDs don't function correctly. Once in, it will give you a couple of links for your domain to accept webmentions. Make a note of these and create a `.env` file (this template include an example `.env.example` which you could rename). Add the link feed and api key with the key/values of `WEBMENTION_URL` and `WEBMENTION_API_KEY` respectively, and the optional `WEBMENTION_PINGBACK` url if required. Please try not to publish this to a repository!
|
||||
|
||||
:::note
|
||||
You don't have to include the pingback link. Maybe coincidentally, but after adding it I started to receive a higher frequency of spam in my mailbox, informing me that my website could be better. TBH they're not wrong. I've now removed it, but it's up to you.
|
||||
:::
|
||||
|
||||
### Sign up to Brid.gy
|
||||
|
||||
You're now going to have to use [brid.gy](https://brid.gy/). As the name suggests, it links your website to your social media accounts. For every account you want to set up (e.g. Mastodon), click on the relevant button and connect each account you want brid.gy to search. Just to note again, brid.gy currently has an issue with .app TLDs.
|
||||
|
||||
## Testing everything works
|
||||
|
||||
With everything set, it's now time to build and publish your website. **REMEMBER** to set your environment variables `WEBMENTION_API_KEY` & `WEBMENTION_URL` with your host.
|
||||
|
||||
You can check to see if everything is working by sending a test webmention via [webmentions.rocks](https://webmention.rocks/receive/1). Log in with your domain, enter the auth code, and then the url of the page you want to test. For example, to test this page I would add `https://astro-cactus.chriswilliams.dev/posts/webmentions/`. To view it on your website, rebuild or (re)start dev mode locally, and you should see the result at the bottom of your page.
|
||||
|
||||
You can also view any test mentions in the browser via their [api](https://github.com/aaronpk/webmention.io#api).
|
||||
|
||||
## Things to add, things to consider
|
||||
|
||||
- At the moment, fresh webmentions are only fetched on a rebuild or restarting dev mode, which obviously means if you don't update your site very often you wont get a lot of new content. It should be quite trivial to add a cron job to run the `getAndCacheWebmentions()` function in `src/utils/webmentions.ts` and populate your blog with new content. This is probably what I'll add next as a github action.
|
||||
|
||||
- I have seen some mentions have duplicates. Unfortunately, they're quite difficult to filter out as they have different id's.
|
||||
|
||||
- I'm not a huge fan of the little external link icon for linking to comments/replies. It's not particularly great on mobile due to its size, and will likely change it in the future.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Many thanks to [Kieran McGuire](https://github.com/chrismwilliams/astro-theme-cactus/issues/107#issue-1863931105) for sharing this with me, and the helpful posts. I'd never heard of webmentions before, and now with this update hopefully others will be able to make use of them. Additionally, articles and examples from [kld](https://kld.dev/adding-webmentions/) and [ryanmulligan.dev](https://ryanmulligan.dev/blog/) really helped in getting this set up and integrated, both a great resource if you're looking for more information!
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: Test Tag
|
||||
description: This tag is used for testing various features of the theme.
|
||||
---
|
||||
|
||||
This is an example of a custom intro on a tag page. Its markdown can be found in `src/content/tag/test.md`.
|
||||
|
||||
This collection includes posts that demonstrate and test different features of the Astro Theme Cactus, including:
|
||||
|
||||
- Markdown rendering capabilities
|
||||
- Image handling and optimization
|
||||
- Table of contents generation
|
||||
- Various edge cases and scenarios
|
||||
|
||||
Feel free to explore these posts to understand how the theme handles different content types and configurations.
|
||||
+34
-34
@@ -1,52 +1,49 @@
|
||||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import PostPreview from "@/components/blog/PostPreview.astro";
|
||||
import Note from "@/components/note/Note.astro";
|
||||
import Project from "@/components/project/Project.astro";
|
||||
import SocialList from "@/components/SocialList.astro";
|
||||
import { getAllPosts } from "@/data/post";
|
||||
import { getAllSpeaking } from "@/data/speaking";
|
||||
import PageLayout from "@/layouts/Base.astro";
|
||||
import { collectionDateSort } from "@/utils/date";
|
||||
|
||||
// Posts
|
||||
const MAX_POSTS = 10;
|
||||
const MAX_POSTS = 5;
|
||||
const allPosts = await getAllPosts();
|
||||
const allPostsByDate = allPosts.sort(collectionDateSort) as CollectionEntry<"post">[];
|
||||
const latestPosts = allPostsByDate.slice(0, MAX_POSTS);
|
||||
const latestPosts = (allPosts.sort(collectionDateSort) as CollectionEntry<"writing">[]).slice(
|
||||
0,
|
||||
MAX_POSTS,
|
||||
);
|
||||
|
||||
// Pinned Posts, set to a max of 3;
|
||||
const MAX_PINNED_POSTS = 3;
|
||||
const pinnedPosts = allPostsByDate
|
||||
.values()
|
||||
.filter((p) => p.data.pinned)
|
||||
.take(MAX_PINNED_POSTS)
|
||||
.toArray();
|
||||
|
||||
// Notes, set to a max of 5
|
||||
const MAX_NOTES = 5;
|
||||
const allNotes = await getCollection("note");
|
||||
const latestNotes = allNotes
|
||||
const MAX_PROJECTS = 3;
|
||||
const allProjects = await getCollection("projects");
|
||||
const latestProjects = allProjects
|
||||
.sort(collectionDateSort)
|
||||
.slice(0, MAX_NOTES) as CollectionEntry<"note">[];
|
||||
.slice(0, MAX_PROJECTS) as CollectionEntry<"projects">[];
|
||||
|
||||
const MAX_TALKS = 3;
|
||||
const latestTalks = (await getAllSpeaking()).sort(collectionDateSort).slice(0, MAX_TALKS);
|
||||
---
|
||||
|
||||
<PageLayout meta={{ title: "Home" }}>
|
||||
<section>
|
||||
<h1 class="title mb-12">Hello World!</h1>
|
||||
<h1 class="title mb-6">Prad Nukala</h1>
|
||||
<p class="mb-4">
|
||||
Hi, I’m a theme for Astro, a simple starter that you can use to create your website or blog.
|
||||
If you want to know more about how you can customise me, add more posts, and make it your own,
|
||||
click on the GitHub icon link below and it will take you to my repo.
|
||||
Engineer and founder. I build decentralized identity infrastructure and tools for developers.
|
||||
Here you'll find what I've built, where I've worked, what I write, and the talks I've given.
|
||||
</p>
|
||||
<SocialList />
|
||||
</section>
|
||||
{
|
||||
pinnedPosts.length > 0 && (
|
||||
latestProjects.length > 0 && (
|
||||
<section class="mt-16">
|
||||
<h2 class="title mb-6 text-xl">Pinned Posts</h2>
|
||||
<ul class="space-y-4" role="list">
|
||||
{pinnedPosts.map((p) => (
|
||||
<li class="grid gap-1 sm:grid-cols-[auto_1fr]">
|
||||
<PostPreview post={p} />
|
||||
<h2 class="title text-accent mb-6 text-xl">
|
||||
<a href="/projects/">Projects</a>
|
||||
</h2>
|
||||
<ul class="space-y-6" role="list">
|
||||
{latestProjects.map((project) => (
|
||||
<li>
|
||||
<Project project={project} as="h3" isPreview />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -54,7 +51,7 @@ const latestNotes = allNotes
|
||||
)
|
||||
}
|
||||
<section class="mt-16">
|
||||
<h2 class="title text-accent mb-6 text-xl"><a href="/posts/">Posts</a></h2>
|
||||
<h2 class="title text-accent mb-6 text-xl"><a href="/writing/">Writing</a></h2>
|
||||
<ul class="space-y-4" role="list">
|
||||
{
|
||||
latestPosts.map((p) => (
|
||||
@@ -66,15 +63,18 @@ const latestNotes = allNotes
|
||||
</ul>
|
||||
</section>
|
||||
{
|
||||
latestNotes.length > 0 && (
|
||||
latestTalks.length > 0 && (
|
||||
<section class="mt-16">
|
||||
<h2 class="title text-accent mb-6 text-xl">
|
||||
<a href="/notes/">Notes</a>
|
||||
<a href="/speaking/">Speaking</a>
|
||||
</h2>
|
||||
<ul class="space-y-6" role="list">
|
||||
{latestNotes.map((note) => (
|
||||
<ul class="space-y-4" role="list">
|
||||
{latestTalks.map((talk) => (
|
||||
<li>
|
||||
<Note note={note} as="h3" isPreview />
|
||||
<a class="cactus-link" href={`/speaking/${talk.id}/`}>
|
||||
{talk.data.title}
|
||||
</a>
|
||||
{talk.data.event && <span class="text-muted text-sm"> · {talk.data.event}</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import type { GetStaticPaths, Page } from "astro";
|
||||
import { Icon } from "astro-icon/components";
|
||||
import Note from "@/components/note/Note.astro";
|
||||
import Pagination from "@/components/Paginator.astro";
|
||||
import PageLayout from "@/layouts/Base.astro";
|
||||
import { collectionDateSort } from "@/utils/date";
|
||||
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
const MAX_NOTES_PER_PAGE = 10;
|
||||
const allNotes = await getCollection("note");
|
||||
return paginate(allNotes.sort(collectionDateSort), { pageSize: MAX_NOTES_PER_PAGE });
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
interface Props {
|
||||
page: Page<CollectionEntry<"note">>;
|
||||
uniqueTags: string[];
|
||||
}
|
||||
|
||||
const { page } = Astro.props;
|
||||
|
||||
const meta = {
|
||||
description: "Read my collection of notes",
|
||||
title: "Notes",
|
||||
};
|
||||
|
||||
const paginationProps = {
|
||||
...(page.url.prev && {
|
||||
prevUrl: {
|
||||
text: "← Previous Page",
|
||||
url: page.url.prev,
|
||||
},
|
||||
}),
|
||||
...(page.url.next && {
|
||||
nextUrl: {
|
||||
text: "Next Page →",
|
||||
url: page.url.next,
|
||||
},
|
||||
}),
|
||||
};
|
||||
---
|
||||
|
||||
<PageLayout meta={meta}>
|
||||
<section>
|
||||
<h1 class="title mb-12 flex items-center gap-3">
|
||||
Notes <a class="text-accent" href="/notes/rss.xml" target="_blank">
|
||||
<span class="sr-only">RSS feed</span>
|
||||
<Icon aria-hidden="true" class="h-6 w-6" focusable="false" name="mdi:rss" />
|
||||
</a>
|
||||
</h1>
|
||||
<ul class="mt-6 space-y-8 text-start">
|
||||
{
|
||||
page.data.map((note) => (
|
||||
<li class="">
|
||||
<Note note={note} as="h2" isPreview />
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
<Pagination {...paginationProps} />
|
||||
</section>
|
||||
</PageLayout>
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
import { getCollection } from "astro:content";
|
||||
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
|
||||
import Note from "@/components/note/Note.astro";
|
||||
import PageLayout from "@/layouts/Base.astro";
|
||||
|
||||
// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr
|
||||
export const getStaticPaths = (async () => {
|
||||
const allNotes = await getCollection("note");
|
||||
return allNotes.map((note) => ({
|
||||
params: { slug: note.id },
|
||||
props: { note },
|
||||
}));
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
export type Props = InferGetStaticPropsType<typeof getStaticPaths>;
|
||||
|
||||
const { note } = Astro.props;
|
||||
|
||||
const meta = {
|
||||
description:
|
||||
note.data.description ||
|
||||
`Read about my note posted on: ${note.data.publishDate.toLocaleDateString()}`,
|
||||
title: note.data.title,
|
||||
};
|
||||
---
|
||||
|
||||
<PageLayout meta={meta}>
|
||||
<Note as="h1" note={note} />
|
||||
</PageLayout>
|
||||
@@ -1,18 +0,0 @@
|
||||
import { getCollection } from "astro:content";
|
||||
import rss from "@astrojs/rss";
|
||||
import { siteConfig } from "@/site.config";
|
||||
|
||||
export const GET = async () => {
|
||||
const notes = await getCollection("note");
|
||||
|
||||
return rss({
|
||||
title: siteConfig.title,
|
||||
description: siteConfig.description,
|
||||
site: import.meta.env.SITE,
|
||||
items: notes.map((note) => ({
|
||||
title: note.data.title,
|
||||
pubDate: note.data.publishDate,
|
||||
link: `notes/${note.id}/`,
|
||||
})),
|
||||
});
|
||||
};
|
||||
@@ -1,147 +0,0 @@
|
||||
---
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import type { GetStaticPaths, Page } from "astro";
|
||||
import { Icon } from "astro-icon/components";
|
||||
import PostPreview from "@/components/blog/PostPreview.astro";
|
||||
import Pagination from "@/components/Paginator.astro";
|
||||
import { getAllPosts, getUniqueTags, groupPostsByYear } from "@/data/post";
|
||||
import PageLayout from "@/layouts/Base.astro";
|
||||
import { collectionDateSort } from "@/utils/date";
|
||||
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
const MAX_POSTS_PER_PAGE = 10;
|
||||
const MAX_TAGS = 7;
|
||||
const MAX_PINNED_POSTS = 3;
|
||||
const allPosts = await getAllPosts();
|
||||
const allPostsByDate = allPosts.sort(collectionDateSort);
|
||||
const uniqueTags = getUniqueTags(allPosts).slice(0, MAX_TAGS);
|
||||
const pinnedPosts = allPostsByDate
|
||||
.values()
|
||||
.filter((p) => p.data.pinned)
|
||||
.take(MAX_PINNED_POSTS)
|
||||
.toArray();
|
||||
return paginate(allPostsByDate, {
|
||||
pageSize: MAX_POSTS_PER_PAGE,
|
||||
props: { uniqueTags, pinnedPosts },
|
||||
});
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
interface Props {
|
||||
page: Page<CollectionEntry<"post">>;
|
||||
uniqueTags: string[];
|
||||
pinnedPosts: CollectionEntry<"post">[];
|
||||
}
|
||||
|
||||
const { page, uniqueTags, pinnedPosts } = Astro.props;
|
||||
|
||||
const meta = {
|
||||
description: "Read my collection of posts and the things that interest me",
|
||||
title: "Posts",
|
||||
};
|
||||
|
||||
const paginationProps = {
|
||||
...(page.url.prev && {
|
||||
prevUrl: {
|
||||
text: "← Previous Page",
|
||||
url: page.url.prev,
|
||||
},
|
||||
}),
|
||||
...(page.url.next && {
|
||||
nextUrl: {
|
||||
text: "Next Page →",
|
||||
url: page.url.next,
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const groupedByYear = groupPostsByYear(page.data);
|
||||
const descYearKeys = Object.keys(groupedByYear).sort((a, b) => +b - +a);
|
||||
---
|
||||
|
||||
<PageLayout meta={meta}>
|
||||
<div class="mb-12 flex items-center gap-3">
|
||||
<h1 class="title">Posts</h1>
|
||||
<a class="text-accent" href="/rss.xml" target="_blank">
|
||||
<span class="sr-only">RSS feed</span>
|
||||
<Icon aria-hidden="true" class="h-6 w-6" focusable="false" name="mdi:rss" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="grid sm:grid-cols-[3fr_1fr] sm:gap-x-8 sm:gap-y-16">
|
||||
<div>
|
||||
{
|
||||
pinnedPosts.length > 0 && (
|
||||
<section class="mb-16">
|
||||
<h2 class="title mb-6 text-xl">Pinned Posts</h2>
|
||||
<ul class="space-y-4" role="list">
|
||||
{pinnedPosts.map((p) => (
|
||||
<li class="grid gap-1 sm:grid-cols-[auto_1fr]">
|
||||
<PostPreview post={p} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
{
|
||||
descYearKeys.map((yearKey) => (
|
||||
<section class="mb-16">
|
||||
<h2 id={`year-${yearKey}`} class="title text-lg">
|
||||
<span class="sr-only">Posts in</span>
|
||||
{yearKey}
|
||||
</h2>
|
||||
<ul class="mt-5 space-y-4 text-start">
|
||||
{groupedByYear[yearKey]?.map((p) => (
|
||||
<li class="grid gap-1 sm:grid-cols-[auto_1fr] sm:[&_q]:col-start-2">
|
||||
<PostPreview post={p} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
))
|
||||
}
|
||||
<Pagination {...paginationProps} />
|
||||
</div>
|
||||
{
|
||||
!!uniqueTags.length && (
|
||||
<aside>
|
||||
<h2 class="title mb-4 flex items-center gap-1 text-lg">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="h-6 w-6"
|
||||
fill="none"
|
||||
stroke="var(--color-muted)"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="1.5"
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path d="M0 0h24v24H0z" fill="none" stroke="none" />
|
||||
<path d="M7.859 6h-2.834a2.025 2.025 0 0 0 -2.025 2.025v2.834c0 .537 .213 1.052 .593 1.432l6.116 6.116a2.025 2.025 0 0 0 2.864 0l2.834 -2.834a2.025 2.025 0 0 0 0 -2.864l-6.117 -6.116a2.025 2.025 0 0 0 -1.431 -.593z" />
|
||||
<path d="M17.573 18.407l2.834 -2.834a2.025 2.025 0 0 0 0 -2.864l-7.117 -7.116" />
|
||||
<path d="M6 9h-.01" />
|
||||
</svg>
|
||||
Tags
|
||||
</h2>
|
||||
<ul class="flex flex-wrap gap-2">
|
||||
{uniqueTags.map((tag) => (
|
||||
<li>
|
||||
<a class="cactus-link flex items-center justify-center" href={`/tags/${tag}/`}>
|
||||
<span aria-hidden="true">#</span>
|
||||
<span class="sr-only">View all posts with the tag</span>
|
||||
{tag}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<span class="mt-4 block sm:text-end">
|
||||
<a class="hover:text-link" href="/tags/">
|
||||
View all <span aria-hidden="true">→</span>
|
||||
<span class="sr-only">blog tags</span>
|
||||
</a>
|
||||
</span>
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</PageLayout>
|
||||
@@ -1,24 +0,0 @@
|
||||
---
|
||||
import { render } from "astro:content";
|
||||
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
|
||||
import { getAllPosts } from "@/data/post";
|
||||
import PostLayout from "@/layouts/BlogPost.astro";
|
||||
|
||||
// if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr
|
||||
export const getStaticPaths = (async () => {
|
||||
const blogEntries = await getAllPosts();
|
||||
return blogEntries.map((post) => ({
|
||||
params: { slug: post.id },
|
||||
props: { post },
|
||||
}));
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
|
||||
|
||||
const { post } = Astro.props;
|
||||
const { Content } = await render(post);
|
||||
---
|
||||
|
||||
<PostLayout post={post}>
|
||||
<Content />
|
||||
</PostLayout>
|
||||
@@ -13,7 +13,7 @@ export const GET = async () => {
|
||||
title: post.data.title,
|
||||
description: post.data.description,
|
||||
pubDate: post.data.publishDate,
|
||||
link: `posts/${post.id}/`,
|
||||
link: `writing/${post.id}/`,
|
||||
})),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
---
|
||||
import { render } from "astro:content";
|
||||
import type { GetStaticPaths, InferGetStaticPropsType } from "astro";
|
||||
import { Icon } from "astro-icon/components";
|
||||
import PostPreview from "@/components/blog/PostPreview.astro";
|
||||
import Pagination from "@/components/Paginator.astro";
|
||||
import { getAllPosts, getTagMeta, getUniqueTags } from "@/data/post";
|
||||
import PageLayout from "@/layouts/Base.astro";
|
||||
import { collectionDateSort } from "@/utils/date";
|
||||
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
const allPosts = await getAllPosts();
|
||||
const sortedPosts = allPosts.sort(collectionDateSort);
|
||||
const uniqueTags = getUniqueTags(sortedPosts);
|
||||
|
||||
return uniqueTags.flatMap((tag) => {
|
||||
const postsWithTag = sortedPosts.filter((post) => post.data.tags.includes(tag));
|
||||
return paginate(postsWithTag, {
|
||||
pageSize: 10,
|
||||
params: { tag },
|
||||
});
|
||||
});
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
|
||||
|
||||
const { page } = Astro.props as Props;
|
||||
const { tag } = Astro.params;
|
||||
const tagMeta = await getTagMeta(tag);
|
||||
|
||||
const TagContent = tagMeta ? (await render(tagMeta)).Content : null;
|
||||
|
||||
const meta = {
|
||||
description: tagMeta?.data.description ?? `View all posts with the tag - ${tag}`,
|
||||
title: tagMeta?.data.title ?? `Posts about ${tag}`,
|
||||
};
|
||||
|
||||
const paginationProps = {
|
||||
...(page.url.prev && {
|
||||
prevUrl: {
|
||||
text: "← Previous Tags",
|
||||
url: page.url.prev,
|
||||
},
|
||||
}),
|
||||
...(page.url.next && {
|
||||
nextUrl: {
|
||||
text: "Next Tags →",
|
||||
url: page.url.next,
|
||||
},
|
||||
}),
|
||||
};
|
||||
---
|
||||
|
||||
<PageLayout meta={meta}>
|
||||
<nav class="mb-8" aria-label="Breadcrumbs">
|
||||
<ul class="flex items-center">
|
||||
<li class="flex items-center">
|
||||
<a class="text-accent" href="/tags/">Tags</a>
|
||||
<Icon aria-hidden="true" name="mdi:chevron-right" class="mx-1.5" />
|
||||
</li>
|
||||
<li aria-current="page" class=""><span aria-hidden="true">#</span>{tag}</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<h1 class="title capitalize">{tagMeta?.data.title ?? `Posts about ${tag}`}</h1>
|
||||
<div class="prose prose-sm prose-cactus mb-16 max-w-none">
|
||||
{tagMeta?.data.description && <p>{tagMeta.data.description}</p>}
|
||||
{TagContent && <TagContent />}
|
||||
</div>
|
||||
<ul class="space-y-4">
|
||||
{
|
||||
page.data.map((p) => (
|
||||
<li class="grid gap-1 sm:grid-cols-[auto_1fr]">
|
||||
<PostPreview as="h2" post={p} />
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
<Pagination {...paginationProps} />
|
||||
</PageLayout>
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
import { getAllPosts, getUniqueTagsWithCount } from "@/data/post";
|
||||
import PageLayout from "@/layouts/Base.astro";
|
||||
|
||||
const allPosts = await getAllPosts();
|
||||
const allTags = getUniqueTagsWithCount(allPosts);
|
||||
|
||||
const meta = {
|
||||
description: "A list of all the topics I've written about in my posts",
|
||||
title: "All Tags",
|
||||
};
|
||||
---
|
||||
|
||||
<PageLayout meta={meta}>
|
||||
<h1 class="title mb-6">Tags</h1>
|
||||
<ul class="space-y-4">
|
||||
{
|
||||
allTags.map(([tag, val]) => (
|
||||
<li class="flex items-center gap-x-2">
|
||||
<a
|
||||
class="cactus-link inline-block"
|
||||
href={`/tags/${tag}/`}
|
||||
title={`View posts with the tag: ${tag}`}
|
||||
>
|
||||
#{tag}
|
||||
</a>
|
||||
<span class="inline-block">
|
||||
- {val} Post{val > 1 && "s"}
|
||||
</span>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</PageLayout>
|
||||
+27
-24
@@ -3,22 +3,12 @@ import type { SiteConfig } from "@/types";
|
||||
|
||||
export const siteConfig: SiteConfig = {
|
||||
// ! Please remember to replace the following site property with your own domain, used in astro.config.ts
|
||||
url: "https://astro-cactus.chriswilliams.dev/",
|
||||
/*
|
||||
- Used to construct the meta title property found in src/components/BaseHead.astro L:11
|
||||
- The webmanifest name found in astro.config.ts L:42
|
||||
- The link value found in src/components/layout/Header.astro L:35
|
||||
- In the footer found in src/components/layout/Footer.astro L:12
|
||||
*/
|
||||
title: "Astro Cactus",
|
||||
// Used as both a meta property (src/components/BaseHead.astro L:31 + L:49) & the generated satori png (src/pages/og-image/[slug].png.ts)
|
||||
author: "Chris Williams",
|
||||
// Used as the default description meta property and webmanifest description
|
||||
description: "An opinionated starter theme for Astro",
|
||||
// HTML lang property, found in src/layouts/Base.astro L:18 & astro.config.ts L:48
|
||||
lang: "en-GB",
|
||||
// Meta property, found in src/components/BaseHead.astro L:42
|
||||
ogLocale: "en_GB",
|
||||
url: "https://prad.nu/",
|
||||
title: "Prad Nukala",
|
||||
author: "Prad Nukala",
|
||||
description: "Engineer & founder. Projects, experience, writing and talks.",
|
||||
lang: "en-US",
|
||||
ogLocale: "en_US",
|
||||
// Date.prototype.toLocaleDateString() parameters, found in src/utils/date.ts.
|
||||
date: {
|
||||
locale: "en-GB",
|
||||
@@ -30,24 +20,37 @@ export const siteConfig: SiteConfig = {
|
||||
},
|
||||
};
|
||||
|
||||
// Origin that serves Cloudflare Stream embeds. Set to your Worker/custom domain
|
||||
// or the account's `customer-<CODE>.cloudflarestream.com` subdomain.
|
||||
// The Stream player iframe is loaded from `${streamOrigin}/<videoId>/iframe`.
|
||||
export const streamOrigin = "https://customer-CODE.cloudflarestream.com";
|
||||
|
||||
// Used to generate links in both the Header & Footer.
|
||||
export const menuLinks: { path: string; title: string }[] = [
|
||||
{
|
||||
path: "/",
|
||||
title: "Home",
|
||||
},
|
||||
{
|
||||
path: "/projects/",
|
||||
title: "Projects",
|
||||
},
|
||||
{
|
||||
path: "/experience/",
|
||||
title: "Experience",
|
||||
},
|
||||
{
|
||||
path: "/writing/",
|
||||
title: "Writing",
|
||||
},
|
||||
{
|
||||
path: "/speaking/",
|
||||
title: "Speaking",
|
||||
},
|
||||
{
|
||||
path: "/about/",
|
||||
title: "About",
|
||||
},
|
||||
{
|
||||
path: "/posts/",
|
||||
title: "Blog",
|
||||
},
|
||||
{
|
||||
path: "/notes/",
|
||||
title: "Notes",
|
||||
},
|
||||
];
|
||||
|
||||
// https://expressive-code.com/reference/configuration/
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ export function getFormattedDate(
|
||||
}
|
||||
|
||||
export function collectionDateSort(
|
||||
a: CollectionEntry<"post" | "note">,
|
||||
b: CollectionEntry<"post" | "note">,
|
||||
a: CollectionEntry<"writing" | "projects">,
|
||||
b: CollectionEntry<"writing" | "projects">,
|
||||
) {
|
||||
return b.data.publishDate.getTime() - a.data.publishDate.getTime();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user