Skip to content

feat(document-driven): add document-driven as a @nuxt/content feature - #1279

Merged
Tahul merged 17 commits into
mainfrom
feat/document-driven
Jun 23, 2022
Merged

feat(document-driven): add document-driven as a @nuxt/content feature#1279
Tahul merged 17 commits into
mainfrom
feat/document-driven

Conversation

@Tahul

@TahulTahul commented Jun 22, 2022

Copy link
Copy Markdown
Contributor

❓ Type of change

  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)

📚 Description

This PR adds documentDriven as a new feature for the module.

This feature basically is a more generic approach than @docus/base.

It offers more flexibility while preserving the same features as a default.

Here is a preview from the config object:

constdefaultDocumentDrivenConfig={// Will fetch page globallypage: true,// Will fetch navigation globallynavigation: true,// Will fetch surround globallysurround: true,// `globals` key definitionglobals: {// Will fetch `_theme.yml` and put it in `globals.theme`theme: {where: [{_id: 'content:_theme.yml'}],without: ['_']}},// Will use `theme` global to fallback on layout resolutionlayoutFallbacks: ['theme'],// Will inject pre-configured `[...slug].vue` pageinjectPage: true}

These datas becomes globally available via the useDocumentDriven() composable:

const{ page, navigation, surround, globals }=useDocumentDriven()

I updated the documentation with new pages:

/guide/writing/document-driven
/api/composables/use-document-driven
/api/composables/use-content-helpers
/api/configuration (new content)
/examples/document-driven/hello-world (new example)

This PR also deeply refactors the playground/ and test/ directories.

You can now run scoped playground with these commands:

yarn dev => `playground/basic`
yarn dev basic => `playground/basic`
yarn dev document-driven => `playground/document-driven`

Same applies to test:

yarn test => `Run all test suite`
yarn test basic => `basic.test.ts`
yarn test module => `module.test.ts`
yarn test document-driven => `document-driven.test.ts`

Any feedback to the API or implementation is more than welcome!

📝 Checklist

  • I have updated the documentation accordingly.

TODO:

@netlify

netlifyBot commented Jun 22, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt-content ready!

NameLink
🔨 Latest commit7c8650a
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt-content/deploys/62b4907587a6b2000854b966
😎 Deploy Previewhttps://deploy-preview-1279--nuxt-content.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Tahul
Tahul requested review from atinux and farnabaz and removed request for farnabazJune 22, 2022 15:26
@atinux

Copy link
Copy Markdown
Member

Beautiful work @Tahul ❤️

I think we could go with

const{ page, navigation, surround, globals }=useContent()

And warn to say that this composable is available only with content.documentDrivent mode activated.

Comment threadsrc/runtime/components/DocumentDrivenEmpty.ts Outdated
Comment threadsrc/runtime/components/DocumentDrivenEmpty.ts Outdated
Comment threadsrc/runtime/components/DocumentDrivenNotFound.ts Outdated
Tahuland others added 3 commits June 23, 2022 13:34
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
@Tahul

Copy link
Copy Markdown
ContributorAuthor

Beautiful work @Tahul ❤️

I think we could go with

const{ page, navigation, surround, globals }=useContent()

And warn to say that this composable is available only with content.documentDrivent mode activated.

yaaaay! 🚀

Pushing that really soon!

@Tahul

Copy link
Copy Markdown
ContributorAuthor

@atinux ; I renamed useDocumentDriven into useContent :)

WDYT about merging this feature?

@atinux

Copy link
Copy Markdown
Member

I would like to have also a review from @farnabaz

@atinux

Copy link
Copy Markdown
Member

I think you can also rename the composable filename @Tahul

@farnabazfarnabaz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@Tahul
Tahul merged commit 2880bee into mainJun 23, 2022
@Tahul
Tahul deleted the feat/document-driven branch June 23, 2022 16:20
@Tahul
Tahul restored the feat/document-driven branch June 27, 2022 12:18
@Tahul
Tahul deleted the feat/document-driven branch June 27, 2022 12:19
@farnabazfarnabaz mentioned this pull request Aug 12, 2022
farnabaz pushed a commit that referenced this pull request Sep 7, 2022
Sign up for freeto 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.

3 participants

@Tahul@atinux@farnabaz