add awsm theme
This commit is contained in:
1 parent
7039b10df2
commit
e397c9ae1e
15 files changed
+117
-115
No files matched your search
@@ -5,6 +5,7 @@ const zMatter = z.object({
|
||||
date: z.date().optional(),
|
||||
createdAt: z.date().optional(),
|
||||
updatedAt: z.date().optional(),
|
||||
priority: z.number().optional(),
|
||||
title: z.string(),
|
||||
image: z.string().optional(),
|
||||
tag: z.array(z.string()).optional(),
|
||||
@@ -41,6 +42,7 @@ export class Database {
|
||||
[date] INT, -- epoch milli
|
||||
[createdAt] INT, -- epoch milli
|
||||
[updatedAt] INT, -- epoch milli
|
||||
priority INT,
|
||||
-- q.title
|
||||
[image] TEXT,
|
||||
-- q.tag.split(/ /g)
|
||||
@@ -53,6 +55,7 @@ export class Database {
|
||||
CREATE INDEX IF NOT EXISTS files_date ON files([date]);
|
||||
CREATE INDEX IF NOT EXISTS files_createdAt ON files(createdAt);
|
||||
CREATE INDEX IF NOT EXISTS files_updatedAt ON files(updatedAt);
|
||||
CREATE INDEX IF NOT EXISTS files_priority ON files(priority);
|
||||
`)
|
||||
|
||||
this.db.exec(/* sql */ `
|
||||
@@ -68,8 +71,8 @@ export class Database {
|
||||
|
||||
public insert(...ps: IPost[]): void {
|
||||
const fStmt = this.db.prepare(/* sql */ `
|
||||
INSERT INTO files ([path], [date], [createdAt], [updatedAt], [image], excerptHtml, contentHtml)
|
||||
VALUES (@path, @date, @createdAt, @updatedAt, @image, @excerptHtml, @contentHtml)
|
||||
INSERT INTO files ([path], [date], [createdAt], [updatedAt], priority, [image], excerptHtml, contentHtml)
|
||||
VALUES (@path, @date, @createdAt, @updatedAt, @priority, @image, @excerptHtml, @contentHtml)
|
||||
`)
|
||||
|
||||
const qStmt = this.db.prepare(/* sql */ `
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import yaml from 'js-yaml'
|
||||
import * as z from 'zod'
|
||||
@@ -8,6 +9,7 @@ export const THEME_FILENAME = 'theme.yml'
|
||||
export const zTheme = z
|
||||
.object({
|
||||
title: z.string(),
|
||||
awsm: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
keywords: z.array(z.string()).optional(),
|
||||
nav: z
|
||||
@@ -50,6 +52,10 @@ export const zTheme = z
|
||||
})
|
||||
.nonstrict()
|
||||
|
||||
export type ITheme = z.infer<typeof zTheme>
|
||||
|
||||
export function getTheme() {
|
||||
return zTheme.parse(yaml.safeLoad(fs.readFileSync(THEME_FILENAME, 'utf-8')))
|
||||
return zTheme.parse(
|
||||
yaml.safeLoad(fs.readFileSync(path.join('built', THEME_FILENAME), 'utf-8'))
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user