Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Astro content loader for policies #180

Merged
merged 12 commits into from
Jan 6, 2025

Conversation

gingerchew
Copy link
Contributor

This pulls from the namesake.fyi policy repo and renders the content to html storing it and the headings metadata in the content layer.

This makes it available like so:

---
import { getEntry } from "astro:content";
const entry = await getEntry('policy', 'terms');
const  { Content, headings } = await render(entry);
---
<Content />

Made a separate PR from the work on the TableOfContents since it was a separate scope.

this pulls from the namesake.fyi policy repo and renders the content to html
storing it and the headings metadata in the content layer.

This makes it available like so:

```astro
---
import { getEntry } from "astro:content";
const entry = await getEntry('policy', 'terms');
const  { Content, headings } = await render(entry);
---
<Content />
```
@gingerchew
Copy link
Contributor Author

Would resolve #166

@evadecker
Copy link
Member

This is great! I imagine others could benefit from this as well... have you considered publishing an npm package?

Copy link
Member

@evadecker evadecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works! Nicely done.

Can we also update src/pages/abuse.astro and src/pages/subprocessors.astro?

src/content.config.ts Outdated Show resolved Hide resolved
src/content.config.ts Outdated Show resolved Hide resolved
src/pages/privacy.astro Outdated Show resolved Hide resolved
src/pages/terms.astro Outdated Show resolved Hide resolved
Convert abuse and subprocessors to use content collection
…rk pkg

Thankfully the way the markdown package works, we're able to get it with very little need
for documenting on our own as it is very straight forward.

1. Get config from LoaderContext
2. Create markdownProcessor
3. Use processor
4. Change the names of the output to match what the data store expects
5. Profit
@evadecker evadecker changed the title Adds policy content layer loader feat: Add Astro content loader for policies Jan 6, 2025
Copy link
Member

@evadecker evadecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Thanks for leading this :)

You may need to pull from main and run pnpm i to resolve the conflicts.

@evadecker evadecker linked an issue Jan 6, 2025 that may be closed by this pull request
This version takes a config object with repo, username, and a processors object

the processors object is just a collection of functions categorized by file extension to
process the give file type
@gingerchew
Copy link
Contributor Author

Okay, should be all squared now once this is merged in, I'll update the TOC branch and get that finished up too :)

@evadecker
Copy link
Member

Thanks so much for your help here @gingerchew! Awesome to see this evolve + use the latest Astro tech + publish a package! Nicely done!

@evadecker evadecker merged commit 86132c5 into namesakefyi:main Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load policy data using Astro Collection loaders
2 participants