Skip to content

Commit

Permalink
use outvariant instead of tiny-invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
yuheiy committed Feb 9, 2024
1 parent b8933d5 commit dcc5275
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"just-extend": "6.2.0",
"just-safe-set": "4.2.1",
"mdast-util-to-string": "4.0.0",
"outvariant": "1.4.2",
"patch-package": "8.0.0",
"prettier": "3.2.4",
"prettier-plugin-astro": "0.13.0",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
import { invariant } from 'outvariant';
import PageHeader from '../components/PageHeader.astro';
import Layout from '../layouts/Layout.astro';
import invariant from '../lib/tiny-invariant';
const title = 'ページが存在しません';
const searchURL = new URL('https://www.google.com/search');
invariant(Astro.site);
invariant(Astro.site, 'Invariant failed');
searchURL.searchParams.set('q', `site:${Astro.site.host}`);
---

Expand Down
3 changes: 2 additions & 1 deletion src/pages/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
import { getCollection } from 'astro:content';
import { invariant } from 'outvariant';
import PageHeader from '../components/PageHeader.astro';
import Layout from '../layouts/Layout.astro';
import { renderDateToHtml } from '../lib/render-date-to-html';
import invariant from '../lib/tiny-invariant';
export async function getStaticPaths() {
return (await getCollection('blog')).map((entry) => ({
Expand All @@ -20,6 +20,7 @@ const { Content, remarkPluginFrontmatter } = await entry.render();
invariant(
typeof remarkPluginFrontmatter.description === 'string' ||
typeof remarkPluginFrontmatter.description === 'undefined',
'Invariant failed',
);
---

Expand Down
5 changes: 3 additions & 2 deletions src/pages/posts-feed.xml.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import rss from '@astrojs/rss';
import type { APIContext } from 'astro';
import { getCollection } from 'astro:content';
import { invariant } from 'outvariant';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
import invariant from '../lib/tiny-invariant';

export async function GET(context: APIContext) {
const blogEntries = (await getCollection('blog'))
.toSorted((a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf())
.toReversed();

invariant(context.site);
invariant(context.site, 'Invariant failed');

return rss({
title: SITE_TITLE,
Expand All @@ -22,6 +22,7 @@ export async function GET(context: APIContext) {
invariant(
typeof remarkPluginFrontmatter.description === 'string' ||
typeof remarkPluginFrontmatter.description === 'undefined',
'Invariant failed',
);

return {
Expand Down

0 comments on commit dcc5275

Please sign in to comment.