Skip to content

Commit

Permalink
Merge branch 'main' into fix-1246
Browse files Browse the repository at this point in the history
  • Loading branch information
garbas committed Mar 3, 2024
2 parents f8c6141 + 18ea29c commit 815f77b
Show file tree
Hide file tree
Showing 8 changed files with 591 additions and 24 deletions.
Binary file added public/logo/nixos-logo-only-hires.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
424 changes: 424 additions & 0 deletions src/assets/image/nixos-logo-notext.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions src/assets/image/nixos-logo-text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 16 additions & 6 deletions src/layouts/Header.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
import {Icon} from "astro-icon";
import { Image } from 'astro:assets';
import flakeBlue from "../assets/image/flake-blue.svg";
import nixosLogoNoText from "../assets/image/nixos-logo-notext.svg";
import nixosLogoText from "../assets/image/nixos-logo-text.svg";
import { getEntry } from 'astro:content';
import Container from "../components/layout/Container.astro";
const headerMenu = await getEntry('menus', 'header');
Expand All @@ -17,16 +18,16 @@ const navbarItemActiveStyle = `border-b-nixlightblue bg-nixlightblue text-white
<Container class="flex flex-col md:flex-row justify-between md:items-center">
<div class="text-4xl font-normal gap-2 flex justify-between md:justify-start items-center my-2">
<a href="/" class="select-none gap-2 flex justify-between md:justify-start items-center">
<Image class="h-16 w-16" src={flakeBlue} alt="Nix Logo" />
<span class="visible md:invisible xl:visible">Nix</span>
<Image class="h-16 w-auto" src={nixosLogoNoText} alt="Nixos Logo" />
<Image class="h-16 block md:hidden xl:block w-auto" src={nixosLogoText} alt="Nixos Logo Text" />
</a>
<div class="bg-nixlightblue block md:hidden p-4 rounded-lg" id="navigation-toggle">
<div class="bg-nixlightblue block md:hidden p-4 rounded-lg" id="navigation-toggle" tabindex="2">
<span class="bg-white block w-8 h-1 mb-1.5"></span>
<span class="bg-white block w-8 h-1 mb-1.5"></span>
<span class="bg-white block w-8 h-1"></span>
</div>
</div>
<div class="pb-4 md:pb-0 flex-col md:flex-row gap-0.5 md:gap-5 hidden md:flex" id="navbar-menu">
<div class="flex pb-4 md:pb-0 flex-col md:flex-row gap-0.5 md:gap-5 md:flex" id="navbar-menu">
{headerMenu.data.items.map((item) => (
<a
class:list={[
Expand All @@ -47,8 +48,17 @@ const navbarItemActiveStyle = `border-b-nixlightblue bg-nixlightblue text-white
const navigationToggle= document.getElementById("navigation-toggle");
const navbarMenu = document.getElementById("navbar-menu");

navigationToggle.addEventListener("click", () => {
function toggleMenu() {
navbarMenu.classList.toggle("hidden");
navbarMenu.classList.toggle("flex")
}
toggleMenu()

navigationToggle.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
toggleMenu()
}
});

navigationToggle.addEventListener("click", () => toggleMenu());
</script>
36 changes: 27 additions & 9 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,40 @@ import '../styles/base.css';
import { getImage } from "astro:assets";
import faviconSvgSrc from "../assets/image/flake-blue.svg";
import { getEntry } from "astro:content";
const {
title = "Nix &amp; NixOS | Reproducible builds and deployments",
description = "Nix is a tool that takes a unique approach to package management and system configuration. Learn how to make reproducible, declarative and reliable systems.",
} = Astro.props
const blogMenu = await getEntry('menus', 'blog');
const faviconSvg = await getImage({ src: faviconSvgSrc, format: 'svg' })
---
const headLinks = [{
rel: "sitemap",
href: "/sitemap-index.xml"
}, {
rel: "icon",
href: faviconSvg.src,
type: "image/svg+xml"
}, {
rel: "alternate",
type: "application/rss+xml",
title: "Complete RSS Feed",
href: "/blog/feed.xml"
}]
const headFeedLinks = blogMenu.data.map((e) => {
return {
rel: "alternate",
type: "application/rss+xml",
title: `${e.title} RSS Feed`,
href: `/blog/${e.id}-rss.xml`
}
})
---
<html lang="en">
<head>
<SEO
Expand All @@ -26,14 +51,7 @@ const faviconSvg = await getImage({ src: faviconSvgSrc, format: 'svg' })
description={description}
charset="utf-8"
extend={{
link: [{
rel: "sitemap",
href: "/sitemap-index.xml"
}, {
rel: "icon",
href: faviconSvg.src,
type: "image/svg+xml"
}],
link: headLinks.concat(headFeedLinks),
meta: [{
name: "viewport",
content: "width=device-width"
Expand Down
3 changes: 2 additions & 1 deletion src/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import MarkdownIt from "markdown-it";

export function generatePathFromPost(post, attachBlog = true) {
const postDate = new Date(post.data.date);
return `/${attachBlog ? "blog/" : ""}${
post.slug.split("/")[0] + "/" + post.slug.split("/").pop().split("_").pop()
post.slug.split("/")[0] + "/" + postDate.getFullYear() + "/" + post.slug.split("/").pop().split("_").pop()
}`;
}

Expand Down
17 changes: 13 additions & 4 deletions src/pages/blog/feed-[id].xml.js → src/pages/blog/[id]-rss.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function getStaticPaths() {

export async function GET(context) {
const blog = await getCollection("blog");
const title = context.params.id.charAt(0).toUpperCase() + context.params.id.slice(1);
blog.sort((a, b) => {
const dateA = new Date(a.data.date);
const dateB = new Date(b.data.date);
Expand All @@ -24,15 +25,23 @@ export async function GET(context) {
return e.data.category === context.params.id;
});
return rss({
title: "NixOS Blog",
site: context.site,
description: "NixOS Blog",
title: `NixOS ${title}`,
site: `${context.site}/blog`,
description: `${title} on NixOS, the purely functional Linux distribution.`,
items: blog.map((post) => ({
title: post.data.title ?? "Untitled",
pubDate: post.data.date ?? new Date().toISOString(),
content: sanitizeHtml(parser.render(post.body)),
link: generatePathFromPost(post),
})),
customData: `<language>en-us</language>`,
customData: `
<language>en-us</language>
<fh:complete xmlns:fh="http://purl.org/syndication/history/1.0"/>
<image>
<title>NixOS ${title}</title>
<url>https://nixos.org/logo/nixos-logo-only-hires.png</url>
<link>${context.site}/blog</link>
</image>
`,
});
}
16 changes: 12 additions & 4 deletions src/pages/blog/feed.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@ export async function GET(context) {
return dateA > dateB ? -1 : 1;
});
return rss({
title: "NixOS Blog",
site: context.site,
description: "NixOS Blog",
title: "NixOS News",
site: `${context.site}/blog`,
description: "News for NixOS, the purely functional Linux distribution.",
items: blog.map((post) => ({
title: post.data.title ?? "Untitled",
pubDate: post.data.date ?? new Date().toISOString(),
content: sanitizeHtml(parser.render(post.body)),
link: generatePathFromPost(post),
})),
customData: `<language>en-us</language>`,
customData: `
<language>en-us</language>
<fh:complete xmlns:fh="http://purl.org/syndication/history/1.0"/>
<image>
<title>NixOS News</title>
<url>https://nixos.org/logo/nixos-logo-only-hires.png</url>
<link>${context.site}/blog</link>
</image>
`,
});
}

0 comments on commit 815f77b

Please sign in to comment.