Allow code blocks inside blogposts
This commit is contained in:
parent
f96124b744
commit
5e3746eb51
4 changed files with 45 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
|||
from wagtail.blocks import RichTextBlock
|
||||
|
||||
from base.blocks import StreamBlock
|
||||
from wagtailcodeblock.blocks import CodeBlock
|
||||
|
||||
class BlogPostBlock(StreamBlock):
|
||||
paragraph = RichTextBlock(blank=True)
|
||||
paragraph = RichTextBlock(blank=True)
|
||||
code = CodeBlock(label='Code snippet')
|
||||
|
|
20
blog/migrations/0009_alter_blogpage_body.py
Normal file
20
blog/migrations/0009_alter_blogpage_body.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 5.0.2 on 2024-03-14 02:57
|
||||
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('blog', '0008_alter_blogpage_body'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='blogpage',
|
||||
name='body',
|
||||
field=wagtail.fields.StreamField([('paragraph', wagtail.blocks.RichTextBlock(blank=True)), ('code', wagtail.blocks.StructBlock([('language', wagtail.blocks.ChoiceBlock(choices=[('bash', 'Bash/Shell'), ('css', 'CSS'), ('diff', 'diff'), ('html', 'HTML'), ('javascript', 'Javascript'), ('json', 'JSON'), ('python', 'Python'), ('scss', 'SCSS'), ('yaml', 'YAML')], help_text='Coding language', identifier='language', label='Language')), ('code', wagtail.blocks.TextBlock(identifier='code', label='Code'))], label='Code snippet'))], blank=True, help_text='Write anything'),
|
||||
),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue