Updated astro to 2.9.0; pages in blog
This commit is contained in:
parent
be5d01a844
commit
fef04a8829
5 changed files with 348 additions and 362 deletions
|
@ -30,4 +30,7 @@ export default defineConfig({
|
||||||
rehypeFigure,
|
rehypeFigure,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
redirects: {
|
||||||
|
"/blog": "/blog/page0",
|
||||||
|
}
|
||||||
});
|
});
|
675
package-lock.json
generated
675
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -10,7 +10,7 @@
|
||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"astro": "^2.3.0",
|
"astro": "^2.9.0",
|
||||||
"astro-compress": "^1.1.42",
|
"astro-compress": "^1.1.42",
|
||||||
"less": "^4.1.3",
|
"less": "^4.1.3",
|
||||||
"reading-time": "^1.5.0",
|
"reading-time": "^1.5.0",
|
||||||
|
|
|
@ -15,15 +15,11 @@ export async function getStaticPaths() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { slug } = Astro.params;
|
|
||||||
const { post } = Astro.props;
|
const { post } = Astro.props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
PostContent, title, description,
|
PostContent, title, description,
|
||||||
readingTime, date, image,
|
readingTime, date, image,
|
||||||
} = await postRenderer(post);
|
} = await postRenderer(post);
|
||||||
|
|
||||||
const locale = 'ru-RU';
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<BlogLayout title={title} description={description} article={true}>
|
<BlogLayout title={title} description={description} article={true}>
|
||||||
|
|
|
@ -4,8 +4,29 @@ import ArticleCard from "../../components/ArticleCard.astro";
|
||||||
|
|
||||||
import { getCollection } from "astro:content";
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
const posts = await getCollection('blog');
|
export async function getStaticPaths() {
|
||||||
|
const POSTS_ON_PAGE = 15;
|
||||||
|
|
||||||
|
const posts = (await getCollection('blog')).sort(
|
||||||
|
// sort by slug (which includes date), desc
|
||||||
|
(a, b) => (a.slug < b.slug) ? 1 : -1
|
||||||
|
);
|
||||||
|
const count = Math.ceil(posts.length / POSTS_ON_PAGE);
|
||||||
|
const paths = [];
|
||||||
|
|
||||||
|
for (let n = 0; n < count; n++) {
|
||||||
|
paths.push({
|
||||||
|
params: { n: n },
|
||||||
|
props: {
|
||||||
|
posts: posts.slice(n, n + POSTS_ON_PAGE + 1),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
const posts: Array<any> = Astro.props.posts;
|
||||||
const description =
|
const description =
|
||||||
"DarkCat09's blog. " +
|
"DarkCat09's blog. " +
|
||||||
"Reading a QR code without a phone, " +
|
"Reading a QR code without a phone, " +
|
||||||
|
@ -15,6 +36,9 @@ const description =
|
||||||
---
|
---
|
||||||
|
|
||||||
<BlogLayout title="Homepage" description={description}>
|
<BlogLayout title="Homepage" description={description}>
|
||||||
|
<Fragment slot="metadata">
|
||||||
|
<meta name="robots" content="noindex, follow" />
|
||||||
|
</Fragment>
|
||||||
<div id="articles">
|
<div id="articles">
|
||||||
{posts.map(post => <ArticleCard post={post} />)}
|
{posts.map(post => <ArticleCard post={post} />)}
|
||||||
</div>
|
</div>
|
Loading…
Add table
Reference in a new issue