Created new functions to handle removal of `http` and `https` from hashnodeURL before being passed to GraphQL
This commit is contained in:
parent
03ae29b4bb
commit
61fffbd600
|
@ -6,13 +6,23 @@ export const getClient = () => {
|
||||||
return new GraphQLClient("https://gql.hashnode.com")
|
return new GraphQLClient("https://gql.hashnode.com")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function removeHTTPSProtocol(url: string) {
|
||||||
|
return url.replace(/^https?:\/\//, '');
|
||||||
|
}
|
||||||
|
export function removeHTTPProtocol(url: string) {
|
||||||
|
const fixHTTPS = removeHTTPSProtocol(url);
|
||||||
|
return fixHTTPS.replace(/^http?:\/\//, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
const newURL = removeHTTPProtocol(config.hashnodeURL);
|
||||||
|
|
||||||
export const getAllPosts = async () => {
|
export const getAllPosts = async () => {
|
||||||
const client = getClient();
|
const client = getClient();
|
||||||
|
|
||||||
const allPosts = await client.request<AllPostsData>(
|
const allPosts = await client.request<AllPostsData>(
|
||||||
gql`
|
gql`
|
||||||
query allPosts {
|
query allPosts {
|
||||||
publication(host: "${config.hashnodeURL}") {
|
publication(host: "${newURL}") {
|
||||||
title
|
title
|
||||||
posts(first: 20) {
|
posts(first: 20) {
|
||||||
pageInfo{
|
pageInfo{
|
||||||
|
@ -56,7 +66,7 @@ export const getPost = async (slug: string) => {
|
||||||
const data = await client.request<PostOrPageData>(
|
const data = await client.request<PostOrPageData>(
|
||||||
gql`
|
gql`
|
||||||
query postDetails($slug: String!) {
|
query postDetails($slug: String!) {
|
||||||
publication(host: "${config.hashnodeURL}") {
|
publication(host: "${newURL}") {
|
||||||
post(slug: $slug) {
|
post(slug: $slug) {
|
||||||
author{
|
author{
|
||||||
name
|
name
|
||||||
|
@ -92,7 +102,7 @@ export const getAboutPage = async () => {
|
||||||
const page = await client.request<PostOrPageData>(
|
const page = await client.request<PostOrPageData>(
|
||||||
gql`
|
gql`
|
||||||
query pageData {
|
query pageData {
|
||||||
publication(host: "${config.hashnodeURL}") {
|
publication(host: "${newURL}") {
|
||||||
staticPage(slug: "about") {
|
staticPage(slug: "about") {
|
||||||
title
|
title
|
||||||
content {
|
content {
|
||||||
|
@ -114,7 +124,7 @@ export const getPublication = async () => {
|
||||||
const data = await client.request<PublicationData>(
|
const data = await client.request<PublicationData>(
|
||||||
gql`
|
gql`
|
||||||
query pubData {
|
query pubData {
|
||||||
publication(host: "${config.hashnodeURL}") {
|
publication(host: "${newURL}") {
|
||||||
title
|
title
|
||||||
displayTitle
|
displayTitle
|
||||||
descriptionSEO
|
descriptionSEO
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default defineConfig({
|
||||||
// }),
|
// }),
|
||||||
integrations: [
|
integrations: [
|
||||||
astroHashnode({
|
astroHashnode({
|
||||||
hashnodeURL: "astroplayground.hashnode.dev",
|
hashnodeURL: "https://astroplayground.hashnode.dev",
|
||||||
verbose: true,
|
verbose: true,
|
||||||
disableViewTransitions: false,
|
disableViewTransitions: false,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue