Svelte markdown object creation
Updated on 2026-08-12
The three TypeScript files below provide the markdown object arrays needed to index and navigate a Svelte site's markdown documents. These objects are used both at project build time and at runtime.
| Relative Url | |
|---|---|
| src\lib\data\transient\posts-markdown-objects.ts | Object details |
| src\lib\data\transient\posts-index-objects.ts | Object details |
| src\lib\data\transient\posts-tag-objects.ts | Object details |
Markdown object creation workflow
flowchart TB
%% Colors
classDef blue fill:#2374f7,color:white,stroke:white
classDef green fill:green,color:white,stroke:white
%% Clickable links
%% click markdown_objects
markdown_files[(MD files)]:::green --> create_md_objects([create-markdown-objects.ts]) --> |Core objects| markdown_objects[(posts-markdown-objects.ts)]:::blue
markdown_objects --> create_tag_objects([create-tag-objects.ts]) --> |Shows tag counts| tag_objects[(posts-tag-objects.ts)]:::blue
markdown_objects --> create_index_objects([create-index-objects.ts]) --> |Input to search engine| index_objects[(posts-index-objects.ts)]:::blue
click markdown_objects "/posts/markdown-post-object" "Click"
Creating the markdown object arrays
This PowerShell script (src\lib\cli\create-runtime-objects.ps1) creates the three markdown object arrays.
function CreateMarkdownObjects {
bun ./create-markdown-objects.ts `
-markdownObjectsInputPath ../markdown/kb `
-markdownObjectsOutputFilename ../data/transient/posts-markdown-objects.ts `
-markdownValidationErrorOutputFilename ../data/transient/links-validation-error.txt `
-frontMatterType asnapost `
-importLine 'import { type ASNAPost, type FullMarkdown } from "../../cli/doc-types.ts";' `
-exportName "markdownObjects: FullMarkdown<ASNAPost>[]"
if ($LastExitCode -ne 0) {
write-host Failure to create markdown objects. -ForegroundColor red
exit(1)
}
write-host Success creating markdown objects. -ForegroundColor darkyellow
}
function CreateTagObjects {
bun ./create-tag-objects.ts `
-tagObjectsOutputFilename ../data/transient/posts-tag-objects.ts `
-frontMatterType Links `
-importLine 'import { type TagCount } from "../../cli/doc-types.ts";' `
-exportName "tagCounts: TagCount[]"
if ($LastExitCode -ne 0) {
write-host Failure to create tag objects. -ForegroundColor red
exit(1)
}
write-host Success creating tag objects. -ForegroundColor darkyellow
}
function CreateIndexObjects {
bun ./create-index-objects.ts `
-indexObjectsOutputFilename ../data/transient/posts-index-objects.ts `
-importLine 'import {type IndexObject} from "../../cli/doc-types.ts";' `
-exportName "indexObjects: IndexObject[]"
if ($LastExitCode -ne 0) {
write-host Failure to create index objects. -ForegroundColor red
exit(1)
}
write-host Success creating index objects. -ForegroundColor darkyellow
}
# Call each of the functions above.
CreateMarkdownObjects
CreateTagObjects
CreateIndexObjects