Skip to content

Commit

Permalink
fix: seo issues (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor authored Nov 12, 2023
1 parent 1ee6ae9 commit d8ee667
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 152 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Sitemaps
public/*.xml

# dependencies
/node_modules
/.pnp
Expand Down
51 changes: 51 additions & 0 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module.exports = {
// These are not tracked for now
changefreq: null,
autoLastmod: false,
priority: null,

generateRobotsTxt: false,
siteUrl: "https://forbole.com",
additionalPaths: async () => {
if (!process.env.GHOST_PRIVATE_KEY || !process.env.NEXT_PUBLIC_GHOST_API)
return [];

const GhostAdminAPI = require("@tryghost/admin-api");

const ghostAdminApi = new GhostAdminAPI({
key: process.env.GHOST_PRIVATE_KEY,
url: process.env.NEXT_PUBLIC_GHOST_API,
version: "v3.0",
});

// The pagination will not be necessary for a while
const getPosts = () =>
ghostAdminApi.posts.browse({
fields: "slug",
filter: "status:published",
limit: 1000,
page: 1,
});

const getTags = () =>
ghostAdminApi.tags.browse({
limit: 1000,
fields: "slug",
});

const [tags, posts] = await Promise.all([getTags(), getPosts()]);

return posts
.map((p) => {
if (!p.slug) return null;
if (p.slug.includes("page/")) return null;

return `/blog/${p.slug}`;
})
.concat(tags.map((t) => `/tag/${t.slug}`))
.filter(Boolean)
.map((loc) => ({
loc,
}));
},
};
14 changes: 14 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const nextTranslate = require("next-translate");

const localePrefixes = ["", "/zh-HK", "/zh-CN"];

module.exports = nextTranslate({
poweredByHeader: false,
nextConfig: {
Expand All @@ -11,6 +13,18 @@ module.exports = nextTranslate({
images: {
unoptimized: true,
},
redirects: async () => [
{
destination: "/zh-HK/:path*",
permanent: false,
source: "/zh/:path*",
},
...localePrefixes.map((prefix) => ({
destination: `${prefix}/staking-service`,
permanent: false,
source: `${prefix}/native-staking`,
})),
],
webpack: (config) => {
config.module.rules.push({
test: /\.svg$/,
Expand Down
Loading

0 comments on commit d8ee667

Please sign in to comment.