Skip to content

Commit bff16cc

Browse files
authored
Merge pull request #1447 from datum-cloud/fix/gsc-crawled-not-indexed
fix: block Mintlify asset crawling and mark .md endpoints noindex
2 parents 4bc5d01 + 9c9e7a5 commit bff16cc

15 files changed

Lines changed: 67 additions & 19 deletions

public/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ User-agent: *
22
Allow: /
33
Disallow: /admin
44
Disallow: /api
5+
Disallow: /docs/_next/
6+
Disallow: /mintlify-assets/_next/
57
Crawl-delay: 10
68
Content-Signal: ai-train=no, search=yes, ai-input=no
79

src/pages/[...mdslug].md.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import type { APIRoute, GetStaticPaths } from 'astro';
1313
import { getEntry } from 'astro:content';
1414
import { getMarkdownRegistry } from '@utils/markdownRegistry';
15-
import { renderEntryMarkdown } from '@utils/pageMarkdown';
15+
import { markdownSeoHeaders, renderEntryMarkdown } from '@utils/pageMarkdown';
1616

1717
export const getStaticPaths: GetStaticPaths = async () => {
1818
const registry = await getMarkdownRegistry();
@@ -37,17 +37,19 @@ export const GET: APIRoute = async ({ props }) => {
3737
);
3838
if (!entry) return new Response('Not found', { status: 404 });
3939

40+
const canonicalUrl = `https://www.datum.net${urlPath}/`;
4041
const body = renderEntryMarkdown(entry, {
4142
// Demote body headings so a body-level H1 doesn't compete with the
4243
// frontmatter title. Safe for all pages — pages without a body H1
4344
// are unaffected.
4445
demoteHeadings: true,
45-
sourceUrl: `https://www.datum.net${urlPath}/`,
46+
sourceUrl: canonicalUrl,
4647
});
4748
return new Response(body, {
4849
headers: {
4950
'Content-Type': 'text/markdown; charset=utf-8',
5051
'Cache-Control': 'public, max-age=300, s-maxage=300',
52+
...markdownSeoHeaders(canonicalUrl),
5153
},
5254
});
5355
} catch (error) {

src/pages/blog.md.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { APIRoute } from 'astro';
77
import { getEntry } from 'astro:content';
88
import { fetchStrapiArticles } from '@libs/strapi';
99
import type { StrapiArticle } from '@libs/strapi';
10-
import { renderEntryMarkdown } from '@utils/pageMarkdown';
10+
import { markdownSeoHeaders, renderEntryMarkdown } from '@utils/pageMarkdown';
1111
import { STRAPI_SSR_CACHE_CONTROL } from '@libs/strapi/httpCache';
1212

1313
function formatDate(d?: string): string {
@@ -35,14 +35,16 @@ export const GET: APIRoute = async () => {
3535
list.push(`- [${a.title}](${url})${meta}${a.description ? ` - ${a.description}` : ''}`);
3636
}
3737

38+
const canonicalUrl = 'https://www.datum.net/blog/';
3839
const body = renderEntryMarkdown(page ?? { data: { title: 'Blog' } }, {
3940
trailingSections: [list.join('\n')],
40-
sourceUrl: 'https://www.datum.net/blog/',
41+
sourceUrl: canonicalUrl,
4142
});
4243
return new Response(body, {
4344
headers: {
4445
'Content-Type': 'text/markdown; charset=utf-8',
4546
'Cache-Control': STRAPI_SSR_CACHE_CONTROL,
47+
...markdownSeoHeaders(canonicalUrl),
4648
},
4749
});
4850
} catch (error) {

src/pages/blog/[slug].md.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const prerender = false;
88
import type { APIRoute } from 'astro';
99
import { ensureStrapiArticleDetail } from '@libs/strapi';
1010
import { STRAPI_SSR_CACHE_CONTROL } from '@libs/strapi/httpCache';
11+
import { markdownSeoHeaders } from '@utils/pageMarkdown';
1112

1213
export const GET: APIRoute = async ({ params }) => {
1314
const slug = params.slug;
@@ -29,10 +30,12 @@ export const GET: APIRoute = async ({ params }) => {
2930
const title = article.title ? `# ${article.title}\n\n` : '';
3031
const description = article.description ? `> ${article.description}\n\n` : '';
3132

33+
const canonicalUrl = `https://www.datum.net/blog/${slug}/`;
3234
return new Response(`${title}${description}${body}`, {
3335
headers: {
3436
'Content-Type': 'text/markdown; charset=utf-8',
3537
'Cache-Control': STRAPI_SSR_CACHE_CONTROL,
38+
...markdownSeoHeaders(canonicalUrl),
3639
},
3740
});
3841
} catch (error) {

src/pages/brand.md.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { APIRoute } from 'astro';
22
import { getCollection, getEntry } from 'astro:content';
3-
import { renderEntryMarkdown } from '@utils/pageMarkdown';
3+
import { markdownSeoHeaders, renderEntryMarkdown } from '@utils/pageMarkdown';
44

55
interface BrandSection {
66
id: string;
@@ -22,15 +22,17 @@ export const GET: APIRoute = async () => {
2222
list.push(`- [${s.data.title ?? slug}](/brand/${slug}/)${desc}`);
2323
}
2424

25+
const canonicalUrl = 'https://www.datum.net/brand/';
2526
const body = renderEntryMarkdown(page ?? { data: { title: 'Brand' } }, {
2627
skipBody: true,
2728
trailingSections: sections.length ? [list.join('\n')] : [],
28-
sourceUrl: 'https://www.datum.net/brand/',
29+
sourceUrl: canonicalUrl,
2930
});
3031
return new Response(body, {
3132
headers: {
3233
'Content-Type': 'text/markdown; charset=utf-8',
3334
'Cache-Control': 'public, max-age=300, s-maxage=300',
35+
...markdownSeoHeaders(canonicalUrl),
3436
},
3537
});
3638
} catch (error) {

src/pages/changelog.md.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { APIRoute } from 'astro';
22
import { getCollection, getEntry } from 'astro:content';
3-
import { renderEntryMarkdown, stripMdxToMarkdown } from '@utils/pageMarkdown';
3+
import { markdownSeoHeaders, renderEntryMarkdown, stripMdxToMarkdown } from '@utils/pageMarkdown';
44

55
interface ChangelogEntry {
66
data: { title?: string; description?: string; date?: string | Date };
@@ -38,14 +38,16 @@ export const GET: APIRoute = async () => {
3838
sections.push('');
3939
}
4040

41+
const canonicalUrl = 'https://www.datum.net/changelog/';
4142
const body = renderEntryMarkdown(index ?? { data: { title: 'Changelog' } }, {
4243
trailingSections: sections.length ? [sections.join('\n').trim()] : [],
43-
sourceUrl: 'https://www.datum.net/changelog/',
44+
sourceUrl: canonicalUrl,
4445
});
4546
return new Response(body, {
4647
headers: {
4748
'Content-Type': 'text/markdown; charset=utf-8',
4849
'Cache-Control': 'public, max-age=300, s-maxage=300',
50+
...markdownSeoHeaders(canonicalUrl),
4951
},
5052
});
5153
} catch (error) {

src/pages/download/[slug].md.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// route the ".md" variant specifically.
66
import type { APIRoute, GetStaticPaths } from 'astro';
77
import { getEntry, getCollection } from 'astro:content';
8-
import { renderEntryMarkdown } from '@utils/pageMarkdown';
8+
import { markdownSeoHeaders, renderEntryMarkdown } from '@utils/pageMarkdown';
99

1010
export const getStaticPaths: GetStaticPaths = async () => {
1111
const entries = (await getCollection('download')) as Array<{ id: string }>;
@@ -17,14 +17,16 @@ export const GET: APIRoute = async ({ props }) => {
1717
try {
1818
const entry = await getEntry('download', entryId);
1919
if (!entry) return new Response('Not found', { status: 404 });
20+
const canonicalUrl = `https://www.datum.net/download/${entryId}/`;
2021
const body = renderEntryMarkdown(entry, {
2122
demoteHeadings: true,
22-
sourceUrl: `https://www.datum.net/download/${entryId}/`,
23+
sourceUrl: canonicalUrl,
2324
});
2425
return new Response(body, {
2526
headers: {
2627
'Content-Type': 'text/markdown; charset=utf-8',
2728
'Cache-Control': 'public, max-age=300, s-maxage=300',
29+
...markdownSeoHeaders(canonicalUrl),
2830
},
2931
});
3032
} catch (err) {

src/pages/events.md.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { APIRoute } from 'astro';
22
import { getCollection, getEntry } from 'astro:content';
3-
import { renderEntryMarkdown } from '@utils/pageMarkdown';
3+
import { markdownSeoHeaders, renderEntryMarkdown } from '@utils/pageMarkdown';
44

55
interface EventEntry {
66
id: string;
@@ -61,14 +61,16 @@ export const GET: APIRoute = async () => {
6161
'- [Alt Cloud Meetups](/events/alt-cloud-meetups/)'
6262
);
6363

64+
const canonicalUrl = 'https://www.datum.net/events/';
6465
const body = renderEntryMarkdown(page ?? { data: { title: 'Events' } }, {
6566
trailingSections: [sections.join('\n')],
66-
sourceUrl: 'https://www.datum.net/events/',
67+
sourceUrl: canonicalUrl,
6768
});
6869
return new Response(body, {
6970
headers: {
7071
'Content-Type': 'text/markdown; charset=utf-8',
7172
'Cache-Control': 'public, max-age=300, s-maxage=300',
73+
...markdownSeoHeaders(canonicalUrl),
7274
},
7375
});
7476
} catch (error) {

src/pages/handbook.md.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { APIRoute } from 'astro';
22
import { getEntry } from 'astro:content';
3-
import { renderEntryMarkdown } from '@utils/pageMarkdown';
3+
import { markdownSeoHeaders, renderEntryMarkdown } from '@utils/pageMarkdown';
44

55
interface HandbookSection {
66
slug: string;
@@ -21,14 +21,16 @@ export const GET: APIRoute = async () => {
2121
}
2222
}
2323

24+
const canonicalUrl = 'https://www.datum.net/handbook/';
2425
const body = renderEntryMarkdown(index ?? { data: { title: 'Handbook' } }, {
2526
trailingSections: sections.length ? [sections.join('\n')] : [],
26-
sourceUrl: 'https://www.datum.net/handbook/',
27+
sourceUrl: canonicalUrl,
2728
});
2829
return new Response(body, {
2930
headers: {
3031
'Content-Type': 'text/markdown; charset=utf-8',
3132
'Cache-Control': 'public, max-age=300, s-maxage=300',
33+
...markdownSeoHeaders(canonicalUrl),
3234
},
3335
});
3436
} catch (error) {

src/pages/locations.md.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { APIRoute } from 'astro';
44
import { getEntry } from 'astro:content';
55
import locations from '@data/locations.json';
66
import { toAsciiMarkdown } from '@utils/markdownExport';
7+
import { markdownSeoHeaders } from '@utils/pageMarkdown';
78

89
interface Location {
910
regionCode: string;
@@ -65,6 +66,7 @@ export const GET: APIRoute = async () => {
6566
}
6667
}
6768

69+
const canonicalUrl = 'https://www.datum.net/locations/';
6870
sections.push(
6971
'',
7072
'## Why these cities',
@@ -73,7 +75,7 @@ export const GET: APIRoute = async () => {
7375
'',
7476
'---',
7577
'',
76-
'Source: <https://www.datum.net/locations/>',
78+
`Source: <${canonicalUrl}>`,
7779
''
7880
);
7981

@@ -82,6 +84,7 @@ export const GET: APIRoute = async () => {
8284
headers: {
8385
'Content-Type': 'text/markdown; charset=utf-8',
8486
'Cache-Control': 'public, max-age=300, s-maxage=300',
87+
...markdownSeoHeaders(canonicalUrl),
8588
},
8689
});
8790
} catch (error) {

0 commit comments

Comments
 (0)