Skip to content

Commit

Permalink
プレビュービルドを可能にする
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Nov 25, 2024
1 parent 8713d22 commit 5c43cd7
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ pnpm run deploy
Netlify を使ってプレビュー環境デプロイを行っています。
`preview`ブランチに push すると、Netlify のプレビュー環境にデプロイされます。

```bash
# ビルド
pnpm run preview-build
```

## リソース情報の更新

コードの更新
Expand Down
2 changes: 1 addition & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
integrations: [
mdx(),
sitemap({
filter: (page) => page.includes("/dev/"),
filter: (page) => !page.includes("/dev/"),
}),
react(),
partytown({
Expand Down
10 changes: 5 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import js from "@eslint/js";
import typescript from "typescript-eslint";
import astro from "eslint-plugin-astro";

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
export default typescript.config(
js.configs.recommended,
typescript.configs.recommended,
astro.configs["flat/recommended"],
astro.configs["flat/jsx-a11y-recommended"],
{
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"preview-build": "cross-env PREVIEW=1 astro build",
"deploy": "astro check && astro build && gh-pages -d dist",
"lint": "eslint src/",
"fmt": "eslint src/ --fix",
Expand Down Expand Up @@ -38,6 +39,7 @@
"astro": "4.16.10",
"astro-seo": "0.8.4",
"bulma": "1.0.2",
"cross-env": "7.0.3",
"eslint": "9.15.0",
"eslint-plugin-astro": "1.3.1",
"eslint-plugin-jsx-a11y": "6.10.2",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions src/constants/characterInfos/callNameInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export const callNameInfos: {
藍田ノエル: "あいえるさん/あいえるはん",
満別花丸: "満別さん/花丸はん",
琴詠ニア: "琴詠さん/ニアはん",
Voidoll: "ボイドールさん/ぼいどーるはん",
},
No7: {
me: ["私", "僕"],
Expand Down
21 changes: 2 additions & 19 deletions src/layouts/Base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ const {
description,
image: _image,
imageAlt,
noindex,
noindex: noindex_,
defaultHideHeader,
isDark,
isNemo,
} = Astro.props;
const noindex = import.meta.env.PREVIEW || noindex_;
const isProduction = import.meta.env.PROD;
// imageとimageAltが片方だけ指定されている場合はエラーを出す
Expand Down Expand Up @@ -99,24 +100,6 @@ const hasImage = imageUrl != undefined && imageAlt != undefined;
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/site.webmanifest" />

{/* セキュリティ対策。というよりSEO対策。 */}
{
import.meta.env.PROD && (
<>
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'"
/>
<meta
http-equiv="Content-Security-Policy"
content="upgrade-insecure-requests"
/>
<meta http-equiv="Permissions-Policy" content="interest-cohort=()" />
<meta http-equiv="X-FRAME-OPTIONS" content="DENY" />
</>
)
}

{/* Google Analytics */}
<script
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
Expand Down
7 changes: 3 additions & 4 deletions src/pages/robots.txt.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/**
* https://docs.astro.build/ja/guides/integrations-guide/sitemap/ からコピー
* https://docs.astro.build/ja/guides/integrations-guide/sitemap/#sitemap-link-in-robotstxt からコピー
*/

import type { APIRoute } from "astro";

const getRobotsTxt = (sitemapURL: URL) => `
User-agent: *
Allow: /
const getRobotsTxt = (sitemapURL: URL) => `User-agent: *
${import.meta.env.PREVIEW ? "Disallow" : "Allow"}: /
Sitemap: ${sitemapURL.href}
`;
Expand Down

0 comments on commit 5c43cd7

Please sign in to comment.