docs icon indicating copy to clipboard operation
docs copied to clipboard

Update markdown-content.md

Open nujovich opened this issue 3 years ago β€’ 3 comments

What kind of changes does this PR include?

  • New or updated content

Description

  • Closes #1715
  • Add config example for Shiki's relative path themes
  • Visual changes

Before

image

After

image

I am actively participating in Hacktoberfest and Hacksquad 2022 πŸ™Œ.

nujovich avatar Oct 08 '22 02:10 nujovich

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
Latest commit 586d4affbdb93e3e826ab4780495d39689e73d69
Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/635bb3d5cb4c500009a1402e
Deploy Preview https://deploy-preview-1749--astro-docs-2.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.

netlify[bot] avatar Oct 08 '22 02:10 netlify[bot]

Thanks for tackling this issue, @nujovich! πŸ₯³ A great first contribution!

I'm wondering whether this deserves an entire new code block, though, and maybe we can work it into the existing example itself? Or at the very least, what about a condensed second example that just shows the theme property and not the whole thing? Would you be willing to make that second code example smaller so we can see what that looks like?

sarah11918 avatar Oct 10 '22 14:10 sarah11918

Sure @sarah11918! Let me work on that!

nujovich avatar Oct 11 '22 01:10 nujovich

Hello @nujovich and @sarah11918,

I was trying to add a new theme to my config file. I noticed that any string passed to shikiConfig.theme will try to resolve to the themes folder inside the shiki package.

So in order to add your own theme to the package you will need follow shiki's guide: add a new theme. This will modify your shiki package and add the theme to the list of themes.

However, shiki is not a direct dependency of your project then there would be more steps to add your own theme πŸ˜₯

An easier way to do this is to import the json and pass it to shikiConfig.theme

import { defineConfig } from 'astro/config';
import customTheme from './src/custom-themes/dracula.json';

export default defineConfig({
  site: 'https://example.com',
  markdown: {
    shikiConfig: {
      theme: customTheme,
    },
  },
});

Hope this helps πŸ˜‡

Oh btw here is the stackblitz

kevinzunigacuellar avatar Oct 21 '22 20:10 kevinzunigacuellar

Hello @nujovich and @sarah11918,

I was trying to add a new theme to my config file. I noticed that any string passed to shikiConfig.theme will try to resolve to the themes folder inside the shiki package.

So in order to add your own theme to the package you will need follow shiki's guide: add a new theme. This will modify your shiki package and add the theme to the list of themes.

However, shiki is not a direct dependency of your project then there would be more steps to add your own theme πŸ˜₯

An easier way to do this is to import the json and pass it to shikiConfig.theme

import { defineConfig } from 'astro/config';
import customTheme from './src/custom-themes/dracula.json';

export default defineConfig({
  site: 'https://example.com',
  markdown: {
    shikiConfig: {
      theme: customTheme,
    },
  },
});

Hope this helps πŸ˜‡

Oh btw here is the stackblitz

Awesome ! I will try that and add it to the docs.

nujovich avatar Oct 21 '22 21:10 nujovich

Thanks again for your contribution @nujovich! Welcome to team docs πŸ₯³

delucis avatar Oct 28 '22 11:10 delucis

Hello @nujovich and @sarah11918,

I was trying to add a new theme to my config file. I noticed that any string passed to shikiConfig.theme will try to resolve to the themes folder inside the shiki package.

So in order to add your own theme to the package you will need follow shiki's guide: add a new theme. This will modify your shiki package and add the theme to the list of themes.

However, shiki is not a direct dependency of your project then there would be more steps to add your own theme πŸ˜₯

An easier way to do this is to import the json and pass it to shikiConfig.theme

import { defineConfig } from 'astro/config';
import customTheme from './src/custom-themes/dracula.json';

export default defineConfig({
  site: 'https://example.com',
  markdown: {
    shikiConfig: {
      theme: customTheme,
    },
  },
});

Hope this helps πŸ˜‡

Oh btw here is the stackblitz

Hi!! I tryed this with a custom theme. The thing is when I change anything on the astro.config.mjs I don't see any changes at all. Even if I use this shikiConfig: { theme: 'dracula' }. IT won't work so when I use my customThem like this shikiConfig: { theme: customTheme } it doesn't work either.

Any thoughts why it doesn't work??

thanks a lot!!

Ivluengo avatar Nov 10 '22 17:11 Ivluengo

Hey @Ivluengo! Little bit hard to see without seeing more of your project. If this isn’t working, the best would be to create a bug report with a reproduction in the astro repo so we can look at fixing it: https://github.com/withastro/astro/issues/new/choose

Alternatively, we have a really active #support channel in the Astro Discord server which is a great place to share code examples and troubleshoot β€” https://astro.build/chat

delucis avatar Nov 10 '22 17:11 delucis