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:
committed by
Morten Olsen
parent
98e39a54cc
commit
ee37ac9d90
@@ -1,22 +1,20 @@
|
||||
---
|
||||
import { type Article, data } from '@/data/data.js';
|
||||
import ArticleView from '@/layouts/article/article.astro';
|
||||
import { type Article, data } from '@/data/data.js'
|
||||
import ArticleView from '@/layouts/article/article.astro'
|
||||
|
||||
type Props = {
|
||||
article: Article;
|
||||
};
|
||||
article: Article
|
||||
}
|
||||
|
||||
const getStaticPaths = async () => {
|
||||
const articles = await data.articles.find();
|
||||
export 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 };
|
||||
props: { article }
|
||||
}))
|
||||
}
|
||||
const { props } = Astro
|
||||
const { article } = props
|
||||
---
|
||||
|
||||
<ArticleView article={article} />
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
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 },
|
||||
}));
|
||||
}
|
||||
@@ -1,36 +1,36 @@
|
||||
---
|
||||
import { type Article, data } from '@/data/data.js';
|
||||
import Articles from '@/layouts/articles/articles.astro';
|
||||
import { range } from '@/utils/data.js';
|
||||
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;
|
||||
};
|
||||
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 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;
|
||||
const start = index * pageSize
|
||||
const end = start + pageSize
|
||||
return {
|
||||
pageNumber: index + 1,
|
||||
pageCount,
|
||||
pageSize,
|
||||
articles: allArticles.slice(start, end),
|
||||
};
|
||||
});
|
||||
articles: allArticles.slice(start, end)
|
||||
}
|
||||
})
|
||||
return pages.map((page) => ({
|
||||
params: { page: String(page.pageNumber) },
|
||||
props: page,
|
||||
}));
|
||||
props: page
|
||||
}))
|
||||
}
|
||||
|
||||
const { props } = Astro;
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Articles {...props} />
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { data } from '@/data/data.ts';
|
||||
import rss from '@astrojs/rss';
|
||||
import type { APIContext } from 'astro';
|
||||
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;
|
||||
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}/`,
|
||||
})),
|
||||
});
|
||||
link: `/articles/${article.slug}/`
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
import {} from '@/data/data.js';
|
||||
import Frontpage from '@/layouts/frontpage/frontpage.astro';
|
||||
import {} from '@/data/data.js'
|
||||
import Frontpage from '@/layouts/frontpage/frontpage.astro'
|
||||
---
|
||||
|
||||
<Frontpage />
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { icons } from '@/assets/images/icons.js';
|
||||
import { data } from '@/data/data.js';
|
||||
import type { ManifestOptions } from 'vite-plugin-pwa';
|
||||
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;
|
||||
(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,
|
||||
@@ -21,7 +21,7 @@ export async function GET() {
|
||||
...nonMaskableIcons.map((png) => ({
|
||||
src: png.src,
|
||||
sizes: png.size,
|
||||
type: 'image/png',
|
||||
type: 'image/png'
|
||||
})),
|
||||
...(maskableIcon
|
||||
? [
|
||||
@@ -29,11 +29,11 @@ export async function GET() {
|
||||
src: maskableIcon.src,
|
||||
sizes: maskableIcon.size,
|
||||
type: 'image/png',
|
||||
purpose: 'maskable',
|
||||
},
|
||||
purpose: 'maskable'
|
||||
}
|
||||
]
|
||||
: []),
|
||||
],
|
||||
};
|
||||
return new Response(JSON.stringify(manifest, null, 2));
|
||||
: [])
|
||||
]
|
||||
}
|
||||
return new Response(JSON.stringify(manifest, null, 2))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { data } from '@/data/data.ts';
|
||||
import { data } from '@/data/data.ts'
|
||||
|
||||
export async function GET() {
|
||||
const resume = await data.getJsonResume();
|
||||
return new Response(JSON.stringify(resume, null, 2));
|
||||
const resume = await data.getJsonResume()
|
||||
return new Response(JSON.stringify(resume, null, 2))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
import Work from '@/layouts/work-history/work-history.astro';
|
||||
import Work from '@/layouts/work-history/work-history.astro'
|
||||
---
|
||||
|
||||
<Work />
|
||||
|
||||
Reference in New Issue
Block a user