Skip to content

Commit c22d414

Browse files
committed
fix(library): noindex direct Markdown article URLs on self-hosted deployments and diff IndexNow from the last submitted revision
1 parent 65564a5 commit c22d414

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ jobs:
656656
continue-on-error: true
657657
permissions:
658658
contents: read
659+
actions: read
659660
steps:
660661
- name: Checkout code
661662
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
@@ -665,12 +666,28 @@ jobs:
665666
with:
666667
bun-version: 1.4.4
667668

668-
# The diff needs only the two trees, so the previous head is fetched alone. A push that
669-
# created the branch has an all-zero `before`, which the script skips.
669+
# Diff from the head of the last earlier run whose submission succeeded, not the previous
670+
# push: a push that never deployed, or whose submission failed, would otherwise drop its
671+
# changed URLs for good. Falls back to the previous push when no such run is in view. The
672+
# diff needs only the two trees, so that one commit is fetched alone; an all-zero `before`
673+
# (the branch's first push) has no base, which the script skips.
670674
- name: Submit changed URLs to IndexNow
671675
env:
672-
BASE_SHA: ${{ github.event.before }}
676+
GH_TOKEN: ${{ github.token }}
677+
PUSH_BEFORE: ${{ github.event.before }}
673678
run: |
679+
BASE_SHA=""
680+
while read -r run_id head_sha; do
681+
conclusion="$(gh api --paginate "repos/$GITHUB_REPOSITORY/actions/runs/$run_id/jobs?per_page=100" \
682+
--jq '.jobs[] | select(.name == "indexnow") | .conclusion')"
683+
if [[ "$conclusion" == "success" ]]; then
684+
BASE_SHA="$head_sha"
685+
break
686+
fi
687+
done < <(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/ci.yml/runs?branch=main&event=push&per_page=30" \
688+
--jq ".workflow_runs[] | select(.id < $GITHUB_RUN_ID) | \"\\(.id) \\(.head_sha)\"")
689+
BASE_SHA="${BASE_SHA:-$PUSH_BEFORE}"
690+
echo "Submitting URLs changed in $BASE_SHA..$GITHUB_SHA"
674691
if [[ ! "$BASE_SHA" =~ ^0+$ ]]; then
675692
git fetch --no-tags --depth=1 origin "$BASE_SHA"
676693
fi

‎apps/sim/lib/landing/routes.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ const MARKETING_DOCUMENT_PATHS: ReadonlySet<string> = new Set([
7070
'/changelog.xml',
7171
])
7272

73+
/** Top-level route segments that republish landing content as documents, e.g. `/library.md/<slug>`. */
74+
const MARKETING_DOCUMENT_SEGMENTS: ReadonlySet<string> = new Set(['library.md'])
75+
7376
/** Whether a pathname serves marketing content: a landing page or a marketing document. */
7477
export function isMarketingPath(pathname: string): boolean {
75-
return isLandingPath(pathname) || MARKETING_DOCUMENT_PATHS.has(pathname)
78+
return (
79+
isLandingPath(pathname) ||
80+
MARKETING_DOCUMENT_PATHS.has(pathname) ||
81+
MARKETING_DOCUMENT_SEGMENTS.has(pathname.split('/')[1])
82+
)
7683
}

‎apps/sim/proxy.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ describe('proxy indexing policy', () => {
179179
expect(robotsTag('/llms.txt')).toBe('noindex, nofollow')
180180
expect(robotsTag('/llms-full.txt')).toBe('noindex, nofollow')
181181
expect(robotsTag('/changelog.xml')).toBe('noindex, nofollow')
182+
expect(robotsTag('/library.md/some-article')).toBe('noindex, nofollow')
182183
})
183184

184185
it('leaves the marketing pages and documents of the hosted deployment indexable', () => {
@@ -189,6 +190,7 @@ describe('proxy indexing policy', () => {
189190
expect(robotsTag('/llms.txt')).toBeNull()
190191
expect(robotsTag('/llms-full.txt')).toBeNull()
191192
expect(robotsTag('/changelog.xml')).toBeNull()
193+
expect(robotsTag('/library.md/some-article')).toBeNull()
192194
})
193195

194196
it('leaves a self-hosted non-landing public page indexable', () => {
@@ -216,6 +218,7 @@ describe('proxy matcher', () => {
216218
expect(matches('/llms.txt')).toBe(true)
217219
expect(matches('/llms-full.txt')).toBe(true)
218220
expect(matches('/changelog.xml')).toBe(true)
221+
expect(matches('/library.md/some-article')).toBe(true)
219222
})
220223

221224
it('still runs for every other API route', () => {

0 commit comments

Comments
 (0)