Skip to content

Commit

Permalink
Merge branch 'calimania:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dvidsilva authored Jan 8, 2025
2 parents 14d30ef + e12504c commit dbee017
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
11 changes: 7 additions & 4 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import react from "@astrojs/react";
import remarkToc from "remark-toc";
import remarkCollapse from "remark-collapse";
import sitemap from "@astrojs/sitemap";
import { SITE } from "./src/config";
import { markketplace } from "./src/config";

// https://astro.build/config

/**
* @type {import('astro/types').RuntimeConfig}
*/
export default defineConfig({
site: SITE.website,
site: markketplace.url,
integrations: [
tailwind({
applyBaseStyles: false,
applyBaseStyles: true,
}),
react(),
sitemap(),
Expand Down
39 changes: 30 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
import type Store from "@interfaces/Store";
import type { Site, SocialObjects } from "./types";

const STRAPI_URL = (process.env.STRAPI_URL || '').replace(/\/$/, '') || 'https://api.markket.place';
const STORE_SLUG = process.env.STORE_SLUG as string || 'markket';

let baseURL = '';
let store: Store = {} as Store;

try {
const url = `${STRAPI_URL}/api/stores?filters[slug][$eq]=${STORE_SLUG}&populate[1]=URLS&populate[2]=SEO`;
const storeRequest = await fetch(url);
const StoreData = await storeRequest.json();
if (StoreData?.data?.[0]?.slug) {
store = StoreData.data[0];
}

baseURL = store?.URLS?.[0]?.URL || '';
} catch (error) {
console.error("Error fetching store data", error);
}

/**
* @type {{[string]: string}} Global Configuration attributes for the markket instance
*/
export const markketplace = {
STRAPI_URL: (import.meta.env.STRAPI_URL || '').replace(/\/$/, '') || 'https://api.markket.place',
STORE_SLUG: import.meta.env.STORE_SLUG as string || 'markket',
STORE_SLUG,
STRAPI_URL,
url: baseURL,
colors: {
primary: import.meta.env.COLOR_PRIMARY as string || '#fbda0c',
accent: import.meta.env.COLOR_ACCENT as string || '#38b2ac',
Expand All @@ -19,14 +40,14 @@ export const markketplace = {
* @TODO: Read these values from the API during launch or build time
*/
export const SITE: Site = {
website: "https://markket.place/",
author: "Markket",
profile: "https://markket.place/stores/markket",
desc: "A minimal, responsive and SEO-friendly Markketplace theme.",
title: "Morir Soñando",
ogImage: "https://markketplace.nyc3.digitaloceanspaces.com/uploads/3852868ed9aad1e45e4ee4992fe43177.png",
website: baseURL || "https://markket.place",
author: store.SEO?.metaAuthor || "Markket",
profile: `https://markket.place/stores/${STORE_SLUG}`,
desc: store.Description || "markketplace store for creators ",
title: store.title || "Markket",
ogImage: store.SEO?.socialImage?.url || "https://markketplace.nyc3.digitaloceanspaces.com/uploads/3852868ed9aad1e45e4ee4992fe43177.png",
lightAndDarkMode: true,
postPerIndex: 4,
postPerIndex: 3,
postPerPage: 8,
scheduledPostMargin: 15 * 60 * 1000, // 15 minutes
};
Expand Down
15 changes: 9 additions & 6 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "@styles/base.css";
import { ViewTransitions } from "astro:transitions";
import { getCollection, type CollectionEntry } from "astro:content";
import Posthog from "@components/posthog.astro";
import type Store from "@interfaces/Store";
const googleSiteVerification = import.meta.env.PUBLIC_GOOGLE_SITE_VERIFICATION;
Expand All @@ -26,13 +27,20 @@ export interface Props {
};
}
const stores = await getCollection("stores");
const store: Store = stores.find(
store => store.data.slug == markketplace.STORE_SLUG
)?.data as any as Store;
const baseUrl = store?.URLS?.[0]?.URL || Astro.site;
const {
title = SITE.title,
author = SITE.author,
profile = SITE.profile,
description = Astro.props.description ?? SITE.desc,
ogImage = SITE.ogImage,
canonicalURL = new URL(Astro.url.pathname, Astro.site).href,
canonicalURL = new URL(Astro.url.pathname, baseUrl).href,
pubDatetime,
modDatetime,
post,
Expand Down Expand Up @@ -61,11 +69,6 @@ const structuredData = {
],
};
const stores = await getCollection("stores");
const store = stores.find(
store => store.data.slug == markketplace.STORE_SLUG
)?.data;
let href = new URL(Astro.url.pathname, Astro.site);
---

Expand Down

0 comments on commit dbee017

Please sign in to comment.