Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Personal website for Andy Meier built with F#, Giraffe, Datastar, and Tailwind C
## Structure

- `app/` - F# web application
- `src/App/` - Main application (Giraffe + Datastar)
- `src/App/` - Main application and FSharp.ViewEngine article source
- `src/Build/` - FAKE build script
- `src/Tests/` - Expecto tests
- `pulumi/` - Infrastructure as code (GCP Artifact Registry, Cloudflare, Kubernetes)
- `pulumi/` - Infrastructure as code (Cloudflare and Kubernetes)

## Development

Expand All @@ -21,7 +21,15 @@ dotnet paket restore
./fake.sh Watch
```

`Watch` starts a local MockNotion service with fictional articles, so normal local development does not require Notion credentials or a Pulumi ESC environment.
Articles are authored directly in `app/src/App/src/Articles/Posts` with FSharp.ViewEngine. `Watch` uses those source-controlled articles and requires no content-service credentials.

## Publishing articles

1. Add a post module under `app/src/App/src/Articles/Posts` and register it in `Articles/Catalog.fs`.
2. Upload article images to `gs://assets.meiermade.com/andymeier/articles/<permalink>/` using content-hashed filenames.
3. Reference each image's `https://assets.meiermade.com/andymeier/...` URL from the post.

Article assets are manually published and cached, so changing an image requires a new filename.

## Testing

Expand Down
12 changes: 12 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ The above copyright notice and this permission notice shall be included in all c

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## Mermaid 11.16.0

Source: https://github.com/mermaid-js/mermaid

Copyright (c) 2014 - 2022 Knut Sveidqvist

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## PrismJS 1.29.0

Source: https://github.com/PrismJS/prism
Expand Down
2 changes: 0 additions & 2 deletions app/andrewmeier.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<Folder Name="/src/">
<Project Path="src/App/App.fsproj" />
<Project Path="src/Build/Build.fsproj" />
<Project Path="src/Domain/Domain.fsproj" />
<Project Path="src/MockNotion/MockNotion.fsproj" />
<Project Path="src/Tests/Tests.fsproj" />
</Folder>
</Solution>
9 changes: 0 additions & 9 deletions app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
services:
mock-notion:
build:
context: .
dockerfile: src/MockNotion/Dockerfile
ports:
- "127.0.0.1:5015:5015"
environment:
MOCK_NOTION_URL: http://0.0.0.0:5015

seq:
image: datalust/seq:2024.3
environment:
Expand Down
4 changes: 0 additions & 4 deletions app/paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
source https://api.nuget.org/v3/index.json
storage: none

nuget FSharp.SystemTextJson
nuget FSharp.ViewEngine
nuget FSharp.UMX
nuget FsToolkit.ErrorHandling
nuget FsToolkit.ErrorHandling.TaskResult
nuget Giraffe
nuget Markdig
nuget Serilog
nuget Serilog.AspNetCore
nuget Serilog.Sinks.Seq
nuget Serilog.Sinks.Console
nuget Serilog.Sinks.OpenTelemetry
nuget Starfederation.Datastar
nuget Microsoft.Data.Sqlite
nuget OpenTelemetry
nuget OpenTelemetry.Extensions.Hosting
nuget OpenTelemetry.Instrumentation.AspNetCore
Expand Down
24 changes: 2 additions & 22 deletions app/paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ STORAGE: NONE
NUGET
remote: https://api.nuget.org/v3/index.json
FSharp.Core (10.1.302) - restriction: >= netstandard2.0
FSharp.SystemTextJson (1.4.36)
FSharp.SystemTextJson (1.4.36) - restriction: >= net6.0
FSharp.Core (>= 4.7) - restriction: >= netstandard2.0
System.Text.Json (>= 6.0.10) - restriction: >= netstandard2.0
FSharp.UMX (1.1)
FSharp.Core (>= 4.3.4) - restriction: >= netstandard2.0
FSharp.ViewEngine (2026.8)
FSharp.Core (>= 10.0.102) - restriction: >= net8.0
JetBrains.Annotations (>= 2025.2.4) - restriction: >= net8.0
Expand Down Expand Up @@ -39,8 +37,6 @@ NUGET
Grpc.Core.Api (>= 2.83) - restriction: >= netstandard2.0
Microsoft.Bcl.AsyncInterfaces (>= 8.0) - restriction: && (>= netstandard2.0) (< netstandard2.1)
JetBrains.Annotations (2026.2) - restriction: >= net8.0
Markdig (1.3.2)
System.Memory (>= 4.6.3) - restriction: || (>= net462) (&& (>= netstandard2.0) (< netstandard2.1))
Microsoft.AspNetCore.Hosting.Abstractions (2.3.11) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.1)) (&& (>= netstandard2.0) (< netstandard2.1))
Microsoft.AspNetCore.Hosting.Server.Abstractions (>= 2.3.10) - restriction: >= netstandard2.0
Microsoft.AspNetCore.Http.Abstractions (>= 2.3.10) - restriction: >= netstandard2.0
Expand All @@ -57,12 +53,6 @@ NUGET
Microsoft.Bcl.AsyncInterfaces (10.0.10) - restriction: || (>= net462) (&& (>= net6.0) (< net8.0)) (&& (>= net6.0) (< netstandard2.1)) (&& (>= netstandard2.0) (< netstandard2.1))
System.Threading.Tasks.Extensions (>= 4.6.3) - restriction: || (>= net462) (&& (>= netstandard2.0) (< netstandard2.1))
Microsoft.Bcl.HashCode (6.0) - restriction: || (&& (>= net462) (>= net6.0)) (&& (>= net462) (< netstandard2.0)) (>= net471)
Microsoft.Data.Sqlite (10.0.10)
Microsoft.Data.Sqlite.Core (>= 10.0.10) - restriction: >= netstandard2.0
SQLitePCLRaw.bundle_e_sqlite3 (>= 2.1.11) - restriction: >= netstandard2.0
SQLitePCLRaw.core (>= 2.1.11) - restriction: >= netstandard2.0
Microsoft.Data.Sqlite.Core (10.0.10) - restriction: >= netstandard2.0
SQLitePCLRaw.core (>= 2.1.11) - restriction: >= netstandard2.0
Microsoft.Extensions.Configuration (10.0.10) - restriction: || (>= net462) (&& (>= net8.0) (< net9.0)) (>= netstandard2.0)
Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10) - restriction: || (>= net462) (>= netstandard2.0)
Microsoft.Extensions.Primitives (>= 10.0.10) - restriction: || (>= net462) (>= netstandard2.0)
Expand Down Expand Up @@ -227,16 +217,6 @@ NUGET
Serilog.Sinks.Seq (9.1)
Serilog (>= 4.3.1) - restriction: >= netstandard2.0
Serilog.Sinks.File (>= 7.0) - restriction: >= netstandard2.0
SQLite (3.53.4) - restriction: >= netstandard2.0
SQLitePCLRaw.bundle_e_sqlite3 (3.0.5) - restriction: >= netstandard2.0
SQLite (>= 3.53.4) - restriction: >= netstandard2.0
SQLitePCLRaw.config.e_sqlite3 (>= 3.0.5) - restriction: >= netstandard2.0
SQLitePCLRaw.config.e_sqlite3 (3.0.5) - restriction: >= netstandard2.0
SQLitePCLRaw.provider.e_sqlite3 (>= 3.0.5) - restriction: >= netstandard2.0
SQLitePCLRaw.core (3.0.5) - restriction: >= netstandard2.0
System.Memory (>= 4.6.3) - restriction: && (< net8.0) (>= netstandard2.0)
SQLitePCLRaw.provider.e_sqlite3 (3.0.5) - restriction: >= netstandard2.0
SQLitePCLRaw.core (>= 3.0.5) - restriction: >= netstandard2.0
StarFederation.Datastar (1.4)
StarFederation.Datastar.FSharp (>= 1.4) - restriction: >= net8.0
StarFederation.Datastar.FSharp (1.4) - restriction: >= net8.0
Expand Down Expand Up @@ -264,7 +244,7 @@ NUGET
System.Buffers (>= 4.6.1) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0))
System.Memory (>= 4.6.3) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0))
System.Runtime.CompilerServices.Unsafe (>= 6.1.2) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0))
System.Text.Json (10.0.10) - restriction: || (&& (< net10.0) (>= net9.0)) (>= net462) (&& (>= net8.0) (< net9.0)) (>= netstandard2.0)
System.Text.Json (10.0.10) - restriction: || (&& (< net10.0) (>= net9.0)) (>= net462) (>= net6.0) (&& (>= net8.0) (< net9.0)) (&& (< net8.0) (>= netstandard2.0))
Microsoft.Bcl.AsyncInterfaces (>= 10.0.10) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0))
System.Buffers (>= 4.6.1) - restriction: || (>= net462) (&& (< net8.0) (>= netstandard2.0))
System.IO.Pipelines (>= 10.0.10) - restriction: || (&& (< net10.0) (>= net9.0)) (>= net462) (&& (>= net8.0) (< net9.0)) (&& (< net8.0) (>= netstandard2.0))
Expand Down
10 changes: 7 additions & 3 deletions app/src/App/App.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@
<Content Include="paket.references" />
<Compile Include="src/Infrastructure.fs" />
<Compile Include="src/Config.fs" />
<Compile Include="src/Telemetry.fs" />
<Compile Include="src/Services.fs" />
<Compile Include="src/Articles/Article.fs" />
<Compile Include="src/Common/View.fs" />
<Compile Include="src/Common/Handler.fs" />
<Compile Include="src/Articles/Shared.fs" />
<Compile Include="src/Articles/Posts/FSharpSemanticKernel.fs" />
<Compile Include="src/Articles/Posts/PersonalInfrastructure.fs" />
<Compile Include="src/Articles/Posts/DevelopmentEnvironment.fs" />
<Compile Include="src/Articles/Catalog.fs" />
<Compile Include="src/Articles/View.fs" />
<Compile Include="src/Articles/Handler.fs" />
<Compile Include="src/Index/View.fs" />
<Compile Include="src/Index/Handler.fs" />
<Compile Include="src/Program.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.fsproj" />
</ItemGroup>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
42 changes: 39 additions & 3 deletions app/src/App/input.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,44 @@
@plugin "@tailwindcss/typography";
@custom-variant dark (&:where(.dark, .dark *));

/* Inline code: monospace fonts render larger at the same font-size,
so scale down to visually match surrounding body text. */
.prose :where(code):not(:where(pre *)) {
.article-scroll-progress {
display: none;
}

#top-nav {
position: sticky;
top: 0;
z-index: 40;
}

body:has([data-article-page]) .article-scroll-progress {
display: block;
}

/* Monospace fonts render larger at the same font-size,
so scale code down to visually match surrounding body text. */
.prose code[class*="language-"] {
font-size: 0.875em;
}

.prose :not(pre) > code[class*="language-"] {
overflow-wrap: anywhere;
}

.article-mermaid svg {
min-width: 40rem;
max-width: none;
height: auto;
}

[data-container-view] .article-mermaid svg,
[data-deployment-view] .article-mermaid svg {
min-width: 56rem;
}

@media (min-width: 768px) {
.article-mermaid svg {
min-width: 0;
max-width: 100%;
}
}
1 change: 0 additions & 1 deletion app/src/App/paket.references
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FSharp.ViewEngine
Giraffe
Markdig
Serilog
Serilog.AspNetCore
Serilog.Sinks.Console
Expand Down
31 changes: 31 additions & 0 deletions app/src/App/src/Articles/Article.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace App.Articles

open FSharp.ViewEngine
open System

type ArticleMetadata =
{ permalink: string
title: string
summary: string
cover: string
tags: string[]
createdAt: DateTimeOffset }

type Article =
{ permalink: string
title: string
summary: string
cover: string
tags: string[]
createdAt: DateTimeOffset
page: HtmlElement }

module Article =
let create (metadata: ArticleMetadata) (page: HtmlElement) =
{ permalink = metadata.permalink
title = metadata.title
summary = metadata.summary
cover = metadata.cover
tags = metadata.tags
createdAt = metadata.createdAt
page = page }
12 changes: 12 additions & 0 deletions app/src/App/src/Articles/Catalog.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module App.Articles.Catalog

open App.Articles

let all: Article list =
[ Posts.FSharpSemanticKernel.article
Posts.PersonalInfrastructure.article
Posts.DevelopmentEnvironment.article ]
|> List.sortByDescending _.createdAt

let tryFind permalink =
all |> List.tryFind (fun article -> article.permalink = permalink)
15 changes: 8 additions & 7 deletions app/src/App/src/Articles/Handler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module App.Articles.Handler

open App.Infrastructure
open App.ServiceRegistry
open App.Articles
open App.Articles.View
open App.Common.Handler
open App.Common.View
Expand All @@ -23,21 +24,21 @@ let private filtersFromRequest (ctx:HttpContext) =
| true, year -> Some year
| false, _ -> None) }

let filterArticles (filters:FilterState) (articles:Domain.Article.Article list) =
let matchesSearch (article:Domain.Article.Article) =
let filterArticles (filters:FilterState) (articles:Article list) =
let matchesSearch (article:Article) =
filters.search
|> Option.forall (fun query ->
let query = query.Trim()
article.title.Contains(query, StringComparison.OrdinalIgnoreCase)
|| article.summary.Contains(query, StringComparison.OrdinalIgnoreCase)
|| (article.tags |> Array.exists (fun tag -> tag.Contains(query, StringComparison.OrdinalIgnoreCase))))

let matchesTag (article:Domain.Article.Article) =
let matchesTag (article:Article) =
filters.tag
|> Option.forall (fun selectedTag ->
article.tags |> Array.exists (fun tag -> String.Equals(tag, selectedTag, StringComparison.OrdinalIgnoreCase)))

let matchesYear (article:Domain.Article.Article) =
let matchesYear (article:Article) =
filters.publishedYear
|> Option.forall (fun year -> article.createdAt.Year = year)

Expand All @@ -53,7 +54,7 @@ let private getArticlesPage (services:Services) : HttpHandler =
if not ctx.IsDatastar && requestedUrl <> canonicalUrl then
return! redirectTo false canonicalUrl next ctx
else
let! allArticles = services.article.listArticles ()
let allArticles = Catalog.all
let page =
{ articles = filterArticles filters allArticles
filters = filters
Expand All @@ -74,9 +75,9 @@ let private getArticlesPage (services:Services) : HttpHandler =
let private getArticlePage (services:Services) (id:string) : HttpHandler =
fun next ctx -> task {
use _span = services.telemetry.startActiveSpan "app.articles.get_article_page"
match! services.article.tryGetArticle id with
match Catalog.tryFind id with
| Some article ->
let page = articlePage article
let page = article.page
let url = SiteUrl.article article.permalink

if ctx.IsDatastar then
Expand Down
Loading
Loading