From 2ffa1b226788a967b330383fab953e6512e830bb Mon Sep 17 00:00:00 2001 From: Bill Ross Date: Mon, 9 Jun 2025 16:27:54 -0600 Subject: [PATCH] Jun9 updates --- docs/META.md | 40 +++++++++++++ lang.md | 2 +- _debug.php => lib/debug.php | 0 lib/meta.php | 100 +++++++++++++++++++++++++++++++++ seo.inc.php => lib/seo.inc.php | 0 marketing.php | 2 +- 6 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 docs/META.md rename _debug.php => lib/debug.php (100%) create mode 100644 lib/meta.php rename seo.inc.php => lib/seo.inc.php (100%) diff --git a/docs/META.md b/docs/META.md new file mode 100644 index 0000000..36371b1 --- /dev/null +++ b/docs/META.md @@ -0,0 +1,40 @@ +1. Twitter Cards (twitter:*) + • Platforms: Twitter, X (formerly Twitter), TweetDeck, some news aggregators. + • Purpose: Provides rich media snippets when links are shared, including title, description, image, and card type (e.g., summary, player, app). + • Example: + + + + + + + +2. Open Graph (og:*) + • Platforms: Facebook, LinkedIn, WhatsApp, Slack, Discord, Reddit, Microsoft Teams, Telegram, and more. + • Purpose: Defines how links are previewed, including titles, images, descriptions, and types. + • Example: + + + + + + + +3. Schema.org (itemprop) + • Platforms: Google, Bing, Yandex, and other search engines. + • Purpose: Provides structured data for better search visibility, rich snippets, and enhanced knowledge panels. + • Example: + + + + + +4. Other Specialized Tags + • Pinterest: Uses og:image and og:description for rich pins. + • Reddit: Often pulls og:title and og:description. + • Discord: Prioritizes og: tags for link previews. + • Slack: Also prefers og: and twitter: tags. + • Microsoft Teams: Uses Open Graph for link cards. + • Telegram: Uses Open Graph for link previews. + + diff --git a/lang.md b/lang.md index 4762b8f..76b268d 100644 --- a/lang.md +++ b/lang.md @@ -1,6 +1,6 @@ ---- # Markdown Friendly Headmatter -data: 2025-05-08 +date: 2025-05-08 title: Why is translation important description: highlight the importance of translating websites for SMB markets to expand reach, build trust, gain a competitive edge, improve SEO, and comply with local regulations key_image: /img/2025/05/08/social.png diff --git a/_debug.php b/lib/debug.php similarity index 100% rename from _debug.php rename to lib/debug.php diff --git a/lib/meta.php b/lib/meta.php new file mode 100644 index 0000000..806157d --- /dev/null +++ b/lib/meta.php @@ -0,0 +1,100 @@ + + + {$title} +
+
{$title}
+

{$description}

+
+
+ +HTML; +} + +$meta['title'] = $meta['title'] !== '' ? $meta['title'] : 'Home'; +$meta['title'] ??= ucfirst(str_replace('/', '', $path)) ?: 'Home'; + +function extractMeta($directory) { + $metaData = []; + + if (!is_dir($directory)) { + throw new Exception("Directory not found: $directory"); + } + + foreach (new DirectoryIterator($directory) as $file) { + if ($file->isFile() && $file->getExtension() === 'md') { + $contents = file_get_contents($file->getPathname()); + + // Extract title and image from the front matter + if (preg_match('/^-{3,}\s*(.*?)\s*-{3,}/s', $contents, $matches)) { + $frontMatter = $matches[1]; + + // Extract title + preg_match('/title:\s*(.*?)\s*$/m', $frontMatter, $titleMatch); + $title = trim($titleMatch[1] ?? ''); + + // Extract image + preg_match('/image:\s*(.*?)\s*$/m', $frontMatter, $imageMatch); + $image = trim($imageMatch[1] ?? ''); + + $metaData[$file->getFilename()] = [ + 'title' => $title, + 'image' => $image, + ]; + } + } + } + + return $metaData; +} + + +$file = '/path/to/your/file.txt'; + +if (file_exists($file)) { + $modTime = filemtime($file); + echo "Last modified: " . date(DATE_RFC2822, $modTime); +} else { + echo "File not found."; +} + +echo realpath($_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']); + +function render_meta($config, $core = [], $options = []) { + // Default options + $defaults = [ + 'ogm' => false, + 'twitter' => false, + 'schema' => true, + ]; + + // Merge provided options with defaults + $options = array_merge($defaults, $options); + + // Example usage + var_dump($options); +} + +function compareDates($date1, $date2) { + try { + // Normalize both dates to the same format (ISO 8601) + $normalized1 = (new DateTime($date1))->format('Y-m-d'); + $normalized2 = (new DateTime($date2))->format('Y-m-d'); + + // Return comparison result + return strcmp($normalized1, $normalized2); + } catch (Exception $e) { + // Handle invalid date formats + trigger_error("Invalid date format: " . $e->getMessage(), E_USER_WARNING); + return null; + } +} + + diff --git a/seo.inc.php b/lib/seo.inc.php similarity index 100% rename from seo.inc.php rename to lib/seo.inc.php diff --git a/marketing.php b/marketing.php index 1a11f38..c6c7fa1 100644 --- a/marketing.php +++ b/marketing.php @@ -1,7 +1,7 @@