Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions apps/docs/scripts/compile-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ const SYNTAX_THEME_FILE = path.resolve(
DOCS_ROOT,
'../../packages/emcn/src/components/code/syntax-theme.ts'
)
/**
* Files whose change can alter every page's output: their content keys the compile cache, and
* `--watch` rebuilds when any of them changes.
*/
const PIPELINE_FILES = [
import.meta.filename,
path.join(DOCS_ROOT, 'lib/content/compile.ts'),
path.join(DOCS_ROOT, 'lib/content/markdown.ts'),
path.join(DOCS_ROOT, 'lib/content/output.ts'),
path.join(DOCS_ROOT, 'lib/shiki-theme.ts'),
SYNTAX_THEME_FILE,
path.join(DOCS_ROOT, 'components/workflow-preview/examples.ts'),
path.join(DOCS_ROOT, 'components/workflow-preview/block-display-workflows.ts'),
path.join(DOCS_ROOT, 'package.json'),
// Integration pages and their index expand catalog content and FAQs from these.
path.join(DOCS_ROOT, 'lib/integrations/seo.ts'),
path.join(DOCS_ROOT, 'lib/integrations/seo-overrides.ts'),
path.join(DOCS_ROOT, '../../packages/deployment-config/src/integrations.json'),
path.join(DOCS_ROOT, '../../packages/deployment-config/src/integration-totals.ts'),
]
const CONTENT_ROOT = path.join(DOCS_ROOT, 'content/docs')
const OUTPUT_ROOT = path.join(DOCS_ROOT, '.content')
const MAX_CONTENT_BYTES = 64 * 1024 * 1024
Expand Down Expand Up @@ -197,24 +217,8 @@ function validateMedia(relative: string, mediaPaths: string[]) {

async function generate() {
await mkdir(path.join(OUTPUT_ROOT, 'pages'), { recursive: true })
const pipelineFiles = [
import.meta.filename,
path.join(DOCS_ROOT, 'lib/content/compile.ts'),
path.join(DOCS_ROOT, 'lib/content/markdown.ts'),
path.join(DOCS_ROOT, 'lib/content/output.ts'),
path.join(DOCS_ROOT, 'lib/shiki-theme.ts'),
SYNTAX_THEME_FILE,
path.join(DOCS_ROOT, 'components/workflow-preview/examples.ts'),
path.join(DOCS_ROOT, 'components/workflow-preview/block-display-workflows.ts'),
path.join(DOCS_ROOT, 'package.json'),
/** Integration pages and their index expand catalog content and FAQs from these. */
path.join(DOCS_ROOT, 'lib/integrations/seo.ts'),
path.join(DOCS_ROOT, 'lib/integrations/seo-overrides.ts'),
path.join(DOCS_ROOT, '../../packages/deployment-config/src/integrations.json'),
path.join(DOCS_ROOT, '../../packages/deployment-config/src/integration-totals.ts'),
]
const pipelineHash = hash(
(await Promise.all(pipelineFiles.map((file) => readFile(file, 'utf8')))).join('\n')
(await Promise.all(PIPELINE_FILES.map((file) => readFile(file, 'utf8')))).join('\n')
)
const previous = await readCache()
const cache: CompiledCache = { pipeline: pipelineHash, files: {} }
Expand Down Expand Up @@ -473,22 +477,30 @@ if (process.argv.includes('--watch')) {
void refresh()
}, 150)
}
const pipelineFiles = new Set(PIPELINE_FILES)
const openApiSpecs = new Set<string>(OPENAPI_SPEC_FILES)
watch(DOCS_ROOT, { recursive: true }, (_, filename) => {
const changed = filename?.toString().replaceAll('\\', '/') ?? ''
if (
!changed.startsWith('content/') &&
!changed.startsWith('lib/content/') &&
!changed.startsWith('lib/search/') &&
!changed.startsWith('components/workflow-preview/') &&
!['scripts/compile-content.ts', 'lib/shiki-theme.ts', ...OPENAPI_SPEC_FILES].includes(changed)
!openApiSpecs.has(changed) &&
!pipelineFiles.has(path.join(DOCS_ROOT, changed))
)
return
scheduleRefresh()
})
/* Editors save by replacing the file, which ends a watch on the file itself; watch its folder. */
watch(path.dirname(SYNTAX_THEME_FILE), (_, filename) => {
if (filename?.toString() === path.basename(SYNTAX_THEME_FILE)) scheduleRefresh()
})
// Pipeline files outside the docs tree: editors save by replacing a file, which ends a watch on
// the file itself, so each one's folder is watched instead.
const outsideDocs = (folder: string) => path.relative(DOCS_ROOT, folder).startsWith('..')
for (const folder of new Set(PIPELINE_FILES.map((file) => path.dirname(file)))) {
if (!outsideDocs(folder)) continue
watch(folder, (_, filename) => {
if (filename && pipelineFiles.has(path.join(folder, filename.toString()))) scheduleRefresh()
})
}
logger.info('Watching documentation source')
await refresh()
} else await generate()
7 changes: 6 additions & 1 deletion apps/sim/app/_shell/consent/consent-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ export function ConsentBanner() {
Necessary cookies keep Sim working. Optional cookies help us understand usage, measure
campaigns, and personalize ads on other sites. You can change or withdraw consent at
any time in Privacy settings or through our{' '}
<a href={`${SIM_SITE_URL}/cookie-policy`} className={CONSENT_LINK_CLASS}>
<a
href={`${SIM_SITE_URL}/cookie-policy`}
target='_blank'
rel='noopener noreferrer'
className={CONSENT_LINK_CLASS}
>
Cookie Policy
</a>
.
Expand Down
9 changes: 6 additions & 3 deletions apps/sim/lib/website/homepage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ describe('fetchWebsiteHomepage', () => {
['noindex', 'noindex'],
['noindex, nofollow', 'noindex, nofollow'],
['NoIndex,max-snippet:-1', 'noindex, max-snippet:-1'],
['noindex, unavailable_after: 2027-01-01', null],
['googlebot: noindex', null],
['noindex, unavailable_after: 2027-01-01', 'noindex'],
['googlebot: noindex', 'noindex'],
['googlebot: none', 'noindex'],
['index, unavailable_after: 2027-01-01', null],
['max-image-preview:none, unavailable_after: 2027-01-01', null],
['noindex\nSet-Cookie: x=1', null],
])(
'passes on the website indexing directives only when all are known: %j',
'passes on the website indexing directives when all are known, and a noindex in any case: %j',
async (tag, expected) => {
const upstream = await startUpstream((response) => {
response.writeHead(200, {
Expand Down
15 changes: 12 additions & 3 deletions apps/sim/lib/website/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ interface WebsiteHomepage {
body: string
/** The website's page policy; Markdown is not rendered as a page and carries none. */
contentSecurityPolicy: string | null
/** The website's indexing directives (`X-Robots-Tag`), when they are all known directives. */
/** The website's indexing directives (`X-Robots-Tag`), when known, or `noindex` when it asked for one. */
robotsTag: string | null
}

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

/**
* A `noindex` or `none`, alone or scoped to one crawler (`googlebot: noindex`); the value of a
* `max-*:` limit (`max-image-preview:none`) is not one.
*/
const NOINDEX_DIRECTIVE = /^(?:(?!max-)[\w-]+:\s*)?(?:noindex|none)$/

/**
* The website's `X-Robots-Tag` when every directive in it is a known one, so its indexing choice
* (e.g. `noindex` on a non-indexable build) holds at `/` too without passing anything else on.
* A header with an unknown directive is not passed on, but a `noindex` in it still is, as a plain
* `noindex`: `/` can only end up stricter than the website asked, never more indexable.
*/
function readRobotsTag(value: string | null): string | null {
if (!value) return null
const directives = value.split(',').map((directive) => directive.trim().toLowerCase())
const known = directives.every(
(directive) => ROBOTS_DIRECTIVES.has(directive) || ROBOTS_LIMIT_DIRECTIVE.test(directive)
)
return known ? directives.join(', ') : null
if (known) return directives.join(', ')
return directives.some((directive) => NOINDEX_DIRECTIVE.test(directive)) ? 'noindex' : null
}

/**
Expand Down
Loading