(files: string[])
| 11 | watch: [`../blog/posts/*.md`], |
| 12 | |
| 13 | load(files: string[]) { |
| 14 | return files |
| 15 | .map((file) => { |
| 16 | const base = path.basename(file, `.md`) |
| 17 | const parts = base.split(`-`) |
| 18 | |
| 19 | const year = parts[0] |
| 20 | const month = parts[1] |
| 21 | const day = parts[2] |
| 22 | const slug = parts.slice(3, 99).join(`-`) |
| 23 | |
| 24 | const contents = fs.readFileSync(file, `utf-8`) |
| 25 | const frontmatter = contents.split(`---\n`)[1] |
| 26 | |
| 27 | const parsed = parsePostFrontmatter(frontmatter) |
| 28 | const excerpt = typeof parsed.excerpt === `string` ? parsed.excerpt : `` |
| 29 | const bodyExcerpt = contents |
| 30 | .split(`---\n`)[2] |
| 31 | .split(`<!--truncate-->`)[0] |
| 32 | .trim() |
| 33 | const resolvedExcerpt = excerpt || bodyExcerpt |
| 34 | |
| 35 | const date = `${year}-${month}-${day}` |
| 36 | const blogPath = `/blog/${year}/${month}/${day}/${slug}` |
| 37 | |
| 38 | return { |
| 39 | ...parsed, |
| 40 | date, |
| 41 | path: blogPath, |
| 42 | excerpt: resolvedExcerpt, |
| 43 | } satisfies PostListRow |
| 44 | }) |
| 45 | .filter((row) => row.published !== false) |
| 46 | .sort((a, b) => (a.path < b.path ? 1 : -1)) |
| 47 | }, |
| 48 | } |
nothing calls this directly
no test coverage detected