This sample plugin imports IMDb Top 250 movies into a Logseq DB graph. It's mainly a learning project to show how to create and write DB properties from external data (JSON/API).
- A modern, interactive UI that lists all 250 movies with flexible grouping options (by decade, year, rating, or director).
- Collapsible groups with expand/collapse all functionality for better navigation.
- One page per movie, tagged with
#movie. - Movie metadata written as DB properties (cover, rating, director, genre, year, duration, keywords).
- Automatic creation of director and genre pages with proper tagging.
- Latest Logseq Desktop
- A DB graph (the DB property APIs used here are for DB graphs)
- Node.js (LTS recommended)
On import, the plugin ensures:
-
Tags:
#movie- Applied to all imported movie pages#director- Applied to director pages (auto-created for each director)#genre- Applied to genre tags (auto-created for each unique genre)
-
Properties (attached to
#movietag):cover(string) - Movie poster image URLurl(default) - IMDb movie page URLrating(string) - IMDb rating scoredirector(node, many) - Reference to director page(s)genre(node, many) - Movie genres as tag referencesyear(string) - Release yearduration(string) - Movie runtimekeywords(string) - IMDb keywords
Then it creates a page for each movie and fills those properties with the corresponding data.
- Start the plugin (dev mode or built package).
- Click the IMDb Top 250 toolbar button (movie icon).
- Browse movies using the grouping options (by decade, year, rating, or director).
- Use the Collapse All / Expand All buttons to manage group visibility.
- Click Import All to Logseq to start the import process.
- The plugin will navigate to the
#movietag page after import is complete.
Note: The current code intentionally imports only 10 movies (demo/debug). See "Demo limit" below.
This plugin uses Vite for fast dev builds and React 18 with Bulma CSS for the UI.
To start development:
npm install # or yarn install
npm run dev # or yarn run devIn Logseq: enable Developer mode, then load the plugin using this project folder.
The plugin manifest is in package.json under the logseq field, and dev mode points to:
logseq.devEntry:http://localhost:5173
To build for production:
npm run build # or yarn run buildAll logic lives in index.tsx:
-
UI Components & State Management:
Appcomponent with React hooks for state managementgroupBystate for flexible grouping (none, decade, year, rating, director)collapsedGroupsstate for managing group expand/collapse- Custom SVG icons for better UX (chevrons, expand/collapse, import)
-
Create properties + attach them to tags:
createRelatedMetadataProperties()- Uses
logseq.Editor.upsertProperty(...)to create properties - Uses
logseq.Editor.createTag(...)to create#movie,#director,#genretags - Uses
logseq.Editor.addTagProperty(...)to attach properties to the#movietag
-
Import one movie (create page + write DB properties):
importItemToLogseq(movie, tipKey)- Uses
logseq.Editor.createPage(...)to create movie page - Uses
logseq.Editor.addBlockTag(...)to tag pages - Uses
logseq.Editor.upsertBlockProperty(...)to set property values - Creates director pages and genre tags with proper relationships
-
Import all movies (loop + throttle):
importAllToLogseq()- Shows progress messages during import
- Navigates to
#movietag page after completion - 100ms throttle between imports to avoid overwhelming Logseq
- DB graph only: if you don't use a DB graph, property/tag APIs may fail or behave differently.
- Demo limit (10 movies): in
importAllToLogseq(), there's adebugCounterthat stops after 10 items. Remove or adjust the following lines to import all 250: - Re-importing: importing again will try to create pages with the same movie title. Depending on Logseq behavior/version, this may result in no-op, duplicate titles, or errors.
- Genre and Director handling: The plugin automatically creates pages for directors and tags for genres, establishing many-to-many relationships through node properties.
- Performance: The plugin includes a 100ms throttle between imports to prevent overwhelming Logseq. Adjust this value in the
setTimeoutcall if needed.
MIT