Skip to content

Latest commit

 

History

History
131 lines (93 loc) · 9.25 KB

File metadata and controls

131 lines (93 loc) · 9.25 KB

API Documentation: window.neoApi Object

This document describes the structure of the global JavaScript object window.neoApi() generated by the neo-parser.js script after parsing the HTML rendered by the neo-util.xml Blogger theme.

Availability: This object is available globally (window.neoApi()) after the DOMContentLoaded event has fired.

Note: This object is generated by parsing the page's DOM. Its structure and the availability of certain properties depend on the specific HTML elements and attributes rendered by the theme for the current page type. Some properties might be null or empty strings if the corresponding data couldn't be found in the DOM.

Top-Level Object: window.neoApi()

The main object containing all parsed data.

Property Type Description
blog Object General information about the blog and current page context. See Blog Object below.
pageType String A string indicating the detected type of the current page. See Page Types below.
page `Array Object

Blog Object (neoApi().blog)

Contains general information about the blog and the current page view, extracted primarily from the DOM.

Property Type Description Notes / Origin
title String The main title of the blog. Extracted from header h1 a or document.title.
homepageUrl String|null The root URL of the blog. Extracted from header h1 a. Can be null if not found.
url String The full URL of the currently viewed page. From window.location.href.
pageTitle String The title specific to the current page view. Extracted from page-specific H1/H2 or document.title.
pageName String|null The name associated with the current view (e.g., Archive month/year, Label name). Extracted from h2 on Archive/Label pages. null otherwise.
searchQuery String|null The search term used if on a search results page. Extracted from h2 on Search pages. null otherwise.

Page Types (neoApi().pageType)

A string indicating the type of the current page, inferred from the DOM structure. Possible values include:

  • 'homepage': The main blog homepage.
  • 'item': A single blog post page.
  • 'static_page': A static page (e.g., About, Contact).
  • 'archive': A date-based archive page (e.g., /2023/10/).
  • 'label': A page showing posts filtered by a specific label.
  • 'search': A page showing search results.
  • 'error': A standard Blogger 404 error page.
  • 'unknown': The parser couldn't identify the page type based on known structures.
  • 'parsing_error': An error occurred during the parsing process.

Page Data Object (neoApi().page)

This property holds the core content data for the current page. Its structure varies based on neoApi().pageType.

1. If pageType is 'homepage', 'archive', 'label', or 'search'

neoApi().page will be an Array of Post List Objects. Each object in the array represents a single post summary as displayed in the list/table.

Post List Object Structure:

Property Type Description Notes
postId String|null The unique ID of the blog post. From tr[data-post-id] or first table cell.
title String The title of the post.
url String The permalink URL of the post (as plain text).
publishedIso String The publication date in ISO 8601 format. From <time datetime="...">.
publishedFormatted String The publication date in the blog's display format. From <time>...</time> text content.
author String The name of the post author. May be empty depending on theme settings/data.
labels Array An array of Label Objects associated with the post. Empty array [] if no labels.
snippet String A short summary or snippet of the post content. May be empty if not available/configured.
firstImageUrl String|null The URL of the first image found in the post (resized thumbnail). null if no image found or placeholder text detected.

2. If pageType is 'item'

neoApi().page will be a single Post Detail Object.

Post Detail Object Structure:

Property Type Description Notes
postId String|null The unique ID of the blog post. Extracted from content div ID.
title String The title of the post. From h1[itemprop="headline"].
url String The permalink URL of the post. From window.location.href.
publishedIso String The publication date in ISO 8601 format. From <time[itemprop="datePublished"]>.
publishedFormatted String The publication date in the blog's display format. From <time[itemprop="datePublished"]>.
labels Array An array of Label Objects associated with the post. Empty array [] if no labels.
bodyHtml String The full HTML content of the post body. From div[itemprop="articleBody"].
pageTitle String The specific title of this page view. From neoApi().blog.pageTitle.
author String Currently not parsed. (Could be added if itemprop="author" exists)

3. If pageType is 'static_page'

neoApi().page will be a single Page Detail Object.

Page Detail Object Structure:

Property Type Description Notes
pageId String|null The unique ID of the static page. Extracted from content div ID.
title String The title of the static page. From h1.neo-page-title.
url String The URL of the static page. From window.location.href.
bodyHtml String The full HTML content of the page body. From div.neo-page-content.
pageTitle String The specific title of this page view. From neoApi().blog.pageTitle.

4. If pageType is 'error', 'unknown', or 'parsing_error'

neoApi().page will be a simple Message/Error Object.

Message/Error Object Structure (Example):

Property Type Description
title String The title extracted from the error/unknown page H1.
message String A descriptive message about the status/error.
error String (Optional) Error message if pageType is parsing_error.
details String (Optional) Further error details.
stack String (Optional) JavaScript error stack trace.

Label Object

Used within the labels array in Post List Objects and Post Detail Objects.

Property Type Description Notes
name String The display name of the label. From li[neo-label-name] or text.
url String|null The URL to the label search page for this label. From li[data-label-url] or a[href].