Skip to content
This repository was archived by the owner on Jan 1, 2025. It is now read-only.

Commit fc94343

Browse files
create-issue-branch[bot]Adammatthiesenjdtjenkins
authored
feat: ✨ Chore: Update AIK and add ViewTransition support (#13)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com> Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com> Co-authored-by: Jacob Jenkins <7649031+jdtjenkins@users.noreply.github.com>
1 parent 8fbe341 commit fc94343

File tree

11 files changed

+224
-368
lines changed

11 files changed

+224
-368
lines changed

.changeset/mean-berries-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@matthiesenxyz/astro-hashnode": patch
3+
---
4+
5+
This updates internal `AIK` as well as impliments ViewTransitions with a disable switch in the user config

package/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default defineConfig({
5454
astroHashnode({
5555
hashnodeURL: 'astroplayground.hashnode.dev', // Your hashnode URL
5656
landingPage: true, // Lets you disable the default landing page!
57+
useViewTransitions: true, // Lets you enable/disable the default included ViewTransitions.
5758
layoutComponent: './src/layouts/YourLayout.astro' // Lets you change the default Layout.astro being used by the Integration Pages.
5859
verbose: false // Change to Verbose console output
5960
})

package/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
"vite": "^5.1.5"
4444
},
4545
"dependencies": {
46-
"@tailwindcss/vite": "4.0.0-alpha.7",
46+
"@tailwindcss/vite": "4.0.0-alpha.8",
4747
"astro-font": "^0.0.77",
48-
"astro-integration-kit": "^0.5.1",
48+
"astro-integration-kit": "^0.6.0",
4949
"astro-remote": "^0.3.2",
5050
"astro-seo": "^0.8.3",
5151
"graphql": "^16.8.1",
5252
"graphql-request": "^6.1.0",
5353
"picocolors": "^1.0.0",
54-
"tailwindcss": "4.0.0-alpha.7",
54+
"tailwindcss": "4.0.0-alpha.8",
5555
"ultrahtml": "^1.5.3"
5656
}
5757
}

package/src/astro-hashnode.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ export default defineIntegration({
6969

7070
hashLog("Setting up Virtual Imports and Layout Component")
7171
// Setup Layout Component
72-
// biome-ignore lint/suspicious/noImplicitAnyLet: This is a false positive
73-
let layoutComponentPath
72+
let layoutComponentPath: string;
7473

7574
if (options.layoutComponent) {
7675
layoutComponentPath = rootResolve(options.layoutComponent)

package/src/definitions/astro-hashnode.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
declare module 'virtual:astro-hashnode/config' {
2-
const userConfig: import("./src/schemas/user-config").Options;
3-
export default config as userConfig;
2+
const Config: import("./src/schemas/user-config").Options;
3+
export default config as Config;
44
}
55

66
declare module 'virtual:astro-hashnode/components' {

package/src/hn-gql/client.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { gql, GraphQLClient } from "graphql-request";
22
import type { AllPostsData, PostOrPageData, PublicationData } from "./schema";
3-
import Config from "virtual:astro-hashnode/config";
3+
import config from "virtual:astro-hashnode/config";
44

55
export const getClient = () => {
66
return new GraphQLClient("https://gql.hashnode.com")
@@ -12,7 +12,7 @@ export const getAllPosts = async () => {
1212
const allPosts = await client.request<AllPostsData>(
1313
gql`
1414
query allPosts {
15-
publication(host: "${Config.hashnodeURL}") {
15+
publication(host: "${config.hashnodeURL}") {
1616
title
1717
posts(first: 20) {
1818
pageInfo{
@@ -56,7 +56,7 @@ export const getPost = async (slug: string) => {
5656
const data = await client.request<PostOrPageData>(
5757
gql`
5858
query postDetails($slug: String!) {
59-
publication(host: "${Config.hashnodeURL}") {
59+
publication(host: "${config.hashnodeURL}") {
6060
post(slug: $slug) {
6161
author{
6262
name
@@ -92,7 +92,7 @@ export const getAboutPage = async () => {
9292
const page = await client.request<PostOrPageData>(
9393
gql`
9494
query pageData {
95-
publication(host: "${Config.hashnodeURL}") {
95+
publication(host: "${config.hashnodeURL}") {
9696
staticPage(slug: "about") {
9797
title
9898
content {
@@ -114,7 +114,7 @@ export const getPublication = async () => {
114114
const data = await client.request<PublicationData>(
115115
gql`
116116
query pubData {
117-
publication(host: "${Config.hashnodeURL}") {
117+
publication(host: "${config.hashnodeURL}") {
118118
title
119119
displayTitle
120120
descriptionSEO

package/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import astroHashnode from "./astro-hashnode.js";
1+
import astroHashnode from "./astro-hashnode";
22

33
export default astroHashnode;

package/src/layouts/Layout.astro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { getPublication } from '../hn-gql'
66
import { SEO } from "astro-seo";
77
import { AstroFont } from "astro-font";
88
import type { AstroHashnodeLayoutProps } from '../proptypes/layouttypes'
9+
import { ViewTransitions } from 'astro:transitions';
10+
import config from "virtual:astro-hashnode/config";
11+
12+
const useTranstions = config.useViewTransitions;
913
1014
const pubData = await getPublication();
1115
@@ -54,6 +58,7 @@ const { pageTitle, hideFooter, hideHeader, ogImage } = Astro.props as AstroHashn
5458
]
5559
}}
5660
/>
61+
{useTranstions && <ViewTransitions />}
5762
</head>
5863
<body>
5964
<div class="flex flex-col">

package/src/schemas/user-config.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
import { z } from "astro/zod";
2-
import { createResolver } from 'astro-integration-kit';
3-
4-
const { resolve } = createResolver(import.meta.url)
52

63
export function LayoutConfigSchema() {
74
return z
85
.string()
96
.optional()
107
}
118
export const optionsSchema = z.object({
9+
/**
10+
* The URL of the Hashnode blog
11+
*/
1212
hashnodeURL: z.string(),
13+
/**
14+
* Allows the user to disable the default landing page and use their own Astro site instead of a landing page.
15+
* @default true
16+
*/
1317
landingPage: z.boolean().default(true),
18+
/**
19+
* Allows the user to enable/disable the Astro ViewTransitions component.
20+
* @default true
21+
* @see https://docs.astro.build/en/guides/view-transitions/ for more information about ViewTransitions
22+
*/
23+
useViewTransitions: z.boolean().default(true),
24+
/**
25+
* Allows the user to change the layout component used for Astro-Hashnode pages.
26+
*/
1427
layoutComponent: LayoutConfigSchema(),
28+
/**
29+
* Allows the user to enable verbose logging
30+
* @default false
31+
*/
1532
verbose: z.boolean().default(false),
1633
});
1734

playground/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default defineConfig({
1212
astroHashnode({
1313
hashnodeURL: "astroplayground.hashnode.dev",
1414
verbose: true,
15+
disableViewTransitions: false,
1516
})
1617
],
1718
});

0 commit comments

Comments
 (0)