I use gridsome-source-mysql
plugin to get data from MySQL.
The articles has more than 50 categories, I want to create a page for each category.
Now my code looks like this:
./src/components/Category01.vue
file:
<template>
...
...
</template>
<static-query>
query {
allPosts(filter: { Category: { in: ["Category01"] }}) {
edges {
node {
id
Category
Title
}
}
}
}
</static-query>
<script>
export default {
name: "Category01",
};
</script>
./src/components/Category02.vue
file:
<template>
...
...
</template>
<static-query>
query {
allPosts(filter: { Category: { in: ["Category02"] }}) {
edges {
node {
id
Category
Title
}
}
}
}
</static-query>
<script>
export default {
name: "Category02",
};
</script>
All are the same except for the different category name.
Is there a better way to create a page for each category?
Thank you!