Coder Social home page Coder Social logo

Comments (13)

alexcibotari avatar alexcibotari commented on August 21, 2024 2

As I statically generate my site, I want them to be generated during build time also, not on client side. At the moment I can achieve it only with server page. Is there any other way you will suggest to deal with static generation of content from headless CMS ?

from analog.

brandonroberts avatar brandonroberts commented on August 21, 2024

I see, so you're just using the markdown component with loading your own content. You can try adding this to your bootstrap providers in the app.config.ts

// ... other imports
import { ContentRenderer, MarkdownContentRendererService } from '@analogjs/content';

export const appConfig: ApplicationConfig = {
  providers: [
    // ... other providers
    provideContent(
      withMarkdownRenderer({
        loadMermaid: () => import('mermaid'),
      }),
      withPrismHighlighter()
    ),
    { provide: ContentRenderer, useClass: MarkdownContentRendererService }
  ],
};

from analog.

alexcibotari avatar alexcibotari commented on August 21, 2024

Now it works

Only the code highlighter is not working ))

image

from analog.

brandonroberts avatar brandonroberts commented on August 21, 2024

Add these imports to your app.config.ts

import 'prismjs/components/prism-bash';
import 'prismjs/components/prism-css';
import 'prismjs/components/prism-javascript';
import 'prismjs/components/prism-json';
import 'prismjs/components/prism-markup';
import 'prismjs/components/prism-typescript';

from analog.

alexcibotari avatar alexcibotari commented on August 21, 2024

I think make sens to add it into instructions, otherwise it is confusing how to integrate with syntax highlights .

Same for providers, make sense to add it to content providers, what is the sens to initiate content provider and separately markdown service

from analog.

brandonroberts avatar brandonroberts commented on August 21, 2024

@alexcibotari In 1.6, we introduced build-time markdown rendering and syntax highlighting, so it doesn't need to be done client-side.

If you were using injectContent and not pulling from a CMS, it works just the same without the manual imports.

We can add some instructions for those who want to do rendering/syntax highlighting client-side.

from analog.

brandonroberts avatar brandonroberts commented on August 21, 2024

As I statically generate my site, I want them to be generated during build time also, not on client side. At the moment I can achieve it only with server page. Is there any other way you will suggest to deal with static generation of content from headless CMS ?

Yes, we can add some guidance on using a headless CMS. Do you have an example repo using a headless CMS?

from analog.

alexcibotari avatar alexcibotari commented on August 21, 2024

I can add you to one of my repositories for a website with Headless CMS integration. Also, based on your guidance I can create a public example to share with everyone.

from analog.

brandonroberts avatar brandonroberts commented on August 21, 2024

👍

from analog.

alexcibotari avatar alexcibotari commented on August 21, 2024

Done. I wrote an email, just in case it will require me to share some private information.

from analog.

alexcibotari avatar alexcibotari commented on August 21, 2024

I found out that without adding MarkedSetupService in providers it will not work.

At the same time, the UI is flickering after refresh

You can check it here : https://localess.org/docs/sdk/typescript

Prismic

from analog.

brandonroberts avatar brandonroberts commented on August 21, 2024

@alexcibotari I released a patch version with a fix for the flickering 1.6.2-beta.2. You can set up these providers for client side rendering and syntax highlighting.

  providers: [
    MarkedSetupService,
    provideContent(
      withMarkdownRenderer({
        loadMermaid: () => import('mermaid'),
      }),
      withHighlighter({ useClass: PrismHighlighter })
    ),
    {provide: ContentRenderer, useClass: MarkdownContentRendererService},
  ]

from analog.

alexcibotari avatar alexcibotari commented on August 21, 2024

@brandonroberts Thank you, the flickering is fixed.

from analog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.