diff --git a/services/api.js b/services/api.js
deleted file mode 100644
index eaf5fc8..0000000
--- a/services/api.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import axios from 'axios';
-
-export const api = axios.create({
- baseURL: 'https://nuareafrukmnjnaakplk.supabase.co/rest/v1',
- headers: {
- apikey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im51YXJlYWZydWttbmpuYWFrcGxrIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NjAyMjc0MjEsImV4cCI6MTk3NTgwMzQyMX0.3qUEldVsmcr_yrpf8N1-qBGdHLB1QCy9nB6-nApVQIA",
- authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im51YXJlYWZydWttbmpuYWFrcGxrIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NjAyMjc0MjEsImV4cCI6MTk3NTgwMzQyMX0.3qUEldVsmcr_yrpf8N1-qBGdHLB1QCy9nB6-nApVQIA"
- }
-})
\ No newline at end of file
diff --git a/components/ArrowIcon.js b/src/components/ArrowIcon.js
similarity index 100%
rename from components/ArrowIcon.js
rename to src/components/ArrowIcon.js
diff --git a/components/CustomLink.js b/src/components/CustomLink.js
similarity index 100%
rename from components/CustomLink.js
rename to src/components/CustomLink.js
diff --git a/components/Footer.js b/src/components/Footer.js
similarity index 100%
rename from components/Footer.js
rename to src/components/Footer.js
diff --git a/components/Header.js b/src/components/Header.js
similarity index 100%
rename from components/Header.js
rename to src/components/Header.js
diff --git a/components/Layout.js b/src/components/Layout.js
similarity index 100%
rename from components/Layout.js
rename to src/components/Layout.js
diff --git a/components/Layout.module.css b/src/components/Layout.module.css
similarity index 100%
rename from components/Layout.module.css
rename to src/components/Layout.module.css
diff --git a/components/SEO.js b/src/components/SEO.js
similarity index 100%
rename from components/SEO.js
rename to src/components/SEO.js
diff --git a/pages/_app.js b/src/pages/_app.js
similarity index 100%
rename from pages/_app.js
rename to src/pages/_app.js
diff --git a/pages/_document.js b/src/pages/_document.js
similarity index 100%
rename from pages/_document.js
rename to src/pages/_document.js
diff --git a/pages/index.js b/src/pages/index.js
similarity index 98%
rename from pages/index.js
rename to src/pages/index.js
index d812880..f92021d 100644
--- a/pages/index.js
+++ b/src/pages/index.js
@@ -24,7 +24,6 @@ export default function Index({ posts, globalData }) {
className="md:first:rounded-t-lg md:last:rounded-b-lg backdrop-blur-lg bg-white dark:bg-black dark:bg-opacity-30 bg-opacity-10 hover:bg-opacity-20 dark:hover:bg-opacity-50 transition border border-gray-800 dark:border-white border-opacity-10 dark:border-opacity-10 border-b-0 last:border-b hover:border-b hovered-sibling:border-t-0"
>
@@ -63,6 +62,5 @@ export async function getServerSideProps() {
const posts = await getPosts();
const globalData = getGlobalData()
-
return { props: { posts, globalData } };
}
diff --git a/pages/posts/[id].js b/src/pages/posts/[id].js
similarity index 98%
rename from pages/posts/[id].js
rename to src/pages/posts/[id].js
index 28daad7..9af8d22 100644
--- a/pages/posts/[id].js
+++ b/src/pages/posts/[id].js
@@ -41,7 +41,7 @@ export default function PostPage({
- {posts.body}
+ {posts?.body}
diff --git a/src/services/api.js b/src/services/api.js
new file mode 100644
index 0000000..ce16bf6
--- /dev/null
+++ b/src/services/api.js
@@ -0,0 +1,9 @@
+import axios from 'axios';
+
+export const api = axios.create({
+ baseURL: 'https://yyhfavepdalzhbxblymv.supabase.co/rest/v1',
+ headers: {
+ apikey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inl5aGZhdmVwZGFsemhieGJseW12Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjE3MzIyNTEsImV4cCI6MjAzNzMwODI1MX0.GJQ9Tzc4NJUMAfaYKvXvpehLZovVWepuyjk7Js8u6Jc",
+ Authorization: " Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inl5aGZhdmVwZGFsemhieGJseW12Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjE3MzIyNTEsImV4cCI6MjAzNzMwODI1MX0.GJQ9Tzc4NJUMAfaYKvXvpehLZovVWepuyjk7Js8u6Jc"
+ }
+})
\ No newline at end of file
diff --git a/styles/globals.css b/src/styles/globals.css
similarity index 100%
rename from styles/globals.css
rename to src/styles/globals.css
diff --git a/utils/global-data.js b/src/utils/global-data.js
similarity index 100%
rename from utils/global-data.js
rename to src/utils/global-data.js
diff --git a/src/utils/mdx-utils.js b/src/utils/mdx-utils.js
new file mode 100644
index 0000000..6f93118
--- /dev/null
+++ b/src/utils/mdx-utils.js
@@ -0,0 +1,31 @@
+import { api } from '../services/api'
+
+export const getPosts = async () => {
+ const {data} = await api.get('/posts');
+
+ if (data) {
+ return data;
+ }
+
+ return []
+}
+
+export const getPostBySlug = async (id) => {
+ try {
+ const { data, error } = await api.get(`/posts?id=eq.${id}`);
+
+ if (error) {
+ console.error("Erro ao buscar post:", error);
+ return {};
+ }
+
+ if (data && data.length > 0) {
+ return data[0];
+ }
+
+ return {};
+ } catch (error) {
+ console.error("Erro na requisição:", error);
+ return {};
+ }
+};
diff --git a/utils/tailwind-preset.js b/src/utils/tailwind-preset.js
similarity index 98%
rename from utils/tailwind-preset.js
rename to src/utils/tailwind-preset.js
index 7e3f9ec..d85dd5e 100644
--- a/utils/tailwind-preset.js
+++ b/src/utils/tailwind-preset.js
@@ -1,6 +1,6 @@
const plugin = require('tailwindcss/plugin');
const pluginTypography = require('@tailwindcss/typography');
-const { COLOR_THEMES, FONT_THEMES } = require('../themes');
+const { COLOR_THEMES, FONT_THEMES } = require('../../themes');
const THEME = process.env.BLOG_THEME || 'default';
const FONT_PRIMARY = process.env.BLOG_FONT_HEADINGS || 'sans-serif';
diff --git a/tailwind.config.js b/tailwind.config.js
index 0b8ca0b..1ae9dc0 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,9 +1,9 @@
module.exports = {
mode: 'jit',
content: [
- './pages/**/*.{js,ts,jsx,tsx}',
- './components/**/*.{js,ts,jsx,tsx}',
+ './src/pages/**/*.{js,ts,jsx,tsx}',
+ './src/components/**/*.{js,ts,jsx,tsx}',
],
darkMode: 'class', // or 'media' or 'class'
- presets: [require('./utils/tailwind-preset')],
+ presets: [require('./src/utils/tailwind-preset')],
};
diff --git a/utils/mdx-utils.js b/utils/mdx-utils.js
deleted file mode 100644
index d90061f..0000000
--- a/utils/mdx-utils.js
+++ /dev/null
@@ -1,19 +0,0 @@
-import { api } from '../services/api'
-
-export const getPosts = async () => {
- const {data} = await api.get('/posts');
-
- if(data){
- return data;
- }
-
- return []
-}
-
-export const getPostBySlug = async (id) => {
-
- //TODO: BUSCAR UM POST EM ESPECIFICO.
- //const {data} = await api.get(`/post?id=eq.${id}`)
-
- return {}
-}
\ No newline at end of file