fixed warnings and added archive sorting
This commit is contained in:
@@ -1 +1,5 @@
|
|||||||
import { defineConfig } from "astro/config";
|
import { defineConfig } from "astro/config";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
output: "server",
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
import { format, add } from "date-fns";
|
|
||||||
import FormattedDate from "@components/FormattedDate.astro";
|
import FormattedDate from "@components/FormattedDate.astro";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { format, add } from "date-fns";
|
import { format, add } from "date-fns";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
date: String;
|
date: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { date } = Astro.props;
|
const { date } = Astro.props;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
---
|
---
|
||||||
const { pathname } = Astro.url;
|
const { pathname } = Astro.url;
|
||||||
console.log(pathname);
|
|
||||||
|
|
||||||
const navLinks = [
|
const navLinks = [
|
||||||
{ label: "Blog", icon: "website-with-texticonImage24px", path: "/" },
|
{ label: "Blog", icon: "website-with-texticonImage24px", path: "/" },
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
|
export const prerender = true;
|
||||||
import Layout from "@layouts/Layout.astro";
|
import Layout from "@layouts/Layout.astro";
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
|
|||||||
@@ -1,13 +1,40 @@
|
|||||||
---
|
---
|
||||||
import { getCollection } from "astro:content";
|
import { getCollection } from "astro:content";
|
||||||
|
const sortParam = Astro.url.search.split("=")[1];
|
||||||
|
|
||||||
import Layout from "@layouts/Layout.astro";
|
import Layout from "@layouts/Layout.astro";
|
||||||
import FormattedDate from "@components/FormattedDate.astro";
|
import FormattedDate from "@components/FormattedDate.astro";
|
||||||
|
|
||||||
const posts = await getCollection("blog");
|
const posts = await getCollection("blog");
|
||||||
|
|
||||||
|
switch (sortParam) {
|
||||||
|
case "date-des":
|
||||||
|
posts.sort(
|
||||||
|
(a, b) => Date.parse(b.data.pubDate) - Date.parse(a.data.pubDate)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "date-asc":
|
||||||
|
posts.sort(
|
||||||
|
(a, b) => Date.parse(a.data.pubDate) - Date.parse(b.data.pubDate)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "title":
|
||||||
|
posts.sort((a, b) => a.data.title - b.data.title);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title="Blog Archive">
|
<Layout title="Blog Archive">
|
||||||
|
<div class="archive-options">
|
||||||
|
<div class="select-container">
|
||||||
|
<select name="sort by" id="sort-by">
|
||||||
|
<option value="title">Title (Alphabetically)</option>
|
||||||
|
<option value="date-des">Publish Date (Newest First)</option>
|
||||||
|
<option value="date-asc">Publish Date (Oldest First)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{
|
{
|
||||||
posts.map(({ slug, data }) => (
|
posts.map(({ slug, data }) => (
|
||||||
<div>
|
<div>
|
||||||
@@ -17,3 +44,21 @@ const posts = await getCollection("blog");
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
|
<script is:inline>
|
||||||
|
const sort = location.search.split("=")[1];
|
||||||
|
const sortEl = document.querySelector("#sort-by");
|
||||||
|
|
||||||
|
sortEl.value = sort || "title";
|
||||||
|
|
||||||
|
sortEl.addEventListener(
|
||||||
|
"change",
|
||||||
|
() => (window.location.href = `/archive?sort=${sortEl.value}`)
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.archive-options {
|
||||||
|
padding: 10px 0 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
|
export const prerender = true;
|
||||||
import { getCollection } from "astro:content";
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
import Layout from "@layouts/Layout.astro";
|
import Layout from "@layouts/Layout.astro";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { getCollection, getEntryBySlug } from "astro:content";
|
export const prerender = true;
|
||||||
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
import Layout from "@layouts/Layout.astro";
|
import Layout from "@layouts/Layout.astro";
|
||||||
import BlogHeader from "@components/BlogHeader.astro";
|
import BlogHeader from "@components/BlogHeader.astro";
|
||||||
@@ -28,6 +29,8 @@ const { Content } = await post.render();
|
|||||||
|
|
||||||
<style is:global>
|
<style is:global>
|
||||||
article img {
|
article img {
|
||||||
|
border-radius: var(--radius);
|
||||||
|
box-shadow: var(--shadow);
|
||||||
display: block;
|
display: block;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-1
@@ -178,7 +178,7 @@ li {
|
|||||||
margin: 0.5rem 0;
|
margin: 0.5rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Button Styles */
|
/* Input Styles */
|
||||||
button,
|
button,
|
||||||
.link-button {
|
.link-button {
|
||||||
background-color: gray;
|
background-color: gray;
|
||||||
@@ -202,6 +202,39 @@ button:active,
|
|||||||
scale: 0.98;
|
scale: 0.98;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
/* appearance: none;
|
||||||
|
padding: 6px 40px 6px 10px;
|
||||||
|
border-radius: var(--radius);
|
||||||
|
border: none; */
|
||||||
|
font-size: 1rem;
|
||||||
|
/* background: none;
|
||||||
|
z-index: 10; */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .select-container {
|
||||||
|
position: relative;
|
||||||
|
width: max-content;
|
||||||
|
border-radius: var(--radius);
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-container::before {
|
||||||
|
position: absolute;
|
||||||
|
content: "▾";
|
||||||
|
top: 0px;
|
||||||
|
right: 0px;
|
||||||
|
height: 10px;
|
||||||
|
width: 10px;
|
||||||
|
color: white;
|
||||||
|
font-size: 1rem;
|
||||||
|
height: 100%;
|
||||||
|
width: 30px;
|
||||||
|
background-color: var(--blue);
|
||||||
|
text-align: center;
|
||||||
|
} */
|
||||||
|
|
||||||
/* Text Inputs */
|
/* Text Inputs */
|
||||||
|
|
||||||
input,
|
input,
|
||||||
|
|||||||
Reference in New Issue
Block a user