
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@1password/docusaurus-plugin-stored-data
Advanced tools
Load local or external data to be used in Docusaurus
Load local or external data to be used in Docusaurus
Start by installing the dependency:
yarn add @1password/docusaurus-plugin-stored-data
npm i @1password/docusaurus-plugin-stored-data
Add the plugin to your docusaurus.config.js
file's "plugins" option. If you're new to Docusaurus plugins, click here to learn more about installing and configuring them.
These are the available plugin options:
type Options = {
/**
* Define key-value pairs, where the key is the ID you want to assign to the data,
* and the value is a local path or external URL to retrieve the data from.
*/
data: Record<string, string>;
};
Here's an example of how to set the plugin's options, loading both local and external data:
// docusaurus.config.js
const { resolve } = require("path");
plugins: [
[
'@1password/docusaurus-plugin-stored-data',
{
data: {
"blog-feed": "https://example.com/blog.xml",
"rust-example": resolve(__dirname, "static", "example.rs"),
}
}
]
],
Now, when you start your dev server or build the site, the plugin will retrieve the contents of each location specified in the config and store it as plugin data. Access this data in your site using one of the plugin's hooks, which takes the ID and returns the data in various formats.
The following hooks are available:
@theme/useStoredData
- Returns the data unformatted@theme/useStoredJson
- Returns the data parsed as JSON@theme/useStoredFeed
- Returns the data parsed as RSS XML into JSON structure using fast-xml-parser.Here's an example of how you might use the plugin to retrieve and render blog posts from an RSS feed:
// FeedItems.tsx
import useStoredFeed from "@theme/useStoredFeed";
const FeedItems = () => {
const feedData = useStoredFeed("blog-feed");
return (
<ul>
{feedData.item.map((item) => (
<li key={item.guid}>{item.title}</li>
))}
</ul>
);
};
Or, if your data can be rendered without modification you can simply call a hook directly inside an MDX file:
// example.mdx
import CodeBlock from "@theme/CodeBlock";
import useStoredData from "@theme/useStoredData";
<CodeBlock language="rust">{useStoredData("rust-example")}</CodeBlock>;
If you're using TypeScript you will need to reference the plugin's types:
// types.d.ts
/// <reference types="@1password/docusaurus-plugin-stored-data" />
MIT
FAQs
Load local or external data to be used in Docusaurus
The npm package @1password/docusaurus-plugin-stored-data receives a total of 9 weekly downloads. As such, @1password/docusaurus-plugin-stored-data popularity was classified as not popular.
We found that @1password/docusaurus-plugin-stored-data demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.