Skip to content

Commit a8bd78c

Browse files
committed
Astro + Starlight website build
1 parent 1c10ff3 commit a8bd78c

File tree

14 files changed

+159
-15
lines changed

14 files changed

+159
-15
lines changed

.htmltest.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# cSpell:ignore github
22
CacheExpires: 9000h # ~ 12 months
3-
DirectoryPath: build
3+
DirectoryPath: dist
44
TestFilesConcurrently: true
5+
IgnoreCanonicalBrokenLinks: true
6+
IgnoreEmptyHref: true
7+
IgnoreAltEmpty: true
58
IgnoreDirs:
9+
- analyses
610
IgnoreInternalURLs: # list of paths
711
IgnoreURLs: # list of regexes of URLs or path to be ignored
812
- ^https?://localhost
913
- \?no-link-check
14+
- \?(_PROJECT|TODO)
1015
# FIXME: temporary ignore rules
1116
- assistance\.md
1217
- LICENSE

astro.config.mjs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// @ts-check
2+
import { defineConfig } from 'astro/config';
3+
import starlight from '@astrojs/starlight';
4+
import { visit } from 'unist-util-visit';
5+
import { rewriteMdLinks } from './src/plugins/rewrite-md-links.mjs';
6+
7+
// https://astro.build/config
8+
export default defineConfig({
9+
// site: 'https://astro--cncf-techdocs.netlify.app/',
10+
integrations: [
11+
starlight({
12+
title: 'CNCF Techdocs',
13+
// favicon: 'static/img/cncf-icon-color.svg', // cSpell:disable-line
14+
customCss: ['./src/css/custom.css'],
15+
sidebar: [
16+
{
17+
label: 'Docs',
18+
collapsed: true,
19+
autogenerate: {
20+
directory: 'docs',
21+
},
22+
},
23+
{
24+
label: 'Project Analyses',
25+
collapsed: true,
26+
autogenerate: {
27+
directory: 'analyses',
28+
},
29+
},
30+
],
31+
social: [
32+
{
33+
icon: 'github',
34+
label: 'GitHub',
35+
href: 'https://github.com/withastro/starlight',
36+
},
37+
],
38+
}),
39+
],
40+
// Configure Astro's markdown handling
41+
markdown: {
42+
// Enable smartypants and other markdown features
43+
// smartypants: true,
44+
// Configure remark plugins
45+
remarkPlugins: [rewriteMdLinks],
46+
},
47+
});

netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build]
2-
publish = "build"
2+
publish = "dist"
33
command = "npm run build:preview"
44

55
[context.production]

package.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
"name": "techdocs",
33
"version": "0.0.0",
44
"description": "Resources provided by the CNCF Technical Documentation team.",
5+
"type": "module",
56
"scripts": {
6-
"_build": "npm run docus:build",
7+
"_build": "npm run astro:build -- --force",
78
"_check:format:any": "npx prettier --check --ignore-path ''",
89
"_check:format:delta": "npm run _check:format:any -- $(npm run -s _list:git:delta)",
910
"_check:format": "npx prettier --check .",
@@ -18,6 +19,12 @@
1819
"_list:check:md": "find . -name '*.md' -not -path '*/node_modules/*' -a -not -path '*/.?*' | grep -Eve '/000|/0010'",
1920
"_list:fix:*": "npm run --loglevel=warn | grep -Ee '^\\s*fix:[^:]+$' | grep -v 'fix:all'",
2021
"_list:git:delta": "git diff --name-only --diff-filter=ACMR | grep -E '\\.(js|md|scss|yml|yaml)$'",
22+
"add-frontmatter": "node scripts/add-frontmatter.mjs",
23+
"astro:build": "astro build",
24+
"astro:postbuild": "find dist -name \"*.html\" -exec perl -i -pe 's|<link rel=\"canonical\"\\s*/>||g' {} +",
25+
"astro:dev": "astro dev",
26+
"astro:preview": "astro preview",
27+
"astro": "astro",
2128
"build:preview": "npm run _build",
2229
"build:production": "npm run _build",
2330
"build": "BUILD_ENV=dev npm run _build",
@@ -26,6 +33,7 @@
2633
"check:markdown": "npm run _check:markdown:all",
2734
"check:spelling": "npx cspell --no-progress -c .cspell.yml analyses docs *.md",
2835
"check": "npm run seq -- $(npm run -s _list:check:*)",
36+
"postastro:build": "find dist -name \"*.html\" -exec perl -i -pe 's|<link rel=\"canonical\"\\s*/>||g' {} +",
2937
"docus:build": "docusaurus build",
3038
"docus:clear": "docusaurus clear",
3139
"docus:deploy": "docusaurus deploy",
@@ -47,28 +55,34 @@
4755
"author": "CNCF",
4856
"license": "CC-BY-4.0",
4957
"dependencies": {
58+
"@astrojs/starlight": "^0.34.4",
5059
"@docusaurus/core": "3.8.1",
5160
"@docusaurus/preset-classic": "3.8.1",
5261
"@mdx-js/react": "^3.1.0",
62+
"astro": "^5.6.1",
5363
"clsx": "^2.1.1",
5464
"prism-react-renderer": "^2.4.1",
5565
"react-dom": "^19.1.0",
56-
"react": "^19.1.0"
66+
"react": "^19.1.0",
67+
"sharp": "^0.32.5",
68+
"unist-util-visit": "^5.0.0"
5769
},
5870
"devDependencies": {
5971
"@docusaurus/module-type-aliases": "3.8.1",
6072
"@docusaurus/tsconfig": "3.8.1",
6173
"@docusaurus/types": "3.8.1",
6274
"cspell": "^9.1.1",
75+
"glob": "^10.3.10",
6376
"markdown-link-check": "3.13.7",
6477
"markdownlint-cli": "^0.45.0",
6578
"markdownlint": "^0.38.0",
6679
"npm-check-updates": "^18.0.1",
6780
"prettier": "^3.5.3",
68-
"typescript": "~5.8.3"
81+
"typescript": "~5.8.3",
82+
"yaml": "^2.4.0"
6983
},
7084
"private": true,
71-
"spelling": "cSpell:ignore ACMR docus HTMLTEST loglevel pkgs -",
85+
"spelling": "cSpell:ignore ACMR docus frontmatter HTMLTEST loglevel pkgs postbuild -",
7286
"prettier": {
7387
"proseWrap": "always",
7488
"singleQuote": true

public/favicon.svg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../static/img/cncf-icon-color.svg

src/content.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineCollection } from 'astro:content';
2+
import { docsLoader } from '@astrojs/starlight/loaders';
3+
import { docsSchema } from '@astrojs/starlight/schema';
4+
5+
export const collections = {
6+
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
7+
};

src/content/docs/analyses

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../analyses

src/content/docs/docs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../docs

src/content/docs/index.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Welcome
3+
# description:
4+
template: splash
5+
hero:
6+
tagline: Techdocs how-tos & project analyses
7+
image:
8+
file: ../../../static/img/cncf-icon-color.svg
9+
actions:
10+
- text: Docs
11+
link: /docs/
12+
# icon: right-arrow
13+
- text: Project analyses
14+
link: /analyses/
15+
variant: secondary
16+
---
17+
18+
import README from '../../../README.md';
19+
20+
<README />

src/css/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828
--ifm-color-primary-lightest: #4fddbf;
2929
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
3030
}
31+
32+
.sl-heading-wrapper.level-h1 {
33+
display: none;
34+
}

0 commit comments

Comments
 (0)