%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/www/portfolio/portfolio-rezakurnia/dist/server/chunks/
Upload File :
Create Path :
Current File : /home2/rezakur1/www/portfolio/portfolio-rezakurnia/dist/server/chunks/articles.service_BvxunLCx.mjs

import { a3 as createComponent, ae as renderComponent, l as Fragment, am as renderTemplate, a2 as createAstro, aq as unescapeHTML, ab as maybeRenderHead } from './astro/server_Dt2ArDMq.mjs';
import 'piccolore';
import { bundledLanguages } from 'shiki/langs';
import { createShikiHighlighter } from '@astrojs/markdown-remark';
import { c as apiGet, E as ENDPOINTS } from './endpoints_DA1Dz-Tw.mjs';

const cachedHighlighters = /* @__PURE__ */ new Map();
function getCachedHighlighter(opts) {
  const key = JSON.stringify(opts, Object.keys(opts).sort());
  if (cachedHighlighters.has(key)) {
    return cachedHighlighters.get(key);
  }
  const highlighter = createShikiHighlighter(opts);
  cachedHighlighters.set(key, highlighter);
  return highlighter;
}

const $$Astro$1 = createAstro();
const $$Code = createComponent(async ($$result, $$props, $$slots) => {
  const Astro2 = $$result.createAstro($$Astro$1, $$props, $$slots);
  Astro2.self = $$Code;
  const {
    code,
    lang = "plaintext",
    meta,
    theme = "github-dark",
    themes = {},
    defaultColor = "light",
    wrap = false,
    inline = false,
    transformers = [],
    ...rest
  } = Astro2.props;
  if (typeof lang === "object") {
    if (lang.id) {
      lang.name = lang.id;
    }
    if (lang.grammar) {
      Object.assign(lang, lang.grammar);
    }
  }
  const highlighter = await getCachedHighlighter({
    langs: [
      typeof lang === "string" ? Object.keys(bundledLanguages).includes(lang) ? lang : "plaintext" : lang
    ],
    theme,
    themes
  });
  const html = await highlighter.codeToHtml(code, typeof lang === "string" ? lang : lang.name, {
    defaultColor,
    wrap,
    inline,
    transformers,
    meta,
    attributes: rest
  });
  return renderTemplate`${renderComponent($$result, "Fragment", Fragment, {}, { "default": async ($$result2) => renderTemplate`${unescapeHTML(html)}` })}`;
}, "/home2/rezakur1/nodevenv/public_html/portfolio/portfolio-rezakurnia/22/lib/node_modules/astro/components/Code.astro", void 0);

const $$Astro = createAstro();
const $$Debug = createComponent(($$result, $$props, $$slots) => {
  const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
  Astro2.self = $$Debug;
  const key = Object.keys(Astro2.props)[0];
  const value = Astro2.props[key];
  return renderTemplate`${maybeRenderHead()}<div class="astro-debug"> <div class="astro-debug-header"> <h2 class="astro-debug-title"> <span class="astro-debug-label">Debug</span> <span class="astro-debug-name">"${key}"</span> </h2> </div> ${renderComponent($$result, "Code", $$Code, { "code": JSON.stringify(value, null, 2) })} </div> <style>
	.astro-debug {
		font-size: 14px;
		padding: 1rem 1.5rem;
		background: white;
		font-family:
			-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
			'Helvetica Neue', sans-serif;
	}

	.astro-debug-header,
	pre.astro-code {
		margin: -1rem -1.5rem 1rem;
		padding: 0.25rem 0.75rem;
	}

	.astro-debug-header {
		background: #ff1639;
		border-radius: 4px;
		border-bottom-left-radius: 0;
		border-bottom-right-radius: 0;
	}

	.astro-debug-title {
		font-size: 1em;
		color: white;
		margin: 0.5em 0;
	}

	.astro-debug-label {
		font-weight: bold;
		text-transform: uppercase;
		margin-right: 0.75em;
	}

	pre.astro-code {
		border: 1px solid #eee;
		padding: 1rem 0.75rem;
		border-radius: 4px;
		border-top-left-radius: 0;
		border-top-right-radius: 0;
		font-size: 14px;
	}
</style>`;
}, "/home2/rezakur1/nodevenv/public_html/portfolio/portfolio-rezakurnia/22/lib/node_modules/astro/components/Debug.astro", void 0);

function mapArticle(item) {
  return {
    slug: item.slug,
    title: item.title,
    excerpt: item.excerpt,
    content: item.content ?? [],
    body: item.body ?? [],
    lens5w1h: item.lens5w1h ?? {},
    tags: item.tags ?? [],
    date: item.date,
    readTime: item.readTime,
    category: item.category,
    coverImage: item.coverImage,
    viewCount: item.viewCount,
    meta_title: item.meta_title,
    meta_description: item.meta_description
  };
}
async function getArticles() {
  try {
    const response = await apiGet(ENDPOINTS.ARTICLES);
    console.log(response.data);
    return (response.data ?? []).map(mapArticle);
  } catch (error) {
    console.error("getArticles error:", error);
    return [];
  }
}
async function getArticleBySlug(slug) {
  try {
    const response = await apiGet(
      `${ENDPOINTS.ARTICLES}/${slug}`
    );
    const item = response.data;
    console.log(item);
    if (!item) return null;
    return mapArticle(item);
  } catch (error) {
    console.error("getArticleBySlug error:", error);
    return null;
  }
}
async function getArticleStats() {
  try {
    const response = await apiGet(`${ENDPOINTS.ARTICLES}/stats`);
    return response.data ?? {
      totalArticles: 0,
      totalCategories: 0,
      lastUpdate: null
    };
  } catch (error) {
    console.error("getArticleStats error:", error);
    return {
      totalArticles: 0,
      totalCategories: 0,
      lastUpdate: null
    };
  }
}
async function getCategories() {
  try {
    const response = await apiGet(`${ENDPOINTS.ARTICLES}/categories`);
    return (response.data ?? []).map((item) => ({
      id: item.id,
      name: item.name,
      description: item.description,
      metaTitle: item.metaTitle,
      metaDescription: item.metaDescription,
      totalArticles: item.totalArticles ?? 0
    }));
  } catch (error) {
    console.error("getCategories error:", error);
    return [];
  }
}

export { getArticleStats as a, getArticles as b, getCategories as c, getArticleBySlug as g };

Zerion Mini Shell 1.0