{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreigzkg3bqscyyvkk5seyli6dhuuo3gda56cd5h5mga5xdxqlgxtyke",
    "uri": "at://did:plc:ifygzfw7s227azydymaqeunw/app.bsky.feed.post/3mg4lp6jerwd2"
  },
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreidjpuxhw7z6zxcfnbfm2fuq6crqbgueg5u64ymu4iblesiss2jrla"
    },
    "mimeType": "image/webp",
    "size": 8550
  },
  "path": "/implement-a-random-post-button-on-bear-blog/",
  "publishedAt": "2026-03-02T20:00:00.000Z",
  "site": "https://www.jamesleighton.com",
  "tags": [
    "100DaysToOffload",
    "WebMentions"
  ],
  "textContent": "Create a new page, and add the following script. This will load your blog sitemap.xml file, and redirect the user to a link it references. Add this page to your navigation to create a random blog post link!\n\n\n    <script> async function redirectToRandomSitemapUrl() {  try {  const response = await fetch('/sitemap.xml');  if (!response.ok) {  throw new Error(`HTTP error! status: ${response.status}`);  }  const xmlText = await response.text();  const parser = new DOMParser();  const xmlDoc = parser.parseFromString(xmlText, 'application/xml');  // Check for XML parsing errors  const parserError = xmlDoc.querySelector(\"parsererror\");  if (parserError) {  throw new Error(\"XML parsing error: \" + parserError.textContent);  }  const locNodes = Array.from(xmlDoc.getElementsByTagName('loc'));  const urls = locNodes  .map(node => node.textContent.trim())  .filter(url => url); // Remove any empty or whitespace-only URLs  if (urls.length === 0) {  console.error('No URLs found in sitemap.');  return;  }  const randomUrl = urls[Math.floor(Math.random() * urls.length)];  window.location.href = randomUrl;  } catch (err) {  console.error('Error loading sitemap:', err);  } } redirectToRandomSitemapUrl(); </script>\n\n* * *\n\nThis is post 16 of #100DaysToOffload.\n\n* * *\n\nTo respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.\n\n* * *",
  "title": "Implementing a Random Post button on Bear Blog",
  "updatedAt": "2026-03-02T13:50:19.474Z"
}