Skip to content

Commit fcf9762

Browse files
committed
fix: sort starters by index
1 parent c35f5e1 commit fcf9762

File tree

7 files changed

+40
-60
lines changed

7 files changed

+40
-60
lines changed

gridsome.config.js

-33
Original file line numberDiff line numberDiff line change
@@ -91,38 +91,5 @@ module.exports = {
9191
}
9292
}
9393
}
94-
],
95-
// Create routes from GraphQL nodes
96-
nodeRoutes: {
97-
WordPressPost: '/:year/:month/:slug',
98-
WordPressTag: '/tag/:slug',
99-
CustomType: {
100-
route: '/other/:custom/:type',
101-
component: './src/templates/MyTemplate.vue', // default templates/typeName.vue
102-
nextFieldName: 'nextPost',
103-
prevFieldName: 'prevPost',
104-
sortBy: 'date'
105-
},
106-
Author: [
107-
{
108-
route: '/author/:name',
109-
component: './src/templates/Author.vue'
110-
},
111-
{
112-
route: '/author/:name/starters',
113-
component: './src/templates/AuthorStarters.vue'
114-
}
115-
]
116-
},
117-
// Create dynamic routes
118-
clientRoutes: [
119-
{
120-
path: '/foo/',
121-
component: './src/templates/MyTemplate.vue',
122-
},
123-
{
124-
path: '/bar/:id',
125-
component: './src/templates/MyTemplate.vue',
126-
}
12794
]
12895
}

gridsome.server.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ module.exports = function (api) {
5454
})
5555

5656
// Connect author field to Contributors & Platforms
57-
starters.addReference('author','Contributor')
58-
starters.addReference('platforms','Platform')
57+
starters.addReference('author', 'Contributor')
58+
starters.addReference('platforms', 'Platform')
5959

60-
startersJson.forEach(({ id, name: title, ...fields }) => {
60+
startersJson.forEach((starter, index) => {
6161
starters.addNode({
62-
id,
63-
title,
64-
fields,
62+
...starter,
63+
index,
6564
internal: {
6665
origin: startersPath
6766
}
@@ -78,11 +77,10 @@ module.exports = function (api) {
7877
})
7978

8079
// Connect author field to Contributors
81-
platformsJson.forEach(({ id, name: title, ...fields }) => {
80+
platformsJson.forEach((platform, index) => {
8281
platforms.addNode({
83-
id,
84-
title,
85-
fields,
82+
...platform,
83+
index,
8684
internal: {
8785
origin: platformsPath
8886
}

src/components/StarterCard.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ export default {
8383
}
8484
}
8585
</style>
86-
</style>
86+
</style>

src/pages/Starters.vue

+19-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,19 @@ export default {
3030

3131
<page-query>
3232
query Starters {
33-
defaultStarters: allStarter (order: ASC, perPage: 3) {
33+
defaultStarters: allStarter (
34+
sort: [{ by: "index", order: ASC }]
35+
filter: {
36+
featured: {
37+
eq: true
38+
}
39+
}
40+
) {
3441
edges {
3542
node {
3643
id
3744
title
45+
path
3846
description
3947
preview
4048
repo
@@ -46,18 +54,26 @@ query Starters {
4654
title
4755
path
4856
}
49-
path
5057
}
5158
}
5259
},
53-
starters: allStarter (order: ASC, skip: 3) {
60+
starters: allStarter (
61+
sortBy: "index"
62+
filter: {
63+
featured: {
64+
ne: true
65+
}
66+
}
67+
) {
5468
edges {
5569
node {
5670
id
5771
title
5872
description
5973
preview
6074
repo
75+
path
76+
screenshot (width: 840, height:840)
6177
platforms {
6278
title
6379
logo
@@ -66,8 +82,6 @@ query Starters {
6682
title
6783
path
6884
}
69-
path
70-
screenshot (width: 840, height:840)
7185
}
7286
}
7387
}

src/templates/Platform.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
query Platform($id: String!) {
2727
platform(id: $id) {
2828
title
29-
belongsTo {
29+
belongsTo(sortBy: "index") {
3030
edges {
3131
node {
3232
... on Starter {
@@ -35,6 +35,8 @@ query Platform($id: String!) {
3535
description
3636
preview
3737
repo
38+
path
39+
screenshot (width: 840, height: 840)
3840
platforms {
3941
title
4042
logo
@@ -43,8 +45,6 @@ query Platform($id: String!) {
4345
title
4446
path
4547
}
46-
path
47-
screenshot (width: 840, height: 840)
4848
}
4949
}
5050
}

src/templates/Starter.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,21 @@ export default {
161161
</script>
162162

163163
<page-query>
164-
query Starters ($id: String!) {
164+
query Starters($id: String!) {
165165
starter(id: $id) {
166166
title
167167
repo
168+
path
169+
preview
170+
screenshot(width: 1680, quality: 80)
168171
platforms {
169172
title
170-
logo (width: 30, height: 30)
173+
logo(width: 30, height: 30)
171174
}
172175
author {
173176
title
174177
path
175178
}
176-
path
177-
preview
178-
screenshot (width: 1680, quality: 80)
179179
}
180180
}
181181
</page-query>

starters/starters.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
- title: Default starter
22
repo: gridsome/gridsome-starter-default
33
author: gridsome
4-
tags: Default
4+
featured: true
55

66
- title: Default WordPress starter
77
repo: gridsome/gridsome-starter-wordpress
88
author: gridsome
99
platforms: wordpress
10-
tags: Default
10+
featured: true
1111

1212
- title: Default Contentful starter
1313
repo: gridsome/gridsome-starter-contentful
1414
author: gridsome
1515
tags: markdown, tailwind
1616
platforms: contentful
17+
featured: true
1718

1819
- title: Gridsome Blog Starter
1920
description: Official Markdown Blog Starter
2021
screenshot: ./screenshots/gridsome-starter-blog.png
2122
repo: gridsome/gridsome-starter-blog
2223
preview: https://gridsome-starter-blog.netlify.com/
2324
author: gridsome
24-
tags: Blog, Dark Mode
25+
tags: blog, dark mode
2526
platforms: markdown
2627

2728
- title: Bleda

0 commit comments

Comments
 (0)