-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
description: Ladybird browser initiative launched | ||
date: 2024-07-20 | ||
draft: true | ||
--- | ||
|
||
# Content goes here | ||
|
||
This is a test of the draft feature | ||
|
||
This page will only appear in development, and not in production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { expect, test, describe } from "bun:test"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
const rootDir: string = path.join(__dirname, "../"); | ||
|
||
describe("Newsletters", () => { | ||
const srcDir = path.join(rootDir, "/src/content/newsletters"); | ||
const distDir = path.join(rootDir, "/dist/newsletter"); | ||
|
||
const mdFiles = fs | ||
.readdirSync(srcDir) | ||
.filter((file) => file.endsWith(".mdx")); | ||
|
||
test("Draft pages should be excluded in build", async () => { | ||
mdFiles.forEach((file) => { | ||
const filePath = path.join(srcDir, file); | ||
const htmlFile = file.replace(".mdx", "/index.html"); | ||
const htmlFilePath = path.join(distDir, htmlFile); | ||
|
||
const fileContent = fs.readFileSync(filePath); | ||
if (fileContent.toString().includes("draft: true")) { | ||
expect(fs.existsSync(htmlFilePath)).toBe(false); | ||
} else { | ||
expect(fs.existsSync(htmlFilePath)).toBe(true); | ||
} | ||
}); | ||
}); | ||
}); |