Skip to content

Commit

Permalink
init website nostr-php.dev build with Vitepress
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastix committed Jun 6, 2024
1 parent b7a8604 commit bae0dfa
Show file tree
Hide file tree
Showing 9 changed files with 1,910 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
composer.lock
test*.php
vendor/

/.phpdoc/cache/

/website/content/.vitepress/dist/
/website/content/.vitepress/cache/
/website/node_modules/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ More info about Nostr: https://github.com/nostr-protocol/nostr.

## Installation

To use in your project with Composer:
To use the package in your PHP project with Composer:

```console
$ composer require nostrverse/nostr-php
Expand Down
1 change: 1 addition & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# https://nostr-php.dev website
29 changes: 29 additions & 0 deletions website/content/.vitepress/config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "nostr-php",
description: "A PHP helper library for Nostr",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
// { text: 'Examples', link: '/markdown-examples' }
],

// sidebar: [
// {
// text: 'Examples',
// items: [
// { text: 'Markdown Examples', link: '/markdown-examples' },
// { text: 'Runtime API Examples', link: '/api-examples' }
// ]
// }
// ],

socialLinks: [
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
]
},
cleanUrls: true
})
49 changes: 49 additions & 0 deletions website/content/api-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
outline: deep
---

# Runtime API Examples

This page demonstrates usage of some of the runtime APIs provided by VitePress.

The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:

```md
<script setup>
import { useData } from 'vitepress'

const { theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>
```

<script setup>
import { useData } from 'vitepress'

const { site, theme, page, frontmatter } = useData()
</script>

## Results

### Theme Data
<pre>{{ theme }}</pre>

### Page Data
<pre>{{ page }}</pre>

### Page Frontmatter
<pre>{{ frontmatter }}</pre>

## More

Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
79 changes: 79 additions & 0 deletions website/content/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home

hero:
name: "nostr-php"
text: "A PHP helper library for Nostr"
# tagline: My great project tagline
actions:
# - theme: brand
# text: Markdown Examples
# link: /markdown-examples
- theme: alt
text: Chat
link: https://t.me/nostr_php
- theme: alt
text: View source code
link: https://github.com/nostrver-se/nostr-php


features:
- title: Publish events
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
- title: Read events
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
- title: Examples
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
---

Add the nostr-php to your PHP project with Composer

```bash
composer require nostrverse/nostr-php
```

Here is very simple example:

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use nostrverse\nostr\Event\Event;
use nostrverse\nostr\Key\Key;
use nostrverse\nostr\Message\EventMessage;
use nostrverse\nostr\Relay\Relay;
use nostrverse\nostr\Sign\Sign;

function send($message) {
try {
$key = new Key();
$private_key = $key->generatePrivateKey(); // this will generate a private key
$private_key_hex = $key->convertToHex($private_key);
$public_key = $key->getPublicKey($private_key_hex);
$relayUrl = 'wss://relay.damus.io';
$note = new Event();
$note->setKind(1);
$note->addTag(['p', $public_key]);
$note->addTag(['r', $relayUrl]);
$note->setContent($message);
$signer = new Sign();
$signer->signEvent($note, $private_key);
$eventMessage = new EventMessage($note);
$relay = new Relay($relayUrl, $eventMessage);
$result = $relay->send();
if ($result->isSuccess()) {
print "The event has been sent to Nostr!\n";
} else {
print 'Something went wrong: ' . $result->message() . "\n";
}
} catch (Exception $e) {
print 'Exception error: ' . $e->getMessage() . "\n";
}
}

$message = 'Hello world ' . date('Y-m-d H:i:s');
send($message);

```
85 changes: 85 additions & 0 deletions website/content/markdown-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Markdown Extension Examples

This page demonstrates some of the built-in markdown extensions provided by VitePress.

## Syntax Highlighting

VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:

**Input**

````md
```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```
````

**Output**

```js{4}
export default {
data () {
return {
msg: 'Highlighted!'
}
}
}
```

## Custom Containers

**Input**

```md
::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::
```

**Output**

::: info
This is an info box.
:::

::: tip
This is a tip.
:::

::: warning
This is a warning.
:::

::: danger
This is a dangerous warning.
:::

::: details
This is a details block.
:::

## More

Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
Loading

0 comments on commit bae0dfa

Please sign in to comment.