Skip to content

Commit

Permalink
feat: generate sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
ttttonyhe committed Jan 14, 2024
1 parent 7d0c972 commit c701be8
Show file tree
Hide file tree
Showing 7 changed files with 480 additions and 423 deletions.
16 changes: 8 additions & 8 deletions apps/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"dependencies": {
"@reduxjs/toolkit": "^2.0.1",
"@sentry/nextjs": "^7.91.0",
"@sentry/nextjs": "^7.93.0",
"@twilight-toolkit/ui": "workspace:*",
"@twilight-toolkit/utils": "workspace:*",
"algoliasearch": "5.0.0-alpha.59",
Expand All @@ -26,22 +26,22 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hotkeys-hook": "^3.4.7",
"react-redux": "^9.0.4",
"react-redux": "^9.1.0",
"react-snowfall": "^1.2.1",
"redux-saga": "^1.3.0",
"rss": "^1.2.2",
"rss-parser": "^3.13.0",
"sharp": "^0.33.1",
"styled-components": "^6.1.6"
"sharp": "^0.33.2",
"styled-components": "^6.1.8"
},
"devDependencies": {
"@ouorz/eslint-config-next": "workspace:*",
"@ouorz/prettier-config": "workspace:*",
"@tailwindcss/typography": "^0.5.10",
"@types/cors": "^2.8.17",
"@types/lodash": "^4.14.202",
"@types/node": "^20.10.6",
"@types/react": "^18.2.46",
"@types/node": "^20.11.0",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"@types/react-highlight": "^0.12.8",
"@types/rss": "^0.0.32",
Expand All @@ -55,15 +55,15 @@
"next-themes": "^0.2.1",
"nextjs-progressbar": "^0.0.16",
"nextjs-redirect": "^6.0.1",
"postcss": "^8.4.32",
"postcss": "^8.4.33",
"react-content-loader": "^6.2.1",
"react-h5-audio-player": "^3.9.1",
"react-highlight": "^0.15.0",
"react-infinite-scroll-component": "^6.1.0",
"react-timeago": "^7.2.0",
"smoothscroll-polyfill": "^0.4.4",
"swr": "^2.2.4",
"tailwindcss": "^3.4.0",
"tailwindcss": "^3.4.1",
"ts-loader": "^9.5.1",
"typescript": "^5.3.3",
"webpack": "^5.89.0"
Expand Down
4 changes: 4 additions & 0 deletions apps/main/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Allow: /

Sitemap: https://www.ouorz.com/sitemap.xml
2 changes: 1 addition & 1 deletion apps/main/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { pageLayout } from "~/components/Page"
import List from "~/components/List"
import Top from "~/components/Top"
import getApi from "~/utilities/api"
import NextJS13Preview from "~/components/Banners/NextJS13Preview"
// import NextJS13Preview from "~/components/Banners/NextJS13Preview"
import YearOfReformation from "~/components/Banners/YearOfReformation"

const GREETINGS = [" there, it's Tony", ", Tony here", ", I'm Tony"]
Expand Down
39 changes: 39 additions & 0 deletions apps/main/src/pages/sitemap.xml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import getApi from "~/utilities/api"

function generateSiteMap(postIDs: number[]) {
return `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${postIDs
.map((id) => {
return `
<url>
<loc>${`https://www.ouorz.com/${id}`}</loc>
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
`
})
.join("")}
</urlset>
`
}

function SiteMap() {}

export async function getServerSideProps({ res }) {
const request = await fetch(getApi({ searchIndexes: true }))
const indexes = await request.json()

const postIDs: number[] = indexes["ids"]
const sitemap = generateSiteMap(postIDs)

res.setHeader("Content-Type", "text/xml")
res.write(sitemap)
res.end()

return {
props: {},
}
}

export default SiteMap
2 changes: 1 addition & 1 deletion apps/main/src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ h5 {
.nexment-emoji-section
.nexment-emoji-section-header
b {
@apply dark:text-white;
@apply dark:!text-white;
}

.nexment-comments-div .nexment-comments-title h5 {
Expand Down
2 changes: 1 addition & 1 deletion apps/wordpress/wp-content/themes/peg/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
<meta name="robots" content="noindex, nofollow">
</head>
<body>
<body>
Loading

0 comments on commit c701be8

Please sign in to comment.