Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanchen Wang <hanchen.wang@mail.utoronto.ca>2016-05-11 17:11:23 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-06-14 16:45:26 +0300
commit5461a5e03d1d7c2e3179abea88aef48e62f413e5 (patch)
tree0cf670f600ef72079436cb20e60c8e1df1222e52 /commands
parent51f7cd9bdeb5cec48c1ad24786120ae7fce0c404 (diff)
commands: Add listExpiredCmd for expired pages
Diffstat (limited to 'commands')
-rw-r--r--commands/list.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/commands/list.go b/commands/list.go
index 7b24713bc..5267a4f8b 100644
--- a/commands/list.go
+++ b/commands/list.go
@@ -25,6 +25,7 @@ import (
func init() {
listCmd.AddCommand(listDraftsCmd)
listCmd.AddCommand(listFutureCmd)
+ listCmd.AddCommand(listExpiredCmd)
listCmd.PersistentFlags().StringVarP(&source, "source", "s", "", "filesystem path to read files relative from")
listCmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
}
@@ -98,3 +99,34 @@ posted in the future.`,
},
}
+
+var listExpiredCmd = &cobra.Command{
+ Use: "expired",
+ Short: "List all posts already expired",
+ Long: `List all of the posts in your content directory which has already
+expired.`,
+ RunE: func(cmd *cobra.Command, args []string) error {
+
+ if err := InitializeConfig(); err != nil {
+ return err
+ }
+
+ viper.Set("BuildExpired", true)
+
+ site := &hugolib.Site{}
+
+ if err := site.Process(); err != nil {
+ return newSystemError("Error Processing Source Content", err)
+ }
+
+ for _, p := range site.Pages {
+ if p.IsExpired() {
+ fmt.Println(filepath.Join(p.File.Dir(), p.File.LogicalName()))
+ }
+
+ }
+
+ return nil
+
+ },
+}