feat(extraction): Hugo design-system support — Markdown, Templates, CSS/SCSS, YAML, JSON#311
Open
alexander-kastil wants to merge 1 commit into
Open
Conversation
- src/extraction/hugo-markdown-extractor.ts: new extractor for Hugo Markdown files, parsing front matter and headings. - src/extraction/hugo-template-extractor.ts: new extractor for Hugo template files, handling partials, blocks, and template calls. - src/extraction/languages/json.ts: new JSON extractor for top-level object keys in Hugo-related JSON files. - src/extraction/languages/yaml.ts: new YAML extractor for top-level mapping keys in Hugo-related YAML files. - src/extraction/scss-extractor.ts: new SCSS extractor extending CSSExtractor to handle SCSS-specific constructs like variables and mixins.
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.
What is Hugo?
Hugo is one of the most widely used open-source static site generators, built in Go. It powers documentation sites, corporate websites, developer blogs, and government portals across the industry. A Hugo project is organised around a distinct file tree: content (Markdown with front matter), layouts (Go
html/templatepartials and base templates), assets (CSS/SCSS, JS), and data (YAML/JSON/TOML configuration and site data). Until now CodeGraph treated almost all of these as opaque blobs.Why index CSS / SCSS?
Design systems live in CSS. When an AI agent needs to understand why a component looks the way it does, or wants to trace where a token like
--color-primaryis defined and consumed, it currently has no graph to walk — it can only grep. With full CSS/SCSS extraction:--custom-properties,$scss-variables) become first-classvariablenodes — searchable, linkable, and traceable across files.functionnodes, so an agent can find all callers of@include button-base()without a full-text search.@layerdeclarations becomenamespacenodes, making cascade-layer architecture visible in the graph.@use/@forward/@importproduce realimportsedges, so the SCSS module graph is walkable exactly like a TypeScript import graph.This matters most for Hugo sites (which commonly have a bespoke SCSS design system), but the extractors work on any project that uses CSS or SCSS.
What this PR adds
New language support
.md.markdowntitle,date,tags, …) aspropertynodes; headings asclass/functionnodes.html(underlayouts/orthemes/),.gohtml.tmpl.gotmplfunctionnode;{{ define }}blocks;{{ partial }}/{{ partialCached }}calls;{{ block }}slots;{{ template }}calls;$variableassignments.css--token),@keyframes,@layer,@import.scss.sass$variables,@mixin,@function,%placeholder,@use/@forward,@includecalls,@extendreferences.yml.yamlvariablenodes.jsonvariablenodesHugo Template path gating
Plain
.htmlfiles (e.g. email templates, test fixtures) are not processed. Only.htmlfiles whose path containslayouts/orthemes/are routed toHugoTemplateExtractor. Files with explicit Hugo extensions (.gohtml,.tmpl,.gotmpl) are always processed regardless of path.Infrastructure
src/types.ts— six newLanguageunion members:json,markdown,gotemplate,css,scss,sasssrc/extraction/grammars.ts— WASM grammar entries for YAML and JSON (tree-sitter); extension map entries for all new types;isLanguageSupported/isGrammarLoaded/getSupportedLanguagesupdatedsrc/extraction/languages/index.ts— YAML and JSON extractors registeredsrc/extraction/tree-sitter.ts— dispatch branches for the four new custom extractorsTest updates
__tests__/extraction.test.ts— replaced two assertions that incorrectly expected.cssand.jsonto resolve tounknown__tests__/security.test.ts— updatedisSourceFileexpectations now that CSS and Markdown are supported extensionsTest plan
npm testpassesnpm run buildsucceeds (YAML + JSON WASM files copy intodist/){{ partial "nav.html" . }}produces acallsedge$primary-colorappears as avariablenode.htmlfiles outsidelayouts/are not indexed as Hugo templates🤖 Generated with Claude Code