UNPKG

@dijitrak/react-nextjs-seo-plugin

Version:

A modern, user-friendly SEO plugin for React and Next.js with multilingual support and comprehensive optimization tools

344 lines (322 loc) 7.45 kB
/** * JSON-LD şema işlemleri */ /** * JSON-LD şemalarını oluşturur * @param {Array} schemas JSON-LD şemaları * @returns {string} HTML script etiketi */ export function generateJSONLD(schemas = []) { if (!schemas || schemas.length === 0) return ''; let result = ''; schemas.forEach(schema => { const schemaData = prepareSchemaData(schema); result += `<script type="application/ld+json">${JSON.stringify(schemaData, null, 2)}</script>\n`; }); return result; } /** * Şema verilerini hazırlar * @param {object} schema Şema verileri * @returns {object} Şema.org uyumlu veri */ function prepareSchemaData(schema) { if (!schema) return {}; const { type, data } = schema; if (!type || !data) { return {}; } return { '@context': 'https://schema.org', '@type': type, ...data }; } /** * Varsayılan şema şablonu oluşturur * @param {string} type Şema tipi * @param {string} siteUrl Site URL'si * @returns {object} Varsayılan şema verisi */ export function getDefaultSchemaTemplate(type, siteUrl = '') { switch (type) { case 'Organization': return { url: siteUrl, name: '', logo: '', description: '', address: { '@type': 'PostalAddress', streetAddress: '', addressLocality: '', addressRegion: '', postalCode: '', addressCountry: '' }, contactPoint: { '@type': 'ContactPoint', telephone: '', email: '', contactType: 'customer service' }, sameAs: [] }; case 'LocalBusiness': return { url: siteUrl, name: '', image: '', description: '', address: { '@type': 'PostalAddress', streetAddress: '', addressLocality: '', addressRegion: '', postalCode: '', addressCountry: '' }, geo: { '@type': 'GeoCoordinates', latitude: '', longitude: '' }, telephone: '', priceRange: '', openingHoursSpecification: [{ '@type': 'OpeningHoursSpecification', dayOfWeek: 'Monday', opens: '09:00', closes: '17:00' }], sameAs: [] }; case 'Person': return { name: '', image: '', jobTitle: '', description: '', email: '', telephone: '', url: siteUrl, address: { '@type': 'PostalAddress', streetAddress: '', addressLocality: '', addressRegion: '', postalCode: '', addressCountry: '' }, sameAs: [] }; case 'Product': return { name: '', image: [], description: '', brand: { '@type': 'Brand', name: '' }, offers: { '@type': 'Offer', priceCurrency: 'USD', price: '', availability: 'https://schema.org/InStock', url: siteUrl }, aggregateRating: { '@type': 'AggregateRating', ratingValue: '4.5', reviewCount: '100' } }; case 'Article': case 'NewsArticle': case 'BlogPosting': return { headline: '', image: '', datePublished: '', dateModified: '', author: { '@type': 'Person', name: '' }, publisher: { '@type': 'Organization', name: '', logo: { '@type': 'ImageObject', url: '' } }, description: '', mainEntityOfPage: { '@type': 'WebPage', '@id': siteUrl } }; case 'WebPage': return { '@id': siteUrl, url: siteUrl, name: '', description: '', isPartOf: { '@type': 'WebSite', '@id': siteUrl, name: '', url: siteUrl }, breadcrumb: { '@type': 'BreadcrumbList', itemListElement: [] } }; case 'WebSite': return { '@id': siteUrl, url: siteUrl, name: '', description: '', potentialAction: { '@type': 'SearchAction', target: `${siteUrl}/search?q={search_term_string}`, 'query-input': 'required name=search_term_string' } }; case 'Event': return { name: '', description: '', startDate: '', endDate: '', location: { '@type': 'Place', name: '', address: { '@type': 'PostalAddress', streetAddress: '', addressLocality: '', addressRegion: '', postalCode: '', addressCountry: '' } }, image: '', performer: { '@type': 'Person', name: '' }, offers: { '@type': 'Offer', price: '', priceCurrency: 'USD', availability: 'https://schema.org/InStock', url: siteUrl, validFrom: '' }, organizer: { '@type': 'Organization', name: '', url: '' } }; case 'BreadcrumbList': return { itemListElement: [ { '@type': 'ListItem', position: 1, name: 'Home', item: siteUrl } ] }; case 'FAQPage': return { mainEntity: [ { '@type': 'Question', name: 'What is an example question?', acceptedAnswer: { '@type': 'Answer', text: 'This is an example answer to the question.' } } ] }; case 'HowTo': return { name: '', description: '', image: '', estimatedCost: { '@type': 'MonetaryAmount', currency: 'USD', value: '0' }, totalTime: 'PT30M', supply: [ { '@type': 'HowToSupply', name: 'Supply 1' } ], tool: [ { '@type': 'HowToTool', name: 'Tool 1' } ], step: [ { '@type': 'HowToStep', name: 'Step 1', text: 'Description of step 1', image: '', url: `${siteUrl}#step1` } ] }; case 'Recipe': return { name: '', image: '', author: { '@type': 'Person', name: '' }, datePublished: '', description: '', prepTime: 'PT15M', cookTime: 'PT1H', totalTime: 'PT1H15M', recipeYield: '4 servings', recipeCategory: '', recipeCuisine: '', nutrition: { '@type': 'NutritionInformation', calories: '270 calories' }, recipeIngredient: [ 'Ingredient 1', 'Ingredient 2' ], recipeInstructions: [ { '@type': 'HowToStep', text: 'Step 1 instructions' }, { '@type': 'HowToStep', text: 'Step 2 instructions' } ] }; default: return {}; } }