Skip to content

Commit 46da897

Browse files
committed
fix: ignore draft docs in link checker
1 parent 1c3827e commit 46da897

6 files changed

Lines changed: 157 additions & 4 deletions

File tree

.github/workflows/validate-docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
uses: actions/setup-node@v4
3535
with:
3636
node-version: '18'
37+
cache: 'npm'
38+
39+
- name: Install Node dependencies
40+
run: npm ci
3741

3842
- name: Post initial status comment
3943
id: initial-comment

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.iws
77
.idea_modules/
88
out/
9+
node_modules/
910
images/.DS_Store
1011
.DS_Store
1112
.env/

package-lock.json

Lines changed: 123 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "mintlify-docs",
3+
"version": "1.0.0",
4+
"description": "Lightdash documentation",
5+
"private": true,
6+
"scripts": {},
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/lightdash/mintlify-docs.git"
10+
},
11+
"type": "commonjs",
12+
"dependencies": {
13+
"gray-matter": "^4.0.3"
14+
}
15+
}

scripts/check-links.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
const fs = require('fs');
1010
const path = require('path');
11+
const matter = require('gray-matter');
1112

1213
const CHECK_EXTERNAL = process.argv.includes('--external');
1314

@@ -41,6 +42,11 @@ function findMDXFiles(dir, fileList = []) {
4142
return fileList;
4243
}
4344

45+
function hasDraftTitle(content) {
46+
const title = matter(content).data.title;
47+
return typeof title === 'string' && title.toLowerCase().includes('draft');
48+
}
49+
4450
function extractLinks(content, filePath) {
4551
const links = [];
4652

@@ -282,9 +288,13 @@ async function main() {
282288

283289
const mdxFiles = findMDXFiles('.');
284290
const excludedPaths = ['node_modules', '.git', 'CONTRIBUTING.md'];
285-
const filteredFiles = mdxFiles.filter(file =>
286-
!excludedPaths.some(excluded => file.includes(excluded))
287-
);
291+
const filteredFiles = mdxFiles.filter(file => {
292+
if (excludedPaths.some(excluded => file.includes(excluded))) {
293+
return false;
294+
}
295+
296+
return !hasDraftTitle(fs.readFileSync(file, 'utf8'));
297+
});
288298

289299
const brokenLinks = [];
290300
const externalLinks = [];

timezones-draft.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Working with timezones in Lightdash"
2+
title: "Draft: Working with timezones in Lightdash"
33
description: "Hidden draft: how to model warehouse data and use Lightdash so that timezones behave predictably."
44
hidden: true
55
---

0 commit comments

Comments
 (0)