Skip to content

Commit 48779be

Browse files
committed
add possibility to also show events as news
1 parent a243f7f commit 48779be

File tree

2 files changed

+43
-38
lines changed

2 files changed

+43
-38
lines changed

content/events/2023/osm-vortrag_2023_12.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
---
2-
title: "Open-Street-Map - Vortrag"
2+
title: "Vortrag: Einführung in OpenStreetMap"
33
date: "2023-12-06"
44
location: "Hochschule Görlitz, Brückenstraße 1, Raum 010"
55
icon: "logo_transparent.png"
6+
show_as_news: true
67
---
78

8-
# Einführung in OpenStreetMap
9-
109
Ort: Hochschule Zittau/Görlitz, Fachbereich Informatik
1110
Brückenstraße 1, Raum 010
1211
Zeit: 06.12.2023 um 19:00 Uhr

gatsby-node.ts

+41-35
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,35 @@ export const createPages: GatsbyNode["createPages"] = async ({ actions, graphql
6767
const createNewsPages = async ({ actions, graphql }: Pick<CreatePagesArgs, "actions" | "graphql">) => {
6868
const { createPage } = actions
6969

70-
const result = await graphql(`{
71-
allMarkdownRemark(
72-
sort: {frontmatter: {date: DESC}}
73-
filter: {fields: {sourceName: {eq: "news"}}}
74-
) {
75-
edges {
76-
node {
77-
id
78-
frontmatter {
79-
title
80-
date
81-
}
82-
html
83-
fields {
84-
slug
70+
const result = await graphql(`
71+
{
72+
allMarkdownRemark(
73+
sort: { frontmatter: { date: DESC } }
74+
filter: { fields: { sourceName: { in: ["news", "events"] } } }
75+
) {
76+
edges {
77+
node {
78+
id
79+
frontmatter {
80+
title
81+
date
82+
show_as_news
83+
}
84+
html
85+
fields {
86+
slug
87+
sourceName
88+
}
89+
}
8590
}
8691
}
8792
}
88-
}
89-
}`)
93+
`)
9094

91-
const edges = (result.data as any).allMarkdownRemark.edges
95+
const edges = (result.data as any).allMarkdownRemark.edges.filter(({ node }) =>
96+
// we also want to show events that are marked with "show_as_news"
97+
node.fields.sourceName === "events" ? !!node.frontmatter.show_as_news : true
98+
)
9299

93100
createPaginatedPage({
94101
edges: edges,
@@ -112,26 +119,25 @@ const createNewsPages = async ({ actions, graphql }: Pick<CreatePagesArgs, "acti
112119

113120
const createEventPages = async ({ actions, graphql }: Pick<CreatePagesArgs, "actions" | "graphql">) => {
114121
const { createPage } = actions
115-
const result = await graphql(`{
116-
allMarkdownRemark(
117-
sort: {frontmatter: {date: DESC}}
118-
filter: {fields: {sourceName: {eq: "events"}}}
119-
) {
120-
edges {
121-
node {
122-
id
123-
frontmatter {
124-
title
125-
date
126-
}
127-
html
128-
fields {
129-
slug
122+
const result = await graphql(`
123+
{
124+
allMarkdownRemark(sort: { frontmatter: { date: DESC } }, filter: { fields: { sourceName: { eq: "events" } } }) {
125+
edges {
126+
node {
127+
id
128+
frontmatter {
129+
title
130+
date
131+
}
132+
html
133+
fields {
134+
slug
135+
}
136+
}
130137
}
131138
}
132139
}
133-
}
134-
}`)
140+
`)
135141

136142
const edges = (result.data as any).allMarkdownRemark.edges
137143

0 commit comments

Comments
 (0)