Skip to content

Commit

Permalink
fixing small things
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Petry committed Oct 6, 2023
1 parent 99e10e0 commit 5f7b5ad
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 33 deletions.
47 changes: 23 additions & 24 deletions composables/data.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
import { fetchContentNavigation, queryContent, useAsyncData } from "#imports";
import { fetchContentNavigation, queryContent, useAsyncData } from '#imports'
import type {
GeneralList,
JsonParsedContent,
Page,
Post,
ProjectList,
} from "~/types";
import { groupBy } from "~/logic";
} from '~/types'
import { groupBy } from '~/logic'

export function useProjects() {
return useAsyncData("content:projects", () =>
queryContent<JsonParsedContent<ProjectList>>("_projects").findOne()
);
return useAsyncData('content:projects', () =>
queryContent<JsonParsedContent<ProjectList>>('_projects').findOne())
}

export function useGeneralList() {
return useAsyncData("content:entrys", () =>
queryContent<JsonParsedContent<GeneralList>>("_partners").findOne()
);
return useAsyncData('content:entrys', () =>
queryContent<JsonParsedContent<GeneralList>>('_partners').findOne())
}

export function useHeaderNav() {
return useAsyncData("content:navigation", () => fetchContentNavigation());
return useAsyncData('content:navigation', () => fetchContentNavigation())
}
export function usePostList() {
return useAsyncData(
"content:post-partials",
'content:post-partials',
() =>
queryContent<Post>()
.where({ _path: /blog\/*/ })
.without(["head", "body", "excerpt", "_"])
.without(['head', 'body', 'excerpt', '_'])
.sort({
publishedAt: -1,
})
.find(),
{
// group posts by the publish year
transform: (posts) =>
groupBy(posts, (p) => new Date(p.publishedAt).getFullYear()),
}
);
transform: posts =>
groupBy(posts, p => new Date(p.publishedAt).getFullYear()),
},
)
}

export function useRoutesContent<T extends Post>(path?: string) {
if (!path) path = useRoute().path;
if (!path)
path = useRoute().path
return useAsyncData(`content:${path}`, () =>
queryContent<T>()
.where({ path: new RegExp(path) })
.without(["excerpt"])
.findOne()
);
.without(['excerpt'])
.findOne())
}

export const usePost = async (path?: string) => useRoutesContent<Post>(path);
export const usePage = async (path?: string) => useRoutesContent<Page>(path);
export const usePost = async (path?: string) => useRoutesContent<Post>(path)
export const usePage = async (path?: string) => useRoutesContent<Page>(path)
function // group posts by the publish year
transform(input: Omit<Post, string>[]): {} {
throw new Error("Function not implemented.");
transform(input: Omit<Post, string>[],
): {} {
throw new Error('Function not implemented.')
}
4 changes: 2 additions & 2 deletions logic/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export const SiteLogo = '/jan-petry.webp'
export const SiteLanguage = 'en-US'
export const SiteTagLine = 'Developer'
// eslint-disable-next-line operator-linebreak
export const SiteDescription =
'Hey, Im Jan, a full-stack web developer living in Trier, Germany. Im passionate about building projects with .NET (most likly with Blazor or MVC) and Typescript (most likly with Angular, Vue or Nuxt).'
export const SiteDescription
= 'Hey, Im Jan, a full-stack web developer living in Trier, Germany. Im passionate about building projects with .NET (most likly with Blazor or MVC) and Typescript (most likly with Angular, Vue or Nuxt).'
export const SameAs = [
'https://twitter.com/omg_itsjan',
'https://github.com/omgitsjan',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"lint": "eslint .",
"images": "cld upload_dir images"
},
"dependencies": {
"@vercel/analytics": "^1.0.2"
},
"devDependencies": {
"@antfu/eslint-config": "^1.0.0-beta.17",
"@iconify-json/bi": "^1.1.20",
Expand Down Expand Up @@ -62,8 +65,5 @@
"overrides": {
"cheerio": "1.0.0-rc.10"
}
},
"dependencies": {
"@vercel/analytics": "^1.0.2"
}
}
8 changes: 4 additions & 4 deletions plugins/analytics.client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inject } from '@vercel/analytics';
import { inject } from '@vercel/analytics'

export default defineNuxtPlugin(() => {
inject();
});
inject()
})

0 comments on commit 5f7b5ad

Please sign in to comment.