Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
samples/astro.config.ts at main · data-engine-thinking/samples · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
data-engine-thinking
samples
Repository navigation
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
samples
/
astro.config.ts
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
205 lines (193 loc) · 8.04 KB
main
Breadcrumbs
samples
/
astro.config.ts
Copy path
Top
File metadata and controls
Code
Blame
205 lines (193 loc) · 8.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import
fs
from
'node:fs'
;
import
path
from
'node:path'
;
import
{
fileURLToPath
}
from
'node:url'
;
import
mdx
from
'@astrojs/mdx'
;
import
starlight
from
'@astrojs/starlight'
;
import
remarkCodeImport
from
'remark-code-import'
;
import
{
defineConfig
,
fontProviders
}
from
'astro/config'
;
import
type
{
AstroUserConfig
}
from
'astro'
;
// One entry in the sidebar tree: either a link to a page, or a group of them.
// Named here so `buildDir` can declare its own (recursive) return type.
type
SidebarEntry
=
|
{
label
:
string
;
slug
:
string
}
|
{
label
:
string
;
collapsed
:
boolean
;
items
:
SidebarEntry
[
]
}
;
type
RemarkPlugins
=
NonNullable
<
NonNullable
<
AstroUserConfig
[
'markdown'
]
>
[
'remarkPlugins'
]
>
;
/* ---------------------------------------------------------------
Reader-friendly sidebar, generated from the content tree.
Starlight's `autogenerate` labels each group with the raw folder
name (e.g. "design-patterns"). Instead we walk src/content/docs and:
- label each group with its index page's title when it has one,
otherwise a Title-Cased version of the folder name;
- relabel a group's own index page to "Introduction" so it does
not repeat the group name;
- label leaf pages with their frontmatter title.
--------------------------------------------------------------- */
const
DOCS
=
fileURLToPath
(
new
URL
(
'./src/content/docs'
,
import
.
meta
.
url
)
)
;
// Treeview order. Two layers, both "lower number = higher in the tree":
// 1) a page's `sidebar.order` frontmatter — the manual, per-page override;
// 2) src/data/treeview-order.json — generated from the manuscript TOC by
// scripts/gen-treeview-order.mjs (maps a content path to its book position).
// Items with neither fall back to numeric/alphabetical order by name.
let
TREEVIEW_ORDER
:
Record
<
string
,
number
>
=
{
}
;
try
{
TREEVIEW_ORDER
=
JSON
.
parse
(
fs
.
readFileSync
(
fileURLToPath
(
new
URL
(
'./src/data/treeview-order.json'
,
import
.
meta
.
url
)
)
,
'utf8'
)
)
;
}
catch
{
}
const
_orderCache
=
new
Map
<
string
,
number
|
undefined
>
(
)
;
function
frontmatterOrder
(
file
:
string
)
:
number
|
undefined
{
if
(
_orderCache
.
has
(
file
)
)
return
_orderCache
.
get
(
file
)
;
let
v
:
number
|
undefined
;
try
{
const
fm
=
fs
.
readFileSync
(
file
,
'utf8'
)
.
match
(
/
^
-
-
-
\r
?
\n
(
[
\s
\S
]
*
?
)
\r
?
\n
-
-
-
/
)
;
// Capture the digits directly, so there is no separately-indexed match to
// re-check: under noUncheckedIndexedAccess every `m[1]` is possibly undefined.
const
raw
=
fm
?.
[
1
]
?.
match
(
/
(?:
^
|
\n
|
\{
)
\s
*
o
r
d
e
r
:
\s
*
(
-
?
\d
+
(?:
\.
\d
+
)
?
)
/
)
?.
[
1
]
;
v
=
raw
===
undefined
?
undefined
:
Number
(
raw
)
;
}
catch
{
v
=
undefined
;
}
_orderCache
.
set
(
file
,
v
)
;
return
v
;
}
function
orderOf
(
dir
:
string
,
name
:
string
)
:
number
{
const
full
=
path
.
join
(
dir
,
name
)
;
const
isFile
=
fs
.
statSync
(
full
)
.
isFile
(
)
;
const
fo
=
frontmatterOrder
(
isFile
?
full
:
path
.
join
(
full
,
'index.md'
)
)
;
// 1) per-page override
if
(
fo
!==
undefined
)
return
fo
;
let
rel
=
path
.
relative
(
DOCS
,
full
)
.
split
(
path
.
sep
)
.
join
(
'/'
)
;
// 2) generated treeview order
if
(
isFile
)
rel
=
rel
.
replace
(
/
\.
m
d
x
?
$
/
i
,
''
)
;
const
o
=
TREEVIEW_ORDER
[
rel
]
;
return
o
===
undefined
?
Infinity
:
o
;
}
const
ACRONYMS
:
Record
<
string
,
string
>
=
{
psa
:
'PSA'
,
sql
:
'SQL'
,
cdc
:
'CDC'
,
pit
:
'PIT'
,
lda
:
'LDA'
,
nbr
:
'NBR'
,
etl
:
'ETL'
,
elt
:
'ELT'
,
api
:
'API'
,
ddl
:
'DDL'
,
}
;
const
SMALL
=
new
Set
(
[
'of'
,
'and'
,
'the'
,
'a'
,
'an'
,
'to'
,
'in'
,
'for'
,
'with'
,
'from'
,
'on'
,
'or'
]
)
;
function
prettify
(
name
:
string
)
:
string
{
return
name
.
replace
(
/
_
/
g
,
'-'
)
.
split
(
'-'
)
.
filter
(
Boolean
)
.
map
(
(
w
,
i
)
=>
{
const
lw
=
w
.
toLowerCase
(
)
;
// Bind the lookup before testing it, so the truthy check narrows away the
// `undefined` that indexing a Record can produce.
const
acronym
=
ACRONYMS
[
lw
]
;
if
(
acronym
)
return
acronym
;
if
(
i
>
0
&&
SMALL
.
has
(
lw
)
)
return
lw
;
return
lw
.
charAt
(
0
)
.
toUpperCase
(
)
+
lw
.
slice
(
1
)
;
}
)
.
join
(
' '
)
;
}
function
titleOf
(
file
:
string
)
:
string
|
null
{
try
{
const
fm
=
fs
.
readFileSync
(
file
,
'utf8'
)
.
match
(
/
^
-
-
-
\r
?
\n
(
[
\s
\S
]
*
?
)
\r
?
\n
-
-
-
/
)
;
const
t
=
fm
?.
[
1
]
?.
match
(
/
^
t
i
t
l
e
:
\s
*
(
.
+
?
)
\s
*
$
/
m
)
?.
[
1
]
;
if
(
t
)
return
t
.
replace
(
/
^
[
"
'
]
|
[
"
'
]
$
/
g
,
''
)
;
}
catch
{
}
return
null
;
}
// A folder's index page is normally relabeled "Introduction"; a page can
// override that sidebar label with `sidebar.label` in its frontmatter.
function
indexLabelOf
(
file
:
string
)
:
string
|
null
{
try
{
const
fm
=
fs
.
readFileSync
(
file
,
'utf8'
)
.
match
(
/
^
-
-
-
\r
?
\n
(
[
\s
\S
]
*
?
)
\r
?
\n
-
-
-
/
)
;
const
m
=
fm
?.
[
1
]
?.
match
(
/
^
[
\t
]
*
l
a
b
e
l
:
[
\t
]
*
(
.
+
?
)
[
\t
]
*
$
/
m
)
?.
[
1
]
;
if
(
m
)
return
m
.
replace
(
/
^
[
"
'
]
|
[
"
'
]
$
/
g
,
''
)
;
}
catch
{
}
return
null
;
}
function
slugOf
(
abs
:
string
)
:
string
{
return
path
.
relative
(
DOCS
,
abs
)
.
split
(
path
.
sep
)
.
join
(
'/'
)
.
replace
(
/
\.
m
d
x
?
$
/
i
,
''
)
.
replace
(
/
\/
?
i
n
d
e
x
$
/
i
,
''
)
;
}
function
buildDir
(
dir
:
string
)
:
SidebarEntry
[
]
{
const
entries
:
SidebarEntry
[
]
=
fs
.
readdirSync
(
dir
)
.
sort
(
(
a
,
b
)
=>
{
const
oa
=
orderOf
(
dir
,
a
)
,
ob
=
orderOf
(
dir
,
b
)
;
return
oa
!==
ob
?
oa
-
ob
:
a
.
localeCompare
(
b
,
undefined
,
{
numeric
:
true
}
)
;
}
)
// The return annotation matters: without it each branch widens separately and
// the callback infers as `GroupEntry[] | LinkEntry[]` rather than SidebarEntry[].
.
flatMap
(
(
name
)
:
SidebarEntry
[
]
=>
{
const
full
=
path
.
join
(
dir
,
name
)
;
if
(
fs
.
statSync
(
full
)
.
isDirectory
(
)
)
{
const
idx
=
path
.
join
(
full
,
'index.md'
)
;
const
label
=
(
fs
.
existsSync
(
idx
)
&&
titleOf
(
idx
)
)
||
prettify
(
name
)
;
return
[
{
label
,
collapsed
:
true
,
items
:
buildDir
(
full
)
}
]
;
}
if
(
/
\.
m
d
x
?
$
/
i
.
test
(
name
)
&&
name
.
toLowerCase
(
)
!==
'index.md'
)
{
return
[
{
label
:
titleOf
(
full
)
||
prettify
(
name
.
replace
(
/
\.
m
d
x
?
$
/
i
,
''
)
)
,
slug
:
slugOf
(
full
)
}
]
;
}
return
[
]
;
}
)
;
const
idx
=
path
.
join
(
dir
,
'index.md'
)
;
if
(
fs
.
existsSync
(
idx
)
)
entries
.
unshift
(
{
label
:
indexLabelOf
(
idx
)
||
'Introduction'
,
slug
:
slugOf
(
idx
)
}
)
;
return
entries
;
}
const
section
=
(
sub
:
string
)
:
SidebarEntry
[
]
=>
buildDir
(
path
.
join
(
DOCS
,
sub
)
)
;
// https://astro.build/config
export
default
defineConfig
(
{
site
:
'https://docs.dataenginethinking.com'
,
outDir
:
'dist'
,
server
:
{
port
:
2330
}
,
fonts
:
[
{
provider
:
fontProviders
.
google
(
)
,
name
:
'Roboto'
,
cssVariable
:
'--font-roboto'
,
}
,
{
provider
:
fontProviders
.
google
(
)
,
name
:
'Roboto Mono'
,
cssVariable
:
'--font-roboto-mono'
,
}
,
]
,
devToolbar
:
{
enabled
:
false
}
,
markdown
:
{
// Pull SQL / Handlebars samples from the standalone files under code/ at
// build time, so the files stay editable and runnable while the pages stay
// in sync. `file=<rootDir>/x.sql` resolves relative to rootDir (code/).
// remark-code-import bundles its own copy of the unified/vfile types, so its
// plugin signature is structurally identical to Astro's RemarkPlugin but a
// distinct type identity. The assertion bridges that skew; it can go once the
// two agree on a single unified version.
remarkPlugins
:
[
[
remarkCodeImport
,
{
rootDir
:
fileURLToPath
(
new
URL
(
'./code'
,
import
.
meta
.
url
)
)
}
]
,
]
as
RemarkPlugins
,
}
,
integrations
:
[
starlight
(
{
title
:
'Data Engine Thinking Samples'
,
favicon
:
'/favicon.ico'
,
logo
:
{
src
:
'./src/assets/logo.png'
,
alt
:
'Data Engine Thinking'
,
replacesTitle
:
true
}
,
customCss
:
[
'./src/styles/custom.css'
]
,
components
:
{
Head
:
'./src/components/Head.astro'
,
}
,
social
:
[
{
icon
:
'github'
,
label
:
'GitHub'
,
href
:
'https://github.com/data-engine-thinking/samples'
,
}
,
]
,
editLink
:
{
baseUrl
:
'https://github.com/data-engine-thinking/samples/edit/main/'
,
}
,
sidebar
:
[
{
label
:
'Patterns'
,
items
:
section
(
'patterns'
)
}
,
{
label
:
'Sample Setup'
,
items
:
section
(
'setup'
)
}
,
{
label
:
'Samples by Chapter'
,
items
:
section
(
'chapters'
)
}
,
{
label
:
'About'
,
slug
:
'about'
}
,
{
label
:
'Taking the Next Step'
,
slug
:
'next-steps'
}
,
{
label
:
'License'
,
slug
:
'license'
}
,
{
label
:
'Disclaimer'
,
slug
:
'disclaimer'
}
,
]
,
}
)
,
mdx
(
)
,
]
,
}
)
;
You can’t perform that action at this time.