feat(beholder)!: expand meta extraction with frontmatter-keys schema and Wappalyzer tag detection#878
Merged
Conversation
…and Wappalyzer tag detection
BREAKING CHANGE: `Meta` is restructured from flat keys (`noindex`, `canonical`,
`'og:type'`, `'twitter:card'`, ...) into a nested shape backed by
`frontmatter-keys.md`. New required fields: `title`, `jsonLd`,
`speculationRules`, `originTrial`, `tags`, `others`. `getMeta(page)` now takes
a context object `getMeta(page, { url, html?, statusCode?, headers? }, timeout?)`.
Old top-level shortcuts (`canonical`, `alternate`, `noindex`, `nofollow`,
`noarchive`, `'og:*'`, `'twitter:card'`) are removed; values move to
`meta.link.canonical`, `meta.robots.*`, `meta.og.*`, `meta.twitter.*` etc.
Changes:
- New `src/meta/` module: `types.ts`, `keys.ts`, `parsers.ts`, `classify.ts`,
`id-extractors.ts`, `tag-detection.ts`, plus ambient `simple-wappalyzer.d.ts`
- Browser-side `collectHead()` serializes every `<meta>`, `<link>`, structured-data
`<script>`, `<base>`, `<iframe>` plus a curated set of `window` globals into
`RawHeadEntry[]`; Node-side `classify()` maps these to typed Meta fields
- `simple-wappalyzer` (MIT) added as a dependency for technology detection;
detected providers run through `id-extractors.ts` for real ID extraction
(GA4, GTM, UA, FB Pixel, Hotjar, Clarity, ...)
- Unknown markup is preserved under `Meta.others` (meta/property/httpEquiv/
itemprop/link/script/iframe buckets) so nothing is silently dropped
- Tests: parsers/classify/id-extractors/tag-detection units + getMeta
error/timeout fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<head>から取得する meta 情報をfrontmatter-keys.md仕様で全面拡張。フラットキー ('og:type',noindex等) からネスト構造 (og.type,robots.noindex等) に再設計。約 500 のキーをホワイトリストで型付き取得、未知キーはMeta.othersに漏れなく保持simple-wappalyzer(MIT) を依存に追加し、~2000 の技術スタックを検出。検出 provider をトリガーにid-extractors.tsで GA4/GTM/UA/FB Pixel/Hotjar/Clarity 等の実 ID を抽出してMeta.tagsに格納collectHead()で属性タプル列を返し、Node 側classify()で純粋関数として分類するアーキテクチャに変更。raceWithTimeout内で並列実行Breaking Changes
@d-zero/beholderのMeta型とgetMeta()の API が破壊的に変わりました。Major bump (2.x→3.0.0) が必要です。meta.canonicalmeta.link?.canonicalmeta.alternatemeta.link?.alternateHreflang(配列) など type/media で分岐meta.noindexmeta.robots?.noindexmeta.nofollowmeta.robots?.nofollowmeta.noarchivemeta.robots?.noarchivemeta['og:type']meta.og?.typemeta['og:title']meta.og?.titlemeta['og:url']meta.og?.urlmeta['og:site_name']meta.og?.siteNamemeta['og:description']meta.og?.descriptionmeta['og:image']meta.og?.image(配列)meta['twitter:card']meta.twitter?.cardgetMeta(page, timeout?)getMeta(page, { url, html?, statusCode?, headers? }, timeout?)新しい required フィールド:
title,jsonLd,speculationRules,originTrial,tags,others。それ以外は optional。New capabilities
JSON.parse済みで取得 (パース失敗時はparseError付き raw を保持)Meta.tags: Wappalyzer カテゴリ別に技術スタックを集計、entries[]でフラットリストMeta.others: 未知の meta name / property / http-equiv / itemprop / link rel / script type / iframe を全件保持Test plan
yarn lint通過 (cspell 辞書に meta tag 関連の特殊用語を追加)yarn build通過 (27 packages)yarn test通過 (757 tests including 119 new tests for meta extraction)