mirror of
https://github.com/Fluffy-Bean/website.git
synced 2025-05-14 08:02:16 +00:00
106 lines
2.5 KiB
Text
106 lines
2.5 KiB
Text
---
|
|
draft: true
|
|
title: "Code Examples"
|
|
description: "Aurghhhhhh"
|
|
pubDate: 2022-07-08
|
|
tags:
|
|
- "code"
|
|
---
|
|
|
|
```astro
|
|
---
|
|
import { getPosts } from "../../utils";
|
|
import Layout from "../../layouts/Layout.astro";
|
|
import Markdown from "../../layouts/Markdown.astro";
|
|
|
|
export async function getStaticPaths() {
|
|
const collection = await getPosts("projects");
|
|
|
|
return collection.map((post, i) => ({
|
|
params: { slug: post.slug },
|
|
props: {
|
|
post: post,
|
|
prev: i > 0 ? collection[i - 1] : undefined,
|
|
next: i < collection.length - 1 ? collection[i + 1] : undefined
|
|
}
|
|
}));
|
|
}
|
|
|
|
const { post, prev, next } = Astro.props;
|
|
---
|
|
|
|
<Layout title=`Leggy Land - ${post.data.title}` src={post.data.image.url} alt={post.data.image.alt}>
|
|
<Markdown {post} {prev} {next} base="/projects" />
|
|
</Layout>
|
|
```
|
|
|
|
```scss
|
|
.astro-code {
|
|
padding: 36px 8px 8px;
|
|
|
|
position: relative;
|
|
|
|
display: block;
|
|
|
|
font-size: 13px;
|
|
|
|
border-radius: $radius;
|
|
|
|
&::before {
|
|
content: "lang: " attr(data-language);
|
|
|
|
padding: 4px 8px;
|
|
|
|
width: 100%;
|
|
height: 28px;
|
|
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
|
|
font-size: 13px;
|
|
|
|
background-color: $gray;
|
|
color: $light;
|
|
}
|
|
}
|
|
```
|
|
|
|
```go
|
|
func (p *penTool) Render() raylib.Texture2D {
|
|
offset := raylib.Vector2Scale(canvas.Offset, -1)
|
|
texture := raylib.LoadRenderTexture(int32(canvas.Size.X), int32(canvas.Size.Y))
|
|
|
|
raylib.BeginTextureMode(texture)
|
|
raylib.ClearBackground(raylib.Fade(raylib.Black, 0))
|
|
for i := 0; i < len(p.Points)-1; i++ {
|
|
startPointOffset := raylib.Vector2Add(p.Points[i], offset)
|
|
endPointOffset := raylib.Vector2Add(p.Points[i+1], offset)
|
|
raylib.DrawLineEx(startPointOffset, endPointOffset, p.Size, p.Color)
|
|
raylib.DrawCircle(int32(startPointOffset.X), int32(startPointOffset.Y), p.Size/2, p.Color)
|
|
}
|
|
if len(p.Points) > 0 {
|
|
endPointOffset := raylib.Vector2Add(p.Points[len(p.Points)-1], offset)
|
|
raylib.DrawCircle(int32(endPointOffset.X), int32(endPointOffset.Y), p.Size/2, p.Color)
|
|
}
|
|
raylib.EndTextureMode()
|
|
|
|
return texture.Texture
|
|
}
|
|
```
|
|
|
|
```python
|
|
from django.db import models
|
|
|
|
|
|
class Article(models.Model):
|
|
title = models.CharField(max_length=255)
|
|
slug = models.SlugField()
|
|
body = models.TextField()
|
|
date = models.DateTimeField(auto_now_add=True)
|
|
thumb = models.ImageField(default="default.png", blank=True)
|
|
published = models.BooleanField(default=False)
|
|
|
|
def __str__(self):
|
|
return self.title
|
|
```
|