Skip to content

Commit a73f1e5

Browse files
committed
fix(landing): keep the website's noindex at /, open the cookie policy in a new tab, and rebuild docs on catalog changes
- readRobotsTag still passes the website's X-Robots-Tag only when every directive is known, but a header with an unknown directive now keeps a noindex (or none, also when scoped to one crawler) as a plain noindex, so / can only end up stricter than the website asked. - The consent banner's Cookie Policy link now leaves for the website, so it opens in a new tab like the settings link, keeping the visitor's place. - compile-content's pipeline inputs are one module list that keys the cache and drives --watch, so edits to the integration FAQ overrides and catalog rebuild, including the deployment-config files outside the docs tree.
1 parent fdddeb2 commit a73f1e5

4 files changed

Lines changed: 54 additions & 29 deletions

File tree

‎apps/docs/scripts/compile-content.ts‎

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@ const SYNTAX_THEME_FILE = path.resolve(
2424
DOCS_ROOT,
2525
'../../packages/emcn/src/components/code/syntax-theme.ts'
2626
)
27+
/**
28+
* Files whose change can alter every page's output: their content keys the compile cache, and
29+
* `--watch` rebuilds when any of them changes.
30+
*/
31+
const PIPELINE_FILES = [
32+
import.meta.filename,
33+
path.join(DOCS_ROOT, 'lib/content/compile.ts'),
34+
path.join(DOCS_ROOT, 'lib/content/markdown.ts'),
35+
path.join(DOCS_ROOT, 'lib/content/output.ts'),
36+
path.join(DOCS_ROOT, 'lib/shiki-theme.ts'),
37+
SYNTAX_THEME_FILE,
38+
path.join(DOCS_ROOT, 'components/workflow-preview/examples.ts'),
39+
path.join(DOCS_ROOT, 'components/workflow-preview/block-display-workflows.ts'),
40+
path.join(DOCS_ROOT, 'package.json'),
41+
// Integration pages and their index expand catalog content and FAQs from these.
42+
path.join(DOCS_ROOT, 'lib/integrations/seo.ts'),
43+
path.join(DOCS_ROOT, 'lib/integrations/seo-overrides.ts'),
44+
path.join(DOCS_ROOT, '../../packages/deployment-config/src/integrations.json'),
45+
path.join(DOCS_ROOT, '../../packages/deployment-config/src/integration-totals.ts'),
46+
]
2747
const CONTENT_ROOT = path.join(DOCS_ROOT, 'content/docs')
2848
const OUTPUT_ROOT = path.join(DOCS_ROOT, '.content')
2949
const MAX_CONTENT_BYTES = 64 * 1024 * 1024
@@ -197,24 +217,8 @@ function validateMedia(relative: string, mediaPaths: string[]) {
197217

198218
async function generate() {
199219
await mkdir(path.join(OUTPUT_ROOT, 'pages'), { recursive: true })
200-
const pipelineFiles = [
201-
import.meta.filename,
202-
path.join(DOCS_ROOT, 'lib/content/compile.ts'),
203-
path.join(DOCS_ROOT, 'lib/content/markdown.ts'),
204-
path.join(DOCS_ROOT, 'lib/content/output.ts'),
205-
path.join(DOCS_ROOT, 'lib/shiki-theme.ts'),
206-
SYNTAX_THEME_FILE,
207-
path.join(DOCS_ROOT, 'components/workflow-preview/examples.ts'),
208-
path.join(DOCS_ROOT, 'components/workflow-preview/block-display-workflows.ts'),
209-
path.join(DOCS_ROOT, 'package.json'),
210-
/** Integration pages and their index expand catalog content and FAQs from these. */
211-
path.join(DOCS_ROOT, 'lib/integrations/seo.ts'),
212-
path.join(DOCS_ROOT, 'lib/integrations/seo-overrides.ts'),
213-
path.join(DOCS_ROOT, '../../packages/deployment-config/src/integrations.json'),
214-
path.join(DOCS_ROOT, '../../packages/deployment-config/src/integration-totals.ts'),
215-
]
216220
const pipelineHash = hash(
217-
(await Promise.all(pipelineFiles.map((file) => readFile(file, 'utf8')))).join('\n')
221+
(await Promise.all(PIPELINE_FILES.map((file) => readFile(file, 'utf8')))).join('\n')
218222
)
219223
const previous = await readCache()
220224
const cache: CompiledCache = { pipeline: pipelineHash, files: {} }
@@ -473,22 +477,30 @@ if (process.argv.includes('--watch')) {
473477
void refresh()
474478
}, 150)
475479
}
480+
const pipelineFiles = new Set(PIPELINE_FILES)
481+
const openApiSpecs = new Set<string>(OPENAPI_SPEC_FILES)
476482
watch(DOCS_ROOT, { recursive: true }, (_, filename) => {
477483
const changed = filename?.toString().replaceAll('\\', '/') ?? ''
478484
if (
479485
!changed.startsWith('content/') &&
480486
!changed.startsWith('lib/content/') &&
481487
!changed.startsWith('lib/search/') &&
482488
!changed.startsWith('components/workflow-preview/') &&
483-
!['scripts/compile-content.ts', 'lib/shiki-theme.ts', ...OPENAPI_SPEC_FILES].includes(changed)
489+
!openApiSpecs.has(changed) &&
490+
!pipelineFiles.has(path.join(DOCS_ROOT, changed))
484491
)
485492
return
486493
scheduleRefresh()
487494
})
488-
/* Editors save by replacing the file, which ends a watch on the file itself; watch its folder. */
489-
watch(path.dirname(SYNTAX_THEME_FILE), (_, filename) => {
490-
if (filename?.toString() === path.basename(SYNTAX_THEME_FILE)) scheduleRefresh()
491-
})
495+
// Pipeline files outside the docs tree: editors save by replacing a file, which ends a watch on
496+
// the file itself, so each one's folder is watched instead.
497+
const outsideDocs = (folder: string) => path.relative(DOCS_ROOT, folder).startsWith('..')
498+
for (const folder of new Set(PIPELINE_FILES.map((file) => path.dirname(file)))) {
499+
if (!outsideDocs(folder)) continue
500+
watch(folder, (_, filename) => {
501+
if (filename && pipelineFiles.has(path.join(folder, filename.toString()))) scheduleRefresh()
502+
})
503+
}
492504
logger.info('Watching documentation source')
493505
await refresh()
494506
} else await generate()

‎apps/sim/app/_shell/consent/consent-banner.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ export function ConsentBanner() {
7474
Necessary cookies keep Sim working. Optional cookies help us understand usage, measure
7575
campaigns, and personalize ads on other sites. You can change or withdraw consent at
7676
any time in Privacy settings or through our{' '}
77-
<a href={`${SIM_SITE_URL}/cookie-policy`} className={CONSENT_LINK_CLASS}>
77+
<a
78+
href={`${SIM_SITE_URL}/cookie-policy`}
79+
target='_blank'
80+
rel='noopener noreferrer'
81+
className={CONSENT_LINK_CLASS}
82+
>
7883
Cookie Policy
7984
</a>
8085
.

‎apps/sim/lib/website/homepage.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ describe('fetchWebsiteHomepage', () => {
9292
['noindex', 'noindex'],
9393
['noindex, nofollow', 'noindex, nofollow'],
9494
['NoIndex,max-snippet:-1', 'noindex, max-snippet:-1'],
95-
['noindex, unavailable_after: 2027-01-01', null],
96-
['googlebot: noindex', null],
95+
['noindex, unavailable_after: 2027-01-01', 'noindex'],
96+
['googlebot: noindex', 'noindex'],
97+
['googlebot: none', 'noindex'],
98+
['index, unavailable_after: 2027-01-01', null],
9799
['noindex\nSet-Cookie: x=1', null],
98100
])(
99-
'passes on the website indexing directives only when all are known: %j',
101+
'passes on the website indexing directives when all are known, and a noindex in any case: %j',
100102
async (tag, expected) => {
101103
const upstream = await startUpstream((response) => {
102104
response.writeHead(200, {

‎apps/sim/lib/website/homepage.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ interface WebsiteHomepage {
5757
body: string
5858
/** The website's page policy; Markdown is not rendered as a page and carries none. */
5959
contentSecurityPolicy: string | null
60-
/** The website's indexing directives (`X-Robots-Tag`), when they are all known directives. */
60+
/** The website's indexing directives (`X-Robots-Tag`), when known, or `noindex` when it asked for one. */
6161
robotsTag: string | null
6262
}
6363

64-
/** Indexing directives that may be passed on; anything else drops the whole header. */
64+
/** Indexing directives that may be passed on as written. */
6565
const ROBOTS_DIRECTIVES = new Set([
6666
'all',
6767
'index',
@@ -76,17 +76,23 @@ const ROBOTS_DIRECTIVES = new Set([
7676
])
7777
const ROBOTS_LIMIT_DIRECTIVE = /^max-(?:snippet|image-preview|video-preview):[a-z0-9-]+$/
7878

79+
/** A `noindex` or `none`, alone or scoped to one crawler (`googlebot: noindex`). */
80+
const NOINDEX_DIRECTIVE = /(?:^|[\s:])(?:noindex|none)$/
81+
7982
/**
8083
* The website's `X-Robots-Tag` when every directive in it is a known one, so its indexing choice
8184
* (e.g. `noindex` on a non-indexable build) holds at `/` too without passing anything else on.
85+
* A header with an unknown directive is not passed on, but a `noindex` in it still is, as a plain
86+
* `noindex`: `/` can only end up stricter than the website asked, never more indexable.
8287
*/
8388
function readRobotsTag(value: string | null): string | null {
8489
if (!value) return null
8590
const directives = value.split(',').map((directive) => directive.trim().toLowerCase())
8691
const known = directives.every(
8792
(directive) => ROBOTS_DIRECTIVES.has(directive) || ROBOTS_LIMIT_DIRECTIVE.test(directive)
8893
)
89-
return known ? directives.join(', ') : null
94+
if (known) return directives.join(', ')
95+
return directives.some((directive) => NOINDEX_DIRECTIVE.test(directive)) ? 'noindex' : null
9096
}
9197

9298
/**

0 commit comments

Comments
 (0)