website now works
This commit is contained in:
1 parent
ce56fcb91c
commit
3daa9f82e7
15 files changed
+241
-137
No files matched your search
+14
-12
@@ -132,7 +132,6 @@ export class Database {
|
||||
[image],
|
||||
tag,
|
||||
category,
|
||||
excerptHtml excerpt,
|
||||
contentHtml content
|
||||
FROM files f
|
||||
JOIN q ON q.path = f.path
|
||||
@@ -155,7 +154,6 @@ export class Database {
|
||||
image?: string
|
||||
tag?: string[]
|
||||
category?: string
|
||||
excerpt: string
|
||||
content: string
|
||||
}
|
||||
}
|
||||
@@ -167,7 +165,10 @@ export class Database {
|
||||
limit: number
|
||||
}
|
||||
) {
|
||||
return this._search(q, opts, 'RANK')
|
||||
return this._search(q, {
|
||||
...opts,
|
||||
orderedBy: 'RANK',
|
||||
})
|
||||
}
|
||||
|
||||
public by(
|
||||
@@ -177,11 +178,11 @@ export class Database {
|
||||
limit: number
|
||||
}
|
||||
) {
|
||||
return this._search(
|
||||
q,
|
||||
opts,
|
||||
'priority DESC, [date] DESC, createdAt DESC, updatedAt DESC'
|
||||
)
|
||||
return this._search(q, {
|
||||
...opts,
|
||||
orderedBy: 'priority DESC, [date] DESC, createdAt DESC, updatedAt DESC',
|
||||
where: '[date] IS NOT NULL',
|
||||
})
|
||||
}
|
||||
|
||||
private _search(
|
||||
@@ -189,13 +190,14 @@ export class Database {
|
||||
opts: {
|
||||
offset: number
|
||||
limit: number
|
||||
},
|
||||
orderedBy: string
|
||||
orderedBy: string
|
||||
where?: string
|
||||
}
|
||||
) {
|
||||
const fromSegment = /* sql */ `
|
||||
FROM files f
|
||||
JOIN q ON q.path = f.path
|
||||
${q ? `WHERE q = @q` : ''}
|
||||
WHERE ${q ? `q = @q` : 'TRUE'} ${opts.where ? `AND ${opts.where}` : ''}
|
||||
`
|
||||
|
||||
const count =
|
||||
@@ -220,7 +222,7 @@ export class Database {
|
||||
category,
|
||||
excerptHtml excerpt
|
||||
${fromSegment}
|
||||
ORDER BY ${orderedBy}
|
||||
ORDER BY ${opts.orderedBy}
|
||||
LIMIT ${opts.limit} OFFSET ${opts.offset}
|
||||
`
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user