Skip to content

Commit

Permalink
Docs sitemap
Browse files Browse the repository at this point in the history
adeira-source-id: fbd5ae6011161ed8a98610f795b83dd1fef3c3f2
  • Loading branch information
itsdouges authored and triplex-bot committed Sep 27, 2024
1 parent 2f2f074 commit 252b2ff
Show file tree
Hide file tree
Showing 4 changed files with 303 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "GPL-3.0",
"scripts": {
"build": "NEXT_PUBLIC_URL=https://triplex-docs-$(git branch --show-current)-try-triplex.vercel.app next build",
"build:sitemap": "ts-node ./scripts/generate-sitemap.ts",
"dev": "NEXT_PUBLIC_URL=localhost:3000 next",
"typedef": "tsc"
},
Expand All @@ -28,5 +29,8 @@
"three": "^0.168.0",
"typescript": "^5.6.2",
"zustand": "^4.3.2"
},
"devDependencies": {
"readdirp": "^3.6.0"
}
}
206 changes: 206 additions & 0 deletions apps/docs/public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://triplex.dev/download</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>yearly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://triplex.dev/</loc>
<lastmod>2024-06-21 11:44:48 +1000</lastmod>
<changefreq>yearly</changefreq>
<priority>1</priority>
</url>
<url>
<loc>https://triplex.dev/pricing</loc>
<lastmod>2023-08-07 19:32:37 +1000</lastmod>
<changefreq>yearly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/legal/privacy-policy</loc>
<lastmod>2023-11-01 12:41:25 +1100</lastmod>
<changefreq>yearly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/faq</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/overview</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/supporting/component-outside-of-project-files</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/supporting/installing-dependencies</loc>
<lastmod>2023-08-07 19:32:37 +1000</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/supporting/resolve-type-error-assets</loc>
<lastmod>2023-11-02 09:11:34 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/supporting/saving-outside-cwd</loc>
<lastmod>2023-12-23 18:33:40 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/setup/linux</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/setup/macos</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/setup/manual-setup</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/setup/overview</loc>
<lastmod>2023-12-27 15:58:39 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/setup/windows</loc>
<lastmod>2024-06-25 20:36:55 +1000</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/guides/common-gotchas</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/guides/component-controls</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/guides/glsl-support</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/guides/javascript-projects</loc>
<lastmod>2024-01-18 09:34:02 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/guides/leva-controls</loc>
<lastmod>2024-01-18 09:34:02 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/guides/provider-controls</loc>
<lastmod>2024-02-13 08:50:33 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/get-started/declaring-props</loc>
<lastmod>2024-06-25 20:36:55 +1000</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/get-started/settings</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/docs/get-started/user-interface</loc>
<lastmod>2024-01-15 10:30:42 +1100</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://triplex.dev/blog/threejs-halloween-challenge</loc>
<lastmod>2023-10-13 11:15:38 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.56.0-live-editing-props</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.57.0-edit-children-elements</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.58.0-provider-component-ui</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.59.0-backend-stability</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.60.0-element-actions</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.61.0-drag-n-drop-file-tabs</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.62.0-the-one-with-linux</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.63.0-new-year-new-features</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://triplex.dev/blog/v0.64.0-shared-buffer-array-canvas-frame</loc>
<lastmod>2024-01-16 13:24:09 +1100</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
</urlset>
70 changes: 70 additions & 0 deletions apps/docs/scripts/generate-sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) Michael Dougall. All rights reserved.
*
* This source code is licensed under the GPL-3.0 license found in the LICENSE
* file in the root directory of this source tree.
*/
import { execSync } from "node:child_process";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import readdirp from "readdirp";

const root = join(process.cwd(), "pages");
const sitemapLoc = join(process.cwd(), "public", "sitemap.xml");

function getLastModifiedDateTime(fullPath: string) {
const result = execSync(
`git log -1 --pretty="format:%ci" ${fullPath}`,
).toString();
return result || undefined;
}

const changeHints = [
["/blog", "weekly"],
["/docs", "monthly"],
] as const;

const priorityHints = [
["/blog/", 0.6],
["/download", 0.9],
] as const;

async function main() {
const sitemap = [];

for await (const entry of readdirp(root)) {
if (entry.path.endsWith(".mdx")) {
const path = entry.path.replace(".mdx", "").replace("index", "");
const url = "https://triplex.dev/" + path;

sitemap.push({
changeFrequency:
changeHints.find(([hint]) => url.includes(hint))?.[1] ?? "yearly",
lastModified: getLastModifiedDateTime(entry.fullPath),
priority: path
? priorityHints.find(([hint]) => url.includes(hint))?.[1] ?? 0.5
: // Root gets immediate 1 priority.
1,
url,
});
}
}

const xml = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${sitemap
.map((url) => {
return `<url>
<loc>${url.url}</loc>
<lastmod>${url.lastModified}</lastmod>
<changefreq>${url.changeFrequency}</changefreq>
<priority>${url.priority}</priority>
</url>`;
})
.join("\n ")}
</urlset>
`;

await writeFile(sitemapLoc, xml);
}

main();
23 changes: 23 additions & 0 deletions apps/docs/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"moduleResolution": "node",
"skipLibCheck": true,
"strict": true,
"jsx": "preserve",
"allowJs": true,
"noEmit": true,
"incremental": true,
"module": "CommonJS",
"resolveJsonModule": true,
"types": ["@react-three/fiber"]
},
"ts-node": {
"transpileOnly": true,
"swc": true
},
"include": ["."]
}

0 comments on commit 252b2ff

Please sign in to comment.