Skip to content

Commit

Permalink
sitemap修正
Browse files Browse the repository at this point in the history
  • Loading branch information
eatski committed Aug 10, 2024
1 parent c832a38 commit 336ffc1
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 90 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ if [ "$MIGRATION" = "1" ]; then
else
echo "MIGRATION is not set to '1'. Skipping prisma migrate deploy."
fi
npx next build && npx next-sitemap
npx next build
6 changes: 0 additions & 6 deletions next-sitemap.config.js

This file was deleted.

64 changes: 0 additions & 64 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
"jsdom": "24.1.1",
"lint-staged": "15.2.8",
"msw": "2.3.5",
"next-sitemap": "4.2.3",
"node-html-parser": "6.1.13",
"prisma": "5.18.0",
"storybook": "8.2.8",
Expand Down
19 changes: 1 addition & 18 deletions src/app/[markdownName]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { readFile } from "node:fs/promises";
import { resolve } from "node:path";
import { brand } from "@/common/texts";
import { Markdown } from "@/components/markdown";
import { markdownNames, readMarkdownDoc } from "@/docs";
import { micromark } from "micromark";
import { Metadata } from "next";
import { notFound } from "next/navigation";
Expand All @@ -11,15 +10,6 @@ import { z } from "zod";
export const dynamic = "force-static";
export const dynamicParams = false;

const markdownNames = [
"privacy",
"terms",
"about",
"howToWriteStory",
"situationPuzzle",
"sponsor",
] as const;

const paramsSchema = z.object({
markdownName: z.enum(markdownNames),
});
Expand Down Expand Up @@ -53,13 +43,6 @@ export const generateMetadata = async ({
};
};

const readMarkdownDoc = (markdownName: string) => {
return readFile(
resolve(process.cwd(), "docs", `${markdownName}.md`),
"utf-8",
);
};

export default async function MarkdownDocumentPage({
params,
}: { params: unknown }) {
Expand Down
10 changes: 10 additions & 0 deletions src/app/[markdownName]/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { brand } from "@/common/texts";
import { markdownNames } from "@/docs";
import { MetadataRoute } from "next";
export default function sitemap(): MetadataRoute.Sitemap {
return markdownNames.map((markdownName) => ({
url: `${brand.origin}/${markdownName}`,
changeFrequency: "daily",
priority: 0.7,
}));
}
42 changes: 42 additions & 0 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { brand } from "@/common/texts";
import { markdownNames } from "@/docs";
import { getStories } from "@/server/services/story";
import { MetadataRoute } from "next";
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const stories = await getStories({
count: 300,
});
return [
{
url: `${brand.origin}/`,
changeFrequency: "daily",
priority: 0.7,
},
{
url: `${brand.origin}/stories`,
changeFrequency: "daily",
priority: 0.7,
},
{
url: `${brand.origin}/stories/rank`,
changeFrequency: "daily",
priority: 0.7,
},
...markdownNames.map(
(markdownName) =>
({
url: `${brand.origin}/${markdownName}`,
changeFrequency: "daily",
priority: 0.7,
}) as const,
),
...stories.map(
(story) =>
({
url: `${brand.origin}/stories/${story.id}`,
changeFrequency: "daily",
priority: 0.7,
}) as const,
),
];
}
1 change: 1 addition & 0 deletions src/common/texts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const brand = {
origin: "https://iesona.com",
serviceName: "Yesonor",
serviceNickname: "いえそな",
serviceDescription:
Expand Down
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions src/docs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { resolve } from "path";
import { readFile } from "fs/promises";

export const markdownNames = [
"privacy",
"terms",
"about",
"howToWriteStory",
"situationPuzzle",
"sponsor",
] as const;

export const readMarkdownDoc = (
markdownName: (typeof markdownNames)[number],
) => {
return readFile(
resolve(process.cwd(), "src", "docs", `${markdownName}.md`),
"utf-8",
);
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 336ffc1

Please sign in to comment.