saber icon indicating copy to clipboard operation
saber copied to clipboard

Provide tags and categories by default?

Open sustained opened this issue 4 years ago • 1 comments

Feature request

What problem does this feature solve?

Right now we have to do something like this in our blog template:

export default {
  computed: {
    tags() {
      return Array.from(
        new Set(
          this.page.posts.reduce((tags, page) => {
            tags.push(...(page.tags || []))
            return tags
          }, [])
        )
      )
    },
    categories() {
      return Array.from(
        new Set(
          this.page.posts.reduce((cats, page) => {
            cats.push(...(page.categories || []))
            return cats
          }, [])
        )
      )
    }, },
}

It's not much work but don't you think it amounts to needless boilerplate, when instead the plugin could just provide a list of all tags and categories by default?

What does the proposed API look like?

See below.

How should this be implemented in your opinion?

Both this.tags and this.categories would be available when injectAllPosts is true.

Alternatively, new options could be added: injectAllTags, injectAllCategories.

Are you willing to work on this yourself?

Yes.

sustained avatar Dec 21 '19 12:12 sustained

Maybe you can try this package: saber-plugin-classification

  • npm: https://www.npmjs.com/package/saber-plugin-classification
  • github: https://github.com/Siricee/saber-plugin-classification

Siricee avatar Dec 18 '20 17:12 Siricee