Skip to content

Commit

Permalink
Add automatic draft feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
krymtkts committed Dec 17, 2023
1 parent cdcc632 commit 16e51cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ module Misc =
source: string
leaf: string
date: string
pubDate: string option }
pubDate: string option
publish: bool }

let getDestinationPath (source: string) (dir: string) =
Directory.leaf source
Expand Down
12 changes: 9 additions & 3 deletions src/Generator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ module Rendering =
|> Parser.parseMarkdownAsReactEl
|> fun (fm, c) -> fm, c

let today = DateTime.toRFC3339Date now

let chooseDate (fm: Parser.FrontMatter option) alt =
let date =
match alt with
| Some date -> date
| _ -> DateTime.toRFC3339Date now
| _ -> today

match fm with
| Some fm ->
Expand All @@ -251,15 +253,18 @@ module Rendering =
| Some date -> date
| None -> date

let date = chooseDate fm pubDate

return
{ frontMatter = fm
content = content
description = content |> Parser.parseReact |> summarizeHtml 120
layout = layout
source = source
leaf = leafHtml source
date = chooseDate fm pubDate
pubDate = pubDate }
date = date
pubDate = pubDate
publish = date <= today }
}

let private writeContent
Expand Down Expand Up @@ -313,6 +318,7 @@ module Rendering =

return!
metas
|> Seq.filter (fun x -> x.publish)
|> Seq.mapi (fun i meta ->
promise {
let prev, next =
Expand Down

0 comments on commit 16e51cf

Please sign in to comment.