Skip to content

Commit 7cbf00a

Browse files
committed
add the template, add yml
1 parent c9adb29 commit 7cbf00a

21 files changed

+654
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build and Publish github template
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
schedule:
9+
- cron: "0 0 * * *" # Runs every day at midnight UTC
10+
11+
jobs:
12+
build-and-publish:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install BlazorStatic.Templates and create the blog
19+
run: |
20+
dotnet new install BlazorStatic.Templates
21+
dotnet new BlazorStaticMinimalBlog -o BlazorStaticMinimalBlog
22+
23+
- name: Push to master branch of BlazorStatic/BlazorStaticMinimalBlog
24+
run: |
25+
git init --initial-branch=master
26+
git config user.name "GitHub Action"
27+
git config user.email "[email protected]"
28+
git remote add origin https://x-access-token:${{ secrets.BLAZORSTATICMINIMALBLOG_REPO_TOKEN }}@github.com/BlazorStatic/BlazorStaticMinimalBlog.git
29+
git add .
30+
git commit -m "publish of the template"
31+
git push -f origin master
32+
working-directory: BlazorStaticMinimalBlog
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="BlazorStatic" Version="1.0.0-beta.13"/>
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Content/**/*">
15+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
20+
<!-- to make hot reload work on .md files -->
21+
<ItemGroup>
22+
<Watch Include="Content/**/*"/>
23+
</ItemGroup>
24+
25+
26+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34309.116
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorStaticMinimalBlog", "BlazorStaticMinimalBlog.csproj", "{97F44AF6-5AF6-4FD8-AE15-96648E0CA921}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{97F44AF6-5AF6-4FD8-AE15-96648E0CA921}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{97F44AF6-5AF6-4FD8-AE15-96648E0CA921}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{97F44AF6-5AF6-4FD8-AE15-96648E0CA921}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{97F44AF6-5AF6-4FD8-AE15-96648E0CA921}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {11C0E4EA-03B1-4426-AA27-ADFAF57D3327}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8"/>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
7+
<base href="/"/>
8+
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
9+
<script>
10+
tailwind.config = {
11+
theme: {
12+
extend: {
13+
14+
colors: {
15+
primary: tailwind.colors.violet
16+
},
17+
},},
18+
}
19+
</script>
20+
21+
22+
<HeadOutlet/>
23+
</head>
24+
25+
<body class="bg-gray-950 font-sans text-gray-200">
26+
<Routes/>
27+
</body>
28+
29+
</html>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="mx-auto max-w-3xl px-4 sm:px-6 xl:max-w-5xl xl:px-0 ">
4+
<div class="flex h-screen flex-col justify-between">
5+
6+
<NavMenu/>
7+
8+
<main class="mb-auto">
9+
@Body
10+
</main>
11+
12+
<footer>
13+
<div class="mt-16 flex flex-col items-center">
14+
<div class="mb-3 flex space-x-4">
15+
<a class="text-sm text-gray-500 transition hover:text-gray-600" target="_blank" rel="noopener noreferrer" href="@WebsiteKeys.GitHubRepo">
16+
<span class="sr-only">github</span>
17+
<Svg Icon="Svg.Icons.Github"/>
18+
</a>
19+
<a class="text-sm text-gray-500 transition hover:text-gray-600" target="_blank" rel="noopener noreferrer" href="@WebsiteKeys.X">
20+
<span class="sr-only">x</span>
21+
<Svg Icon="Svg.Icons.X"/>
22+
</a>
23+
</div>
24+
<div class="mb-2 flex space-x-2 text-sm text-gray-400">
25+
<a target="_blank" rel="noopener noreferrer" href="https://github.com/BlazorStatic/BlazorStatic"> Built with Blazor Static</a>
26+
<div>•</div>
27+
<div@DateTime.Now.Year</div>
28+
</div>
29+
</div>
30+
</footer>
31+
</div>
32+
</div>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
@inject NavigationManager Nm
2+
3+
<header class="flex items-center justify-between py-10">
4+
<div>
5+
<a href="">
6+
<div class="flex items-center justify-between">
7+
<div class=" h-6 text-2xl font-semibold sm:block text-primary-800">@WebsiteKeys.Title</div>
8+
</div>
9+
</a>
10+
</div>
11+
<div class="flex items-center space-x-4 leading-5 sm:space-x-6">
12+
@foreach(var item in menuItems)
13+
{
14+
<NavLink ActiveClass="bg-primary-950 px-2 py-1 rounded-xl" class="hidden font-medium text-gray-100 sm:block"
15+
Match="@(item.Link == "" ? NavLinkMatch.All : NavLinkMatch.Prefix)" href="@item.Link">
16+
@((MarkupString)item.Name)
17+
<Svg Icon="item.Icon"/>
18+
</NavLink>
19+
20+
@* <a class="hidden font-medium text-gray-100 sm:block @(Nm.Uri.EndsWith(item.link)?"":"") " href="@item.link">@item.name</a> *@
21+
}
22+
<button id="toggle-button" aria-label="Toggle Menu" class="sm:hidden">
23+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="h-8 w-8 text-gray-100">
24+
<path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path>
25+
</svg>
26+
</button>
27+
<div id="mobile-menu" class="fixed left-0 top-0 z-10 h-full w-full translate-x-full transform duration-300 ease-in-out bg-gray-950 opacity-[0.98]">
28+
<div class="flex justify-end">
29+
<button id="close-mobile-menu-button" class="mr-8 mt-11 h-8 w-8" aria-label="Toggle Menu">
30+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="text-gray-100">
31+
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path>
32+
</svg>
33+
</button>
34+
</div>
35+
<nav class="fixed mt-8 h-full">
36+
@foreach(var item in menuItems)
37+
{
38+
<div class="px-12 py-4">
39+
<NavLink ActiveClass="underline" class="text-2xl font-bold tracking-widest text-gray-100"
40+
Match="@(item.Link == "" ? NavLinkMatch.All : NavLinkMatch.Prefix)" href="@item.Link">
41+
@((MarkupString)item.Name)
42+
<Svg Icon="item.Icon"/>
43+
</NavLink>
44+
</div>
45+
}
46+
</nav>
47+
</div>
48+
</div>
49+
</header>
50+
<script>
51+
//👎 but what can I do? It's a static html. I can't use C# here.
52+
const toggleMobileMenu = () => document.querySelector('#mobile-menu').classList.toggle('translate-x-full');
53+
54+
document.querySelector('#toggle-button').addEventListener('click', toggleMobileMenu);
55+
document.querySelector('#close-mobile-menu-button').addEventListener('click', toggleMobileMenu);
56+
</script>
57+
58+
59+
@code
60+
{
61+
List<MenuItem> menuItems =
62+
[
63+
new("Home", ""),
64+
new("Tags", "tags"),
65+
new("", WebsiteKeys.GitHubRepo, Svg.Icons.Github)
66+
];
67+
68+
69+
record MenuItem(string Name, string Link, Svg.Icons? Icon = null);
70+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
@page "/"
2+
@page "/blog/{fileName}"
3+
@using System.Globalization
4+
@using BlazorStatic
5+
@using BlazorStatic.Services
6+
@inject BlazorStaticContentService<BlogFrontMatter> blazorStaticContentService
7+
8+
9+
@* No filename -> show latest posts *@
10+
@if (string.IsNullOrWhiteSpace(FileName))
11+
{
12+
<div class="divide-y divide-gray-700">
13+
<div class="space-y-2 pb-8 pt-6 md:space-y-5">
14+
<h1 class="font-sans md:leading-14 text-3xl font-extrabold leading-9 tracking-tight text-gray-100 sm:text-4xl sm:leading-10 md:text-6xl">Latest</h1>
15+
<p class="text-lg leading-7 text-gray-400 prose prose-invert">@WebsiteKeys.BlogLead</p>
16+
</div>
17+
18+
<PostsList/>
19+
</div>
20+
return;
21+
}
22+
23+
@* Show specific post by filename param *@
24+
@if (post == null)
25+
{
26+
<div>Post not found 🤷 </div>
27+
return;
28+
}
29+
<article>
30+
<div class="xl:divide-y xl:divide-gray-700">
31+
<header class="pt-6 xl:pb-6">
32+
<div class="space-y-1 text-center">
33+
<dl class="space-y-10">
34+
<div>
35+
<dt class="sr-only">Published on</dt>
36+
<dd class="text-base font-medium leading-6 text-gray-400">
37+
<time datetime="@post.FrontMatter.Published.ToString("yyyy-MM-ddTHH:mm:ss.fffK", CultureInfo.InvariantCulture)">
38+
@post.FrontMatter.Published.ToString("MMMM d, yyyy", new CultureInfo("en-US"))
39+
</time>
40+
</dd>
41+
</div>
42+
</dl>
43+
<div class="prose prose-invert mx-auto">
44+
<h1 class="">@post.FrontMatter.Title</h1>
45+
</div>
46+
</div>
47+
</header>
48+
<div class="grid-rows-[auto_1fr] divide-y pb-8 divide-gray-700 xl:grid xl:grid-cols-4 xl:gap-x-6 xl:divide-y-0">
49+
50+
<dl class="pb-10 pt-6 xl:border-b xl:pt-11 xl:border-gray-700">
51+
<dt class="sr-only">Authors</dt>
52+
<dd>
53+
<ul class="flex flex-wrap justify-center gap-4 sm:space-x-12 xl:block xl:space-x-0 xl:space-y-8">
54+
@foreach(var author in post.FrontMatter.Authors)
55+
{
56+
<li class="flex items-center space-x-2">
57+
@* <img alt="avatar" loading="lazy" width="38" height="38" decoding="async" data-nimg="1" class="h-10 w-10 rounded-full" srcset="/_next/image?url=%2Fstatic%2Fimages%2Favatar.png&amp;w=48&amp;q=75 1x, /_next/image?url=%2Fstatic%2Fimages%2Favatar.png&amp;w=96&amp;q=75 2x" src="/_next/image?url=%2Fstatic%2Fimages%2Favatar.png&amp;w=96&amp;q=75" style="color: transparent;"/> *@
58+
<dl class="whitespace-nowrap text-sm font-medium leading-5">
59+
@if (!string.IsNullOrWhiteSpace(author.Name))
60+
{
61+
<dt class="sr-only">Name</dt>
62+
<dd class="text-gray-900 dark:text-gray-100 flex gap-1 items-center">
63+
@author.Name
64+
@if (!string.IsNullOrWhiteSpace(author.XUserName))
65+
{
66+
<a target="_blank" rel="noopener noreferrer" href="https://x.com/@author.XUserName" class="flex gap-1 text-primary-500 hover:text-primary-600 dark:hover:text-primary-400">
67+
<Svg SizeClasses="w-4 h-4" Icon="Svg.Icons.X"/>
68+
</a>
69+
}
70+
@if (!string.IsNullOrWhiteSpace(author.GitHubUserName))
71+
{
72+
<a target="_blank" rel="noopener noreferrer" href="https://github.com/@author.GitHubUserName" class="flex gap-1 items-center text-primary-500 hover:text-primary-600 dark:hover:text-primary-400">
73+
<Svg SizeClasses="w-4 h-4" Icon="Svg.Icons.Github"/>
74+
</a>
75+
}
76+
</dd>
77+
}
78+
</dl>
79+
</li>
80+
}
81+
</ul>
82+
</dd>
83+
</dl>
84+
<div class="divide-y divide-gray-700 xl:col-span-3 xl:row-span-2 xl:pb-0">
85+
<div class="prose prose-invert max-w-none pb-8 pt-10">
86+
@((MarkupString)post.HtmlContent)
87+
</div>
88+
<div class="pb-6 pt-6 text-sm text-gray-300">
89+
<a target="_blank" rel="noopener noreferrer" href="@($"{WebsiteKeys.BlogPostStorageAddress}/{FileName}")">View on GitHub</a>
90+
</div>
91+
</div>
92+
<footer>
93+
<div class=" text-sm font-medium leading-5 divide-gray-700 xl:col-start-1 xl:row-start-2 xl:divide-y">
94+
<div class="py-4 xl:py-8">
95+
<h2 class="text-xs uppercase tracking-wide text-gray-400">Tags</h2>
96+
<div class="flex flex-wrap">
97+
@foreach(var tag in post.FrontMatter.Tags)
98+
{
99+
<a class="text-primary-500 hover:text-primary-400 mr-3 text-sm font-medium uppercase" href="@blazorStaticContentService.Options.TagsPageUrl/@tag">@tag</a>
100+
}
101+
</div>
102+
</div>
103+
</div>
104+
<div class="pt-4 xl:pt-8">
105+
<a class="text-primary-500 hover:text-primary-400" aria-label="Back to the home" href="">← Back to the home</a>
106+
</div>
107+
</footer>
108+
</div>
109+
</div>
110+
</article>
111+
112+
113+
@code{
114+
[Parameter] public string? FileName { get; set; }
115+
Post<BlogFrontMatter>? post;
116+
117+
protected override void OnInitialized()
118+
{
119+
if (string.IsNullOrWhiteSpace(FileName)) return;
120+
post = blazorStaticContentService.Posts.FirstOrDefault(x => x.Url == FileName);
121+
}
122+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@page "/tags/{tagName}"
2+
@page "/tags"
3+
@using BlazorStatic
4+
@using BlazorStatic.Services
5+
@using System.Net
6+
@inject BlazorStaticContentService<BlogFrontMatter> blazorStaticContentService
7+
8+
@if (TagName == null)
9+
{
10+
<div class="flex flex-wrap justify-evenly gap-1">
11+
@{
12+
var tagsWithCount = blazorStaticContentService.Posts
13+
.SelectMany(x => x.FrontMatter.Tags)
14+
.GroupBy(x => x)
15+
.Select(group => new { Tag = group.Key, Count = group.Count() })
16+
.OrderByDescending(x => x.Count);
17+
18+
foreach(var tag in tagsWithCount)
19+
{
20+
<a class="text-primary-500 hover:text-primary-400 mr-3 text-sm font-medium uppercase" href="@blazorStaticContentService.Options.TagsPageUrl/@WebUtility.HtmlEncode(tag.Tag)">@tag.Tag (@tag.Count)</a>
21+
}
22+
}
23+
</div>
24+
return;
25+
}
26+
27+
28+
<div class="divide-y divide-gray-700">
29+
<div class="space-y-2 pb-8 pt-6 md:space-y-5">
30+
<h1 class="font-sans md:leading-14 text-3xl font-extrabold leading-9 tracking-tight text-gray-100 sm:text-4xl sm:leading-10 md:text-6xl">@TagName</h1>
31+
<p class="text-lg leading-7 text-gray-400">
32+
Blog posts tagged by
33+
<span class="text-primary-300">@TagName</span>
34+
</p>
35+
</div>
36+
<PostsList Posts="posts"/>
37+
</div>
38+
39+
@code {
40+
41+
[Parameter] public string? TagName { get; set; }
42+
43+
List<Post<BlogFrontMatter>>? posts;
44+
45+
protected override void OnInitialized()
46+
{
47+
if (string.IsNullOrWhiteSpace(TagName)) return;
48+
posts = blazorStaticContentService.Posts.Where(x => x.FrontMatter.Tags.Contains(TagName)).ToList();
49+
}
50+
51+
}

0 commit comments

Comments
 (0)