mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
init
This commit is contained in:
22
src/pages/articles/[...slug].astro
Normal file
22
src/pages/articles/[...slug].astro
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
import { type Article, data } from '@/data/data.js';
|
||||
import ArticleView from '@/layouts/article/article.astro';
|
||||
|
||||
type Props = {
|
||||
article: Article;
|
||||
};
|
||||
|
||||
const getStaticPaths = async () => {
|
||||
const articles = await data.articles.find();
|
||||
return articles.map((article) => ({
|
||||
params: { slug: article.slug },
|
||||
props: { article },
|
||||
}));
|
||||
};
|
||||
const { props } = Astro;
|
||||
const { article } = props;
|
||||
|
||||
export { getStaticPaths };
|
||||
---
|
||||
|
||||
<ArticleView article={article} />
|
||||
24
src/pages/articles/[...slug].pdf.ts
Normal file
24
src/pages/articles/[...slug].pdf.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { type Article, data } from '@/data/data.ts';
|
||||
import type { APIContext } from 'astro';
|
||||
|
||||
type Props = {
|
||||
article: Article;
|
||||
};
|
||||
|
||||
export async function GET(context: APIContext<Props>) {
|
||||
const { props } = context;
|
||||
const { article } = props;
|
||||
return new Response(JSON.stringify(article), {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const articles = await data.articles.find();
|
||||
return articles.map((article) => ({
|
||||
params: { slug: article.slug },
|
||||
props: { article },
|
||||
}));
|
||||
}
|
||||
36
src/pages/articles/pages/[...page].astro
Normal file
36
src/pages/articles/pages/[...page].astro
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
import { type Article, data } from '@/data/data.js';
|
||||
import Articles from '@/layouts/articles/articles.astro';
|
||||
import { range } from '@/utils/data.js';
|
||||
|
||||
type Props = {
|
||||
articles: Article[];
|
||||
pageNumber: number;
|
||||
pageCount: number;
|
||||
pageSize: number;
|
||||
};
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const pageSize = 2;
|
||||
const allArticles = await data.articles.find();
|
||||
const pageCount = Math.ceil(allArticles.length / pageSize);
|
||||
const pages = range(0, pageCount).map((index) => {
|
||||
const start = index * pageSize;
|
||||
const end = start + pageSize;
|
||||
return {
|
||||
pageNumber: index + 1,
|
||||
pageCount,
|
||||
pageSize,
|
||||
articles: allArticles.slice(start, end),
|
||||
};
|
||||
});
|
||||
return pages.map((page) => ({
|
||||
params: { page: String(page.pageNumber) },
|
||||
props: page,
|
||||
}));
|
||||
}
|
||||
|
||||
const { props } = Astro;
|
||||
---
|
||||
|
||||
<Articles {...props} />
|
||||
17
src/pages/articles/rss.xml.ts
Normal file
17
src/pages/articles/rss.xml.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { data } from '@/data/data.ts';
|
||||
import rss from '@astrojs/rss';
|
||||
import type { APIContext } from 'astro';
|
||||
|
||||
export async function GET(context: APIContext) {
|
||||
const articles = await data.articles.find();
|
||||
const profile = data.profile;
|
||||
return rss({
|
||||
title: profile.basics.name,
|
||||
description: profile.basics.tagline,
|
||||
site: context.site || 'http://localhost:3000',
|
||||
items: articles.map((article) => ({
|
||||
...article.data,
|
||||
link: `/articles/${article.slug}/`,
|
||||
})),
|
||||
});
|
||||
}
|
||||
6
src/pages/index.astro
Normal file
6
src/pages/index.astro
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
import {} from '@/data/data.js';
|
||||
import Frontpage from '@/layouts/frontpage/frontpage.astro';
|
||||
---
|
||||
|
||||
<Frontpage />
|
||||
39
src/pages/manifest.webmanifest.ts
Normal file
39
src/pages/manifest.webmanifest.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { icons } from '@/assets/images/icons.js';
|
||||
import { data } from '@/data/data.js';
|
||||
import type { ManifestOptions } from 'vite-plugin-pwa';
|
||||
|
||||
export async function GET() {
|
||||
const [maskableIcon] = icons.pngs.filter(
|
||||
(icon) => icon.size === '512x512' && icon.src.includes('png'),
|
||||
);
|
||||
const nonMaskableIcons = icons.pngs.filter((icon) => icon !== maskableIcon);
|
||||
const basics = data.profile.basics;
|
||||
|
||||
const manifest: Partial<ManifestOptions> = {
|
||||
name: basics.name,
|
||||
short_name: basics.name,
|
||||
description: basics.tagline,
|
||||
theme_color: '#30E130',
|
||||
background_color: data.site.theme,
|
||||
start_url: '/',
|
||||
display: 'minimal-ui',
|
||||
icons: [
|
||||
...nonMaskableIcons.map((png) => ({
|
||||
src: png.src,
|
||||
sizes: png.size,
|
||||
type: 'image/png',
|
||||
})),
|
||||
...(maskableIcon
|
||||
? [
|
||||
{
|
||||
src: maskableIcon.src,
|
||||
sizes: maskableIcon.size,
|
||||
type: 'image/png',
|
||||
purpose: 'maskable',
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
};
|
||||
return new Response(JSON.stringify(manifest, null, 2));
|
||||
}
|
||||
6
src/pages/resume.json.ts
Normal file
6
src/pages/resume.json.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { data } from '@/data/data.ts';
|
||||
|
||||
export async function GET() {
|
||||
const resume = await data.getJsonResume();
|
||||
return new Response(JSON.stringify(resume, null, 2));
|
||||
}
|
||||
5
src/pages/work-history.astro
Normal file
5
src/pages/work-history.astro
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
import Work from '@/layouts/work-history/work-history.astro';
|
||||
---
|
||||
|
||||
<Work />
|
||||
Reference in New Issue
Block a user