add news
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
import { isToday, isAfter, parse } from "date-fns";
|
||||
import { nb } from "date-fns/locale";
|
||||
import { toZonedTime, format} from "date-fns-tz";
|
||||
import { toZonedTime, format } from "date-fns-tz";
|
||||
|
||||
const timeZone = "Europe/Oslo";
|
||||
|
||||
export const commonDateFormat = "dd.MM.yyyy 'kl.' HH:mm";
|
||||
export const commonDateTimeFormat = "dd.MM.yyyy 'kl.' HH:mm";
|
||||
export const commonDateFormat = "dd.MM.yyyy";
|
||||
|
||||
export function toLocalTime(date: Date | string | number) {
|
||||
return toZonedTime(date, timeZone);
|
||||
|
46
web/src/lib/news.ts
Normal file
46
web/src/lib/news.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { graphql } from "@/gql";
|
||||
import { NewsFragment } from "@/gql/graphql";
|
||||
|
||||
export type { NewsFragment, NewsIndexFragment } from "@/gql/graphql";
|
||||
|
||||
const NewsFragmentDefinition = graphql(`
|
||||
fragment News on NewsPage {
|
||||
__typename
|
||||
id
|
||||
slug
|
||||
title
|
||||
firstPublishedAt
|
||||
excerpt
|
||||
featuredImage {
|
||||
...Image
|
||||
}
|
||||
body {
|
||||
...Blocks
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
const NewsIndexFragmentDefinition = graphql(`
|
||||
fragment NewsIndex on NewsIndex {
|
||||
__typename
|
||||
id
|
||||
slug
|
||||
title
|
||||
lead
|
||||
}
|
||||
`);
|
||||
|
||||
export const newsQuery = graphql(`
|
||||
query news {
|
||||
index: newsIndex {
|
||||
... on NewsIndex {
|
||||
...NewsIndex
|
||||
}
|
||||
}
|
||||
news: pages(contentType: "news.NewsPage") {
|
||||
... on NewsPage {
|
||||
...News
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
Reference in New Issue
Block a user