Add reversible post archiving across Wiki discovery and feeds
waterfall-wiki CI and deployment / verify-and-deploy (push) Successful in 18m21s
waterfall-wiki CI and deployment / verify-and-deploy (push) Successful in 18m21s
This commit is contained in:
@@ -8,7 +8,7 @@ import {postInput} from './write';
|
||||
export function withoutTitle(markdown:string){return markdown.replace(/^# [^\n]*(?:\n|$)\n?/,'');}
|
||||
export function withRevision(entry:ExploreEntry):ExploreEntry{
|
||||
const editableMarkdown=entry.editableMarkdown??withoutTitle(entry.markdown);
|
||||
const revision=createHash('sha256').update(JSON.stringify([entry.title,entry.description,editableMarkdown,[...entry.categories].sort(),(entry.systemTags||[]).map(t=>t.id).sort(),entry.coverAssetId??null,entry.assets?.map(a=>[a.id,a.role])??[]])).digest('hex');
|
||||
const revision=createHash('sha256').update(JSON.stringify([entry.archived||false,entry.title,entry.description,editableMarkdown,[...entry.categories].sort(),(entry.systemTags||[]).map(t=>t.id).sort(),entry.coverAssetId??null,entry.assets?.map(a=>[a.id,a.role])??[]])).digest('hex');
|
||||
return {...entry,editableMarkdown,revision};
|
||||
}
|
||||
export async function staticEdits(client?:PoolClient){if(!process.env.DATABASE_URL)return [];return (await (client||db()).query(`SELECT e.*,COALESCE((SELECT jsonb_agg(t.name ORDER BY t.name) FROM note_edit_tags et JOIN tags t ON t.id=et.tag_id WHERE et.page_id=e.page_id AND t.kind='normal'),'[]') AS categories,COALESCE((SELECT jsonb_agg(t ORDER BY t.name) FROM note_edit_tags et JOIN tags t ON t.id=et.tag_id WHERE et.page_id=e.page_id AND t.kind='system'),'[]') AS "systemTags" FROM note_edits e`)).rows;}
|
||||
|
||||
Reference in New Issue
Block a user